Rollup merge of #137314 - lcnr:cycles-with-unknown-kind, r=compiler-errors
change definitely unproductive cycles to error builds on top of #136824 by adding a third variant to `PathKind` for paths which may change to be coinductive in the future but must not be so right now. Most notably, impl where-clauses of not yet coinductive traits. With this, we can change cycles which are definitely unproductive to a proper error. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/114. This does not affect stable as we keep these cycles as ambiguous during coherence. r? ````````@compiler-errors```````` ````````@nikomatsakis````````
This commit is contained in:
commit
d55e2e4333
21 changed files with 287 additions and 207 deletions
|
@ -1,4 +1,7 @@
|
|||
//@ check-pass
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
|
||||
trait A<'a> {}
|
||||
trait B<'b> {}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
//@ check-pass
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
|
||||
// Make sure that we don't look into associated type bounds when looking for
|
||||
// supertraits that define an associated type. Fixes #76593.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0275]: overflow evaluating the requirement `Loop == _`
|
||||
error[E0271]: type mismatch resolving `Loop normalizes-to _`
|
||||
--> $DIR/inherent-impls-overflow.rs:10:6
|
||||
|
|
||||
LL | impl Loop {}
|
||||
| ^^^^
|
||||
| ^^^^ types differ
|
||||
|
||||
error: type parameter `T` is only used recursively
|
||||
--> $DIR/inherent-impls-overflow.rs:14:24
|
||||
|
@ -36,4 +36,5 @@ LL | impl Poly0<()> {}
|
|||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0275`.
|
||||
Some errors have detailed explanations: E0271, E0275.
|
||||
For more information about an error, try `rustc --explain E0271`.
|
||||
|
|
|
@ -9,7 +9,7 @@ type Loop = Loop; //[current]~ ERROR overflow normalizing the type alias `Loop`
|
|||
|
||||
impl Loop {}
|
||||
//[current]~^ ERROR overflow normalizing the type alias `Loop`
|
||||
//[next]~^^ ERROR overflow evaluating the requirement `Loop == _`
|
||||
//[next]~^^ ERROR type mismatch resolving `Loop normalizes-to _`
|
||||
|
||||
type Poly0<T> = Poly1<(T,)>;
|
||||
//[current]~^ ERROR overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>`
|
||||
|
|
|
@ -6,9 +6,11 @@
|
|||
trait Overflow {
|
||||
type Assoc;
|
||||
}
|
||||
impl<T> Overflow for T {
|
||||
type Assoc = <T as Overflow>::Assoc;
|
||||
//~^ ERROR: overflow
|
||||
impl<T> Overflow for T
|
||||
where
|
||||
(T,): Overflow
|
||||
{
|
||||
type Assoc = <(T,) as Overflow>::Assoc;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
error[E0275]: overflow evaluating the requirement `<T as Overflow>::Assoc == _`
|
||||
--> $DIR/trait_ref_is_knowable-norm-overflow.rs:10:18
|
||||
|
|
||||
LL | type Assoc = <T as Overflow>::Assoc;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Trait`
|
||||
--> $DIR/trait_ref_is_knowable-norm-overflow.rs:18:1
|
||||
--> $DIR/trait_ref_is_knowable-norm-overflow.rs:20:1
|
||||
|
|
||||
LL | impl<T: Copy> Trait for T {}
|
||||
| ------------------------- first implementation here
|
||||
LL | struct LocalTy;
|
||||
LL | impl Trait for <LocalTy as Overflow>::Assoc {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
|
||||
|
|
||||
= note: overflow evaluating the requirement `_ == <LocalTy as Overflow>::Assoc`
|
||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`trait_ref_is_knowable_norm_overflow`)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Some errors have detailed explanations: E0119, E0275.
|
||||
For more information about an error, try `rustc --explain E0119`.
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// Regression test for trait-system-refactor-initiative#114.
|
||||
//
|
||||
// We previously treated the cycle when trying to use the
|
||||
// `<R as DimMin<C>>::Output: DimMin` where-bound when
|
||||
// normalizing `<R as DimMin<C>>::Output` as ambiguous, causing
|
||||
// this to error.
|
||||
|
||||
//@ check-pass
|
||||
//@ compile-flags: -Znext-solver
|
||||
//@ ignore-compare-mode-next-solver
|
||||
|
||||
pub trait DimMin<D> {
|
||||
type Output;
|
||||
}
|
||||
pub fn repro<R: DimMin<C>, C>()
|
||||
where
|
||||
<R as DimMin<C>>::Output: DimMin<C, Output = <R as DimMin<C>>::Output>,
|
||||
{
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,21 @@
|
|||
// If we treat known inductive cycles as errors, this test compiles
|
||||
// as normalizing `Overflow::Assoc<Overflow>` fails.
|
||||
//
|
||||
// As coherence already uses the new solver on stable, this change
|
||||
// would require an FCP.
|
||||
|
||||
trait Trait {
|
||||
type Assoc<T: Trait>;
|
||||
}
|
||||
|
||||
struct Overflow;
|
||||
impl Trait for Overflow {
|
||||
type Assoc<T: Trait> = <T as Trait>::Assoc<Overflow>;
|
||||
}
|
||||
|
||||
trait Overlap<T, WfHack> {}
|
||||
impl<T: Trait, U: Copy> Overlap<T::Assoc<T>, U> for T {}
|
||||
impl<U> Overlap<u32, U> for Overflow {}
|
||||
//~^ ERROR conflicting implementations of trait `Overlap<<Overflow as Trait>::Assoc<Overflow>, _>` for type `Overflow`
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,11 @@
|
|||
error[E0119]: conflicting implementations of trait `Overlap<<Overflow as Trait>::Assoc<Overflow>, _>` for type `Overflow`
|
||||
--> $DIR/unproductive-in-coherence.rs:18:1
|
||||
|
|
||||
LL | impl<T: Trait, U: Copy> Overlap<T::Assoc<T>, U> for T {}
|
||||
| ----------------------------------------------------- first implementation here
|
||||
LL | impl<U> Overlap<u32, U> for Overflow {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Overflow`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
|
@ -13,12 +13,7 @@ fn needs_bar<S: Bar>() {}
|
|||
|
||||
fn test<T: Foo1<Assoc1 = <T as Foo2>::Assoc2> + Foo2<Assoc2 = <T as Foo1>::Assoc1>>() {
|
||||
needs_bar::<T::Assoc1>();
|
||||
//~^ ERROR overflow evaluating the requirement `<T as Foo1>::Assoc1 == _`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo1>::Assoc1 == _`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo1>::Assoc1 == _`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo1>::Assoc1 == _`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo1>::Assoc1: Sized`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar`
|
||||
//~^ ERROR the trait bound `<T as Foo1>::Assoc1: Bar` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,59 +1,19 @@
|
|||
error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1 == _`
|
||||
error[E0277]: the trait bound `<T as Foo1>::Assoc1: Bar` is not satisfied
|
||||
--> $DIR/recursive-self-normalization-2.rs:15:17
|
||||
|
|
||||
LL | needs_bar::<T::Assoc1>();
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar`
|
||||
--> $DIR/recursive-self-normalization-2.rs:15:17
|
||||
|
|
||||
LL | needs_bar::<T::Assoc1>();
|
||||
| ^^^^^^^^^
|
||||
| ^^^^^^^^^ the trait `Bar` is not implemented for `<T as Foo1>::Assoc1`
|
||||
|
|
||||
note: required by a bound in `needs_bar`
|
||||
--> $DIR/recursive-self-normalization-2.rs:12:17
|
||||
|
|
||||
LL | fn needs_bar<S: Bar>() {}
|
||||
| ^^^ required by this bound in `needs_bar`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn test<T: Foo1<Assoc1 = <T as Foo2>::Assoc2> + Foo2<Assoc2 = <T as Foo1>::Assoc1>>() where <T as Foo1>::Assoc1: Bar {
|
||||
| ++++++++++++++++++++++++++++++
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1: Sized`
|
||||
--> $DIR/recursive-self-normalization-2.rs:15:17
|
||||
|
|
||||
LL | needs_bar::<T::Assoc1>();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: required by an implicit `Sized` bound in `needs_bar`
|
||||
--> $DIR/recursive-self-normalization-2.rs:12:14
|
||||
|
|
||||
LL | fn needs_bar<S: Bar>() {}
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `needs_bar`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn needs_bar<S: Bar + ?Sized>() {}
|
||||
| ++++++++
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1 == _`
|
||||
--> $DIR/recursive-self-normalization-2.rs:15:5
|
||||
|
|
||||
LL | needs_bar::<T::Assoc1>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1 == _`
|
||||
--> $DIR/recursive-self-normalization-2.rs:15:5
|
||||
|
|
||||
LL | needs_bar::<T::Assoc1>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1 == _`
|
||||
--> $DIR/recursive-self-normalization-2.rs:15:17
|
||||
|
|
||||
LL | needs_bar::<T::Assoc1>();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0275`.
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -9,12 +9,7 @@ fn needs_bar<S: Bar>() {}
|
|||
|
||||
fn test<T: Foo<Assoc = <T as Foo>::Assoc>>() {
|
||||
needs_bar::<T::Assoc>();
|
||||
//~^ ERROR overflow evaluating the requirement `<T as Foo>::Assoc == _`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo>::Assoc == _`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo>::Assoc == _`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo>::Assoc == _`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo>::Assoc: Sized`
|
||||
//~| ERROR overflow evaluating the requirement `<T as Foo>::Assoc: Bar`
|
||||
//~^ ERROR the trait bound `<T as Foo>::Assoc: Bar` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,59 +1,19 @@
|
|||
error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc == _`
|
||||
error[E0277]: the trait bound `<T as Foo>::Assoc: Bar` is not satisfied
|
||||
--> $DIR/recursive-self-normalization.rs:11:17
|
||||
|
|
||||
LL | needs_bar::<T::Assoc>();
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc: Bar`
|
||||
--> $DIR/recursive-self-normalization.rs:11:17
|
||||
|
|
||||
LL | needs_bar::<T::Assoc>();
|
||||
| ^^^^^^^^
|
||||
| ^^^^^^^^ the trait `Bar` is not implemented for `<T as Foo>::Assoc`
|
||||
|
|
||||
note: required by a bound in `needs_bar`
|
||||
--> $DIR/recursive-self-normalization.rs:8:17
|
||||
|
|
||||
LL | fn needs_bar<S: Bar>() {}
|
||||
| ^^^ required by this bound in `needs_bar`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn test<T: Foo<Assoc = <T as Foo>::Assoc>>() where <T as Foo>::Assoc: Bar {
|
||||
| ++++++++++++++++++++++++++++
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc: Sized`
|
||||
--> $DIR/recursive-self-normalization.rs:11:17
|
||||
|
|
||||
LL | needs_bar::<T::Assoc>();
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: required by an implicit `Sized` bound in `needs_bar`
|
||||
--> $DIR/recursive-self-normalization.rs:8:14
|
||||
|
|
||||
LL | fn needs_bar<S: Bar>() {}
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `needs_bar`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn needs_bar<S: Bar + ?Sized>() {}
|
||||
| ++++++++
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc == _`
|
||||
--> $DIR/recursive-self-normalization.rs:11:5
|
||||
|
|
||||
LL | needs_bar::<T::Assoc>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc == _`
|
||||
--> $DIR/recursive-self-normalization.rs:11:5
|
||||
|
|
||||
LL | needs_bar::<T::Assoc>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc == _`
|
||||
--> $DIR/recursive-self-normalization.rs:11:17
|
||||
|
|
||||
LL | needs_bar::<T::Assoc>();
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0275`.
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue