From 2c7ede8f52fb2d861ab875ac44ddd88850315cc6 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 26 Feb 2024 10:19:11 +0100 Subject: [PATCH] update tests --- .../occurs-check/associated-type.next.stderr | 4 --- .../occurs-check/opaques.next.stderr | 6 ++-- .../auto-trait-coherence.next.stderr | 4 +-- tests/ui/impl-trait/auto-trait-coherence.rs | 3 +- ...o_tait_defining_each_other2.current.stderr | 2 +- .../two_tait_defining_each_other2.next.stderr | 8 ++--- .../two_tait_defining_each_other2.rs | 2 +- .../trait_ref_is_knowable-norm-overflow.rs | 2 +- ...trait_ref_is_knowable-norm-overflow.stderr | 4 +-- .../trait_ref_is_knowable-normalization-3.rs | 2 +- .../generalize-proj-new-universe-index-2.rs | 4 +-- ...eneralize-proj-new-universe-index-2.stderr | 19 ----------- ...tantiate-canonical-occurs-check-failure.rs | 29 ++++++++++++++++ .../occurs-check-nested-alias.next.stderr | 9 ----- .../generalize/occurs-check-nested-alias.rs | 34 +++++++++++-------- .../issue-118950-root-region.stderr | 4 --- 16 files changed, 68 insertions(+), 68 deletions(-) delete mode 100644 tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.stderr create mode 100644 tests/ui/traits/next-solver/generalize/instantiate-canonical-occurs-check-failure.rs delete mode 100644 tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.next.stderr diff --git a/tests/ui/coherence/occurs-check/associated-type.next.stderr b/tests/ui/coherence/occurs-check/associated-type.next.stderr index 6119e6149a7..50b83b90b0b 100644 --- a/tests/ui/coherence/occurs-check/associated-type.next.stderr +++ b/tests/ui/coherence/occurs-check/associated-type.next.stderr @@ -1,11 +1,7 @@ WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } -WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } -WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } -WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } -WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } error[E0119]: conflicting implementations of trait `Overlap fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())` --> $DIR/associated-type.rs:31:1 | diff --git a/tests/ui/coherence/occurs-check/opaques.next.stderr b/tests/ui/coherence/occurs-check/opaques.next.stderr index 4ad8257d2c1..a5182eb5d9c 100644 --- a/tests/ui/coherence/occurs-check/opaques.next.stderr +++ b/tests/ui/coherence/occurs-check/opaques.next.stderr @@ -1,17 +1,17 @@ -error[E0119]: conflicting implementations of trait `Trait>` for type `Alias<_>` +error[E0119]: conflicting implementations of trait `Trait<_>` --> $DIR/opaques.rs:30:1 | LL | impl Trait for T { | ---------------------- first implementation here ... LL | impl Trait for defining_scope::Alias { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Alias<_>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error[E0282]: type annotations needed --> $DIR/opaques.rs:13:20 | LL | pub fn cast(x: Container, T>) -> Container { - | ^ cannot infer type for struct `Container, T>` + | ^ cannot infer type for struct `Container` error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/auto-trait-coherence.next.stderr b/tests/ui/impl-trait/auto-trait-coherence.next.stderr index 3f979d1a50b..cd91bfcb48d 100644 --- a/tests/ui/impl-trait/auto-trait-coherence.next.stderr +++ b/tests/ui/impl-trait/auto-trait-coherence.next.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D` +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<_>` --> $DIR/auto-trait-coherence.rs:24:1 | LL | impl AnotherTrait for T {} | -------------------------------- first implementation here ... LL | impl AnotherTrait for D { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<_>` error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/auto-trait-coherence.rs b/tests/ui/impl-trait/auto-trait-coherence.rs index 0f089c5adbd..e3036fd0fe2 100644 --- a/tests/ui/impl-trait/auto-trait-coherence.rs +++ b/tests/ui/impl-trait/auto-trait-coherence.rs @@ -22,7 +22,8 @@ impl AnotherTrait for T {} // (We treat opaque types as "foreign types" that could grow more impls // in the future.) impl AnotherTrait for D { - //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D` + //[old]~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D` + //[next]~^^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<_>` } fn main() {} diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr index 33866451c6b..c5c9ae33f4d 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr @@ -7,7 +7,7 @@ LL | type A = impl Foo; = note: `A` must be used in combination with a concrete type within the same module error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/two_tait_defining_each_other2.rs:11:5 + --> $DIR/two_tait_defining_each_other2.rs:12:5 | LL | x // B's hidden type is A (opaquely) | ^ one of the two opaque types used here has to be outside its defining scope diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr index 69328e20583..7e2b05618c4 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr @@ -1,8 +1,8 @@ -error[E0284]: type annotations needed: cannot satisfy `A == B` - --> $DIR/two_tait_defining_each_other2.rs:11:5 +error[E0284]: type annotations needed: cannot satisfy `_ == A` + --> $DIR/two_tait_defining_each_other2.rs:10:8 | -LL | x // B's hidden type is A (opaquely) - | ^ cannot satisfy `A == B` +LL | fn muh(x: A) -> B { + | ^ cannot satisfy `_ == A` error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.rs b/tests/ui/impl-trait/two_tait_defining_each_other2.rs index 229a7411951..faa1fed22d3 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.rs @@ -8,9 +8,9 @@ trait Foo {} fn muh(x: A) -> B { + //[next]~^ ERROR type annotations needed: cannot satisfy `_ == A` x // B's hidden type is A (opaquely) //[current]~^ ERROR opaque type's hidden type cannot be another opaque type - //[next]~^^ ERROR type annotations needed: cannot satisfy `A == B` } struct Bar; diff --git a/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.rs b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.rs index 66409f171e6..3238f028362 100644 --- a/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.rs +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.rs @@ -16,6 +16,6 @@ trait Trait {} impl Trait for T {} struct LocalTy; impl Trait for ::Assoc {} -//~^ ERROR conflicting implementations of trait `Trait` for type `::Assoc` +//~^ ERROR conflicting implementations of trait `Trait` fn main() {} diff --git a/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr index 583945723d5..fc145b81196 100644 --- a/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `::Assoc` +error[E0119]: conflicting implementations of trait `Trait` --> $DIR/trait_ref_is_knowable-norm-overflow.rs:18:1 | LL | impl Trait for T {} | ------------------------- first implementation here LL | struct LocalTy; LL | impl Trait for ::Assoc {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `::Assoc` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error[E0275]: overflow evaluating the requirement `::Assoc: Sized` --> $DIR/trait_ref_is_knowable-norm-overflow.rs:10:18 diff --git a/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-3.rs b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-3.rs index 98fd98ac282..70d8d74d5ea 100644 --- a/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-3.rs +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-3.rs @@ -9,7 +9,7 @@ impl Id for T { } -// Coherence should be able to reason that `(): PartialEq<::Assoc>>` +// Coherence should be able to reason that `(): PartialEq<::Assoc>>` // does not hold. // // See https://github.com/rust-lang/trait-system-refactor-initiative/issues/51 diff --git a/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.rs b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.rs index 4de5eda3a79..91793e59f1a 100644 --- a/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.rs +++ b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.rs @@ -1,8 +1,8 @@ //@ compile-flags: -Znext-solver -//@ known-bug: trait-system-refactor-initiative#60 +//@ check-pass // Generalizing a projection containing an inference variable -// which cannot be named by the `root_vid` can result in ambiguity. +// which cannot be named by the `root_vid` previously resulted in ambiguity. // // Because we do not decrement the universe index when exiting a forall, // this can cause unexpected failures. diff --git a/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.stderr b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.stderr deleted file mode 100644 index 4548ab1e297..00000000000 --- a/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0284]: type annotations needed - --> $DIR/generalize-proj-new-universe-index-2.rs:74:5 - | -LL | bound::<::Assoc, as Id>::Assoc, _>() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `V` declared on the function `bound` - | - = note: cannot satisfy `<::Assoc as WithAssoc< as Id>::Assoc>>::Assoc == _` -note: required by a bound in `bound` - --> $DIR/generalize-proj-new-universe-index-2.rs:69:21 - | -LL | fn bound() - | ----- required by a bound in this function -LL | where -LL | T: WithAssoc, - | ^^^^^^^^^ required by this bound in `bound` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/next-solver/generalize/instantiate-canonical-occurs-check-failure.rs b/tests/ui/traits/next-solver/generalize/instantiate-canonical-occurs-check-failure.rs new file mode 100644 index 00000000000..37d91fe2c7d --- /dev/null +++ b/tests/ui/traits/next-solver/generalize/instantiate-canonical-occurs-check-failure.rs @@ -0,0 +1,29 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +// With #119106 generalization now results in `AliasRelate` if the generalized +// alias contains an inference variable which is not nameable. +// +// We previously proved alias-relate after canonicalization, which does not keep track +// of universe indices, so all inference vars were nameable inside of `AliasRelate`. +// +// If we now have a rigid projection containing an unnameable inference variable, +// we should emit an alias-relate obligation, which constrains the type of `x` to +// an alias. This caused us to emit yet another equivalent alias-relate obligation +// when trying to instantiate the query result, resulting in overflow. +trait Trait<'a> { + type Assoc: Default; +} + +fn takes_alias<'a, T: Trait<'a>>(_: >::Assoc) {} + +fn foo Trait<'a>>() { + let x = Default::default(); + + let _incr_universe: for<'a, 'b> fn(&'a (), &'b ()) = + (|&(), &()| ()) as for<'a> fn(&'a (), &'a ()); + + takes_alias::(x); +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.next.stderr b/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.next.stderr deleted file mode 100644 index cde925db184..00000000000 --- a/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.next.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0284]: type annotations needed: cannot satisfy `_ == <>::Id as Unnormalizable>::Assoc` - --> $DIR/occurs-check-nested-alias.rs:36:9 - | -LL | x = y; - | ^ cannot satisfy `_ == <>::Id as Unnormalizable>::Assoc` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.rs b/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.rs index 78fbe441527..536e7e97c40 100644 --- a/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.rs +++ b/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.rs @@ -1,10 +1,8 @@ //@ revisions: old next -//@[old] check-pass - -// Currently always fails to generalize the outer alias, even if it -// is treated as rigid by `alias-relate`. //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#8 +//@ check-pass + +// case 3 of https://github.com/rust-lang/trait-system-refactor-initiative/issues/8. #![crate_type = "lib"] #![allow(unused)] trait Unnormalizable { @@ -14,8 +12,8 @@ trait Unnormalizable { trait Id { type Id; } -impl Id for U { - type Id = U; +impl Id for T { + type Id = T; } struct Inv(*mut T); @@ -24,15 +22,23 @@ fn unconstrained() -> T { todo!() } -fn create( - x: &U, -) -> (Inv, Inv<<>::Id as Unnormalizable>::Assoc>) { +fn create( + x: &T, +) -> (Inv, Inv<<>::Id as Unnormalizable>::Assoc>) { todo!() } fn foo() { - let q = unconstrained(); - let (mut x, y) = create::<_, _>(&q); - x = y; - drop::(q); + let t = unconstrained(); + let (mut u, assoc) = create::<_, _>(&t); + u = assoc; + // Instantiating `?u` with `<>::Id as Unnormalizable>::Assoc` would + // result in a cyclic type. However, we can still unify these types by first + // normalizing the inner associated type. Emitting an error here would be incomplete. + drop::(t); + + // FIXME(-Znext-solver): This line is necessary due to an unrelated solver bug + // and should get removed in the future. + // https://github.com/rust-lang/trait-system-refactor-initiative/issues/96 + drop::::Assoc>>(u); } diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.stderr b/tests/ui/traits/next-solver/issue-118950-root-region.stderr index e33320ed9e6..931c46c6887 100644 --- a/tests/ui/traits/next-solver/issue-118950-root-region.stderr +++ b/tests/ui/traits/next-solver/issue-118950-root-region.stderr @@ -14,13 +14,9 @@ LL | #![feature(lazy_type_alias)] = note: `#[warn(incomplete_features)]` on by default WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } -WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } -WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } -WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } -WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } error[E0119]: conflicting implementations of trait `Overlap` for type `fn(_)` --> $DIR/issue-118950-root-region.rs:19:1 |