summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/new-solver/generalize
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /tests/ui/traits/new-solver/generalize
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/traits/new-solver/generalize')
-rw-r--r--tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs73
-rw-r--r--tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs75
-rw-r--r--tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr18
3 files changed, 0 insertions, 166 deletions
diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs
deleted file mode 100644
index b0b9b6bbd..000000000
--- a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-// compile-flags: -Ztrait-solver=next
-// check-pass
-
-// A minimization of an ambiguity when using typenum. See
-// https://github.com/rust-lang/trait-system-refactor-initiative/issues/55
-// for more details.
-trait Id {
- type Assoc: ?Sized;
-}
-impl<T: ?Sized> Id for T {
- type Assoc = T;
-}
-
-trait WithAssoc<T: ?Sized> {
- type Assoc: ?Sized;
-}
-
-
-struct Leaf;
-struct Wrapper<U: ?Sized>(U);
-
-impl<U: ?Sized> WithAssoc<U> for Leaf {
- type Assoc = U;
-}
-
-impl<Ul: ?Sized, Ur: ?Sized> WithAssoc<Wrapper<Ur>> for Wrapper<Ul>
-where
- Ul: WithAssoc<Ur>,
-{
- type Assoc = <<Ul as WithAssoc<Ur>>::Assoc as Id>::Assoc;
-}
-
-fn bound<T: ?Sized, U: ?Sized, V: ?Sized>()
-where
- T: WithAssoc<U, Assoc = V>,
-{
-}
-
-// normalize self type to `Wrapper<Leaf>`
-// This succeeds, HOWEVER, instantiating the query response previously
-// incremented the universe index counter.
-// equate impl headers:
-// <Wrapper<Leaf> as WithAssoc<<Wrapper<Leaf> as Id>::Assoc>>
-// <Wrapper<?2t> as WithAssoc<Wrapper<?3t>>>
-// ~> AliasRelate(<Wrapper<Leaf> as Id>::Assoc, Equate, Wrapper<?3t>)
-// add where bounds:
-// ~> Leaf: WithAssoc<?3t>
-// equate with assoc type:
-// ?0t
-// <Leaf as WithAssoc<?3t>>::Assoc as Id>::Assoc
-// ~> AliasRelate(
-// <<Leaf as WithAssoc<?3t>>::Assoc as Id>::Assoc,
-// Equate,
-// <<Leaf as WithAssoc<?4t>>::Assoc as Id>::Assoc,
-// )
-//
-// We do not reuse `?3t` during generalization because `?0t` cannot name `?4t` as we created
-// it after incrementing the universe index while normalizing the self type.
-//
-// evaluate_added_goals_and_make_query_response:
-// AliasRelate(<Wrapper<Leaf> as Id>::Assoc, Equate, Wrapper<?3t>)
-// YES, constrains ?3t to Leaf
-// AliasRelate(
-// <<Leaf as WithAssoc<Leaf>>::Assoc as Id>::Assoc,
-// Equate,
-// <<Leaf as WithAssoc<?4t>>::Assoc as Id>::Assoc,
-// )
-//
-// Normalizing <<Leaf as WithAssoc<?4t>>::Assoc as Id>::Assoc then *correctly*
-// results in ambiguity.
-fn main() {
- bound::<<Wrapper<Leaf> as Id>::Assoc, <Wrapper<Leaf> as Id>::Assoc, _>()
-}
diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs
deleted file mode 100644
index 94d645a98..000000000
--- a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-// compile-flags: -Ztrait-solver=next
-// known-bug: trait-system-refactor-initiative#60
-
-// Generalizing a projection containing an inference variable
-// which cannot be named by the `root_vid` can result in ambiguity.
-//
-// Because we do not decrement the universe index when exiting a forall,
-// this can cause unexpected failures.
-//
-// See generalize-proj-new-universe-index-1.rs for more details.
-
-// For this reproduction we need:
-// - an inference variable with a lower universe
-// - enter a binder to increment the current universe
-// - create a new inference variable which is constrained by proving a goal
-// - equate a projection containing the new variable with the first variable
-// - generalization creates yet another inference variable which is then
-// part of an alias-relate, resulting this to fail with ambiguity.
-//
-// Because we need to enter the binder in-between the creation of the first
-// and second inference variable, this is easiest via
-// `assemble_candidates_after_normalizing_self_ty` because eagerly call
-// `try_evaluate_added_goals` there before creating the inference variables
-// for the impl parameters.
-trait Id {
- type Assoc: ?Sized;
-}
-impl<T: ?Sized> Id for T {
- type Assoc = T;
-}
-
-// By adding an higher ranked bound to the impl we currently
-// propagate this bound to the caller, forcing us to create a new
-// universe.
-trait IdHigherRankedBound {
- type Assoc: ?Sized;
-}
-
-impl<T: ?Sized> IdHigherRankedBound for T
-where
- for<'a> T: 'a,
-{
- type Assoc = T;
-}
-
-trait WithAssoc<T: ?Sized> {
- type Assoc: ?Sized;
-}
-
-
-struct Leaf;
-struct Wrapper<U: ?Sized>(U);
-struct Rigid;
-
-impl<U: ?Sized> WithAssoc<U> for Leaf {
- type Assoc = U;
-}
-
-
-impl<Ur: ?Sized> WithAssoc<Wrapper<Ur>> for Rigid
-where
- Leaf: WithAssoc<Ur>,
-{
- type Assoc = <<Leaf as WithAssoc<Ur>>::Assoc as Id>::Assoc;
-}
-
-fn bound<T: ?Sized, U: ?Sized, V: ?Sized>()
-where
- T: WithAssoc<U, Assoc = V>,
-{
-}
-
-fn main() {
- bound::<<Rigid as IdHigherRankedBound>::Assoc, <Wrapper<Leaf> as Id>::Assoc, _>()
-}
diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr
deleted file mode 100644
index 9aa4f4531..000000000
--- a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error[E0284]: type annotations needed: cannot satisfy `<<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc == <<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc`
- --> $DIR/generalize-proj-new-universe-index-2.rs:74:5
- |
-LL | bound::<<Rigid as IdHigherRankedBound>::Assoc, <Wrapper<Leaf> as Id>::Assoc, _>()
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc == <<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc`
- |
-note: required by a bound in `bound`
- --> $DIR/generalize-proj-new-universe-index-2.rs:69:21
- |
-LL | fn bound<T: ?Sized, U: ?Sized, V: ?Sized>()
- | ----- required by a bound in this function
-LL | where
-LL | T: WithAssoc<U, Assoc = V>,
- | ^^^^^^^^^ required by this bound in `bound`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0284`.