Skip to content

Commit

Permalink
Auto merge of rust-lang#116494 - compiler-errors:typeck-coinductive-a…
Browse files Browse the repository at this point in the history
…mbig, r=<try>

[crater only] Always make inductive cycles as ambig during typeck

r? `@ghost`
  • Loading branch information
bors committed Oct 6, 2023
2 parents 31be8cc + 1007c9c commit 919137c
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 135 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
freshener: infcx.freshener(),
intercrate_ambiguity_causes: None,
query_mode: TraitQueryMode::Standard,
treat_inductive_cycle: TreatInductiveCycleAs::Recur,
treat_inductive_cycle: TreatInductiveCycleAs::Ambig,
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
error[E0277]: `<Self as Case1>::C` is not an iterator
--> $DIR/bad-bounds-on-assoc-in-trait.rs:26:21
|
LL | type C: Clone + Iterator<Item: Send + Iterator<Item: for<'a> Lam<&'a u8, App: Debug>> + Sync>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `<Self as Case1>::C` is not an iterator
|
= help: the trait `Iterator` is not implemented for `<Self as Case1>::C`
help: consider further restricting the associated type
|
LL | trait Case1 where <Self as Case1>::C: Iterator {
| ++++++++++++++++++++++++++++++++++

error[E0277]: `<<Self as Case1>::C as Iterator>::Item` cannot be sent between threads safely
--> $DIR/bad-bounds-on-assoc-in-trait.rs:26:36
|
Expand Down Expand Up @@ -34,6 +46,6 @@ help: consider further restricting the associated type
LL | trait Case1 where <<Self as Case1>::C as Iterator>::Item: Sync {
| ++++++++++++++++++++++++++++++++++++++++++++++++++

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0277`.
37 changes: 12 additions & 25 deletions tests/ui/impl-trait/in-trait/specialization-broken.stderr
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/specialization-broken.rs:16:22
error[E0391]: cycle detected when computing whether impls specialize one another
--> $DIR/specialization-broken.rs:12:1
|
LL | default impl<U> Foo for U
| - this type parameter
...
LL | fn bar(&self) -> U {
| ^
| |
| expected associated type, found type parameter `U`
| help: change the output type to match the trait: `impl Sized`
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: type in trait
--> $DIR/specialization-broken.rs:9:22
= note: ...which requires evaluating trait selection obligation `i32: Foo`...
= note: ...which again requires computing whether impls specialize one another, completing the cycle
note: cycle used when building specialization graph of trait `Foo`
--> $DIR/specialization-broken.rs:8:1
|
LL | fn bar(&self) -> impl Sized;
| ^^^^^^^^^^
= note: expected signature `fn(&U) -> impl Sized`
found signature `fn(&U) -> U`
LL | trait Foo {
| ^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: method with return-position `impl Trait` in trait cannot be specialized
--> $DIR/specialization-broken.rs:16:5
|
LL | fn bar(&self) -> U {
| ^^^^^^^^^^^^^^^^^^
|
= note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed

error: aborting due to 2 previous errors
error: aborting due to previous error

For more information about this error, try `rustc --explain E0053`.
For more information about this error, try `rustc --explain E0391`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,20 @@ LL | #![feature(specialization)]
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default

error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
--> $DIR/specialization-no-default.rs:20:5
error[E0391]: cycle detected when computing whether impls specialize one another
--> $DIR/specialization-no-default.rs:46:1
|
LL | impl<T> Foo for T {
| ----------------- parent `impl` is here
...
LL | fn foo(&self) {}
| ^^^^^^^^^^^^^ cannot specialize default item `foo`
LL | default impl<T> Baz for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: to specialize, `foo` in the parent `impl` must be marked `default`

error[E0520]: `bar` specializes an item from a parent `impl`, but that item is not marked `default`
--> $DIR/specialization-no-default.rs:23:5
|
LL | impl<T> Foo for T {
| ----------------- parent `impl` is here
...
LL | fn bar(&self) {}
| ^^^^^^^^^^^^^ cannot specialize default item `bar`
|
= note: to specialize, `bar` in the parent `impl` must be marked `default`

error[E0520]: `T` specializes an item from a parent `impl`, but that item is not marked `default`
--> $DIR/specialization-no-default.rs:37:5
|
LL | impl<T> Bar for T {
| ----------------- parent `impl` is here
...
LL | type T = ();
| ^^^^^^ cannot specialize default item `T`
|
= note: to specialize, `T` in the parent `impl` must be marked `default`

error[E0520]: `baz` specializes an item from a parent `impl`, but that item is not marked `default`
--> $DIR/specialization-no-default.rs:55:5
|
LL | impl<T: Clone> Baz for T {
| ------------------------ parent `impl` is here
...
LL | fn baz(&self) {}
| ^^^^^^^^^^^^^ cannot specialize default item `baz`
|
= note: to specialize, `baz` in the parent `impl` must be marked `default`

error[E0520]: `redundant` specializes an item from a parent `impl`, but that item is not marked `default`
--> $DIR/specialization-no-default.rs:74:5
|
LL | impl<T: Clone> Redundant for T {
| ------------------------------ parent `impl` is here
...
LL | fn redundant(&self) {}
| ^^^^^^^^^^^^^^^^^^^ cannot specialize default item `redundant`
= note: ...which immediately requires computing whether impls specialize one another again
note: cycle used when building specialization graph of trait `Baz`
--> $DIR/specialization-no-default.rs:42:1
|
= note: to specialize, `redundant` in the parent `impl` must be marked `default`
LL | trait Baz {
| ^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to 5 previous errors; 1 warning emitted
error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0520`.
For more information about this error, try `rustc --explain E0391`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ LL | #![feature(specialization)]
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default

error[E0046]: not all trait items implemented, missing: `foo_two`
--> $DIR/specialization-trait-item-not-implemented.rs:18:1
error[E0391]: cycle detected when computing whether impls specialize one another
--> $DIR/specialization-trait-item-not-implemented.rs:12:1
|
LL | fn foo_two(&self) -> &'static str;
| ---------------------------------- `foo_two` from trait
...
LL | impl Foo for MyStruct {}
| ^^^^^^^^^^^^^^^^^^^^^ missing `foo_two` in implementation
LL | default impl<T> Foo for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: ...which requires evaluating trait selection obligation `MyStruct: Foo`...
= note: ...which again requires computing whether impls specialize one another, completing the cycle
note: cycle used when building specialization graph of trait `Foo`
--> $DIR/specialization-trait-item-not-implemented.rs:5:1
|
LL | trait Foo {
| ^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0046`.
For more information about this error, try `rustc --explain E0391`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,12 @@ LL | #![feature(specialization)]
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default

error[E0599]: the method `foo_one` exists for struct `MyStruct`, but its trait bounds were not satisfied
error[E0275]: overflow evaluating the requirement `MyStruct: Foo`
--> $DIR/specialization-trait-not-implemented.rs:22:29
|
LL | struct MyStruct;
| ---------------
| |
| method `foo_one` not found for this struct
| doesn't satisfy `MyStruct: Foo`
...
LL | println!("{}", MyStruct.foo_one());
| ^^^^^^^ method cannot be called on `MyStruct` due to unsatisfied trait bounds
|
note: trait bound `MyStruct: Foo` was not satisfied
--> $DIR/specialization-trait-not-implemented.rs:14:1
|
LL | default impl<T> Foo for T {
| ^^^^^^^^^^^^^^^^---^^^^^-
| |
| unsatisfied trait bound introduced here
note: the trait `Foo` must be implemented
--> $DIR/specialization-trait-not-implemented.rs:7:1
|
LL | trait Foo {
| ^^^^^^^^^
= help: items from traits can only be used if the trait is implemented and in scope
note: `Foo` defines an item `foo_one`, perhaps you need to implement it
--> $DIR/specialization-trait-not-implemented.rs:7:1
|
LL | trait Foo {
| ^^^^^^^^^
| ^^^^^^^

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0599`.
For more information about this error, try `rustc --explain E0275`.
31 changes: 12 additions & 19 deletions tests/ui/specialization/issue-39448.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,21 @@ LL | #![feature(specialization)]
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default

error[E0275]: overflow evaluating the requirement `T: FromA<U>`
--> $DIR/issue-39448.rs:45:13
|
LL | x.foo(y.to()).to()
| ^^
|
note: required for `T` to implement `FromA<U>`
--> $DIR/issue-39448.rs:24:29
error[E0391]: cycle detected when computing whether impls specialize one another
--> $DIR/issue-39448.rs:24:1
|
LL | impl<T: A, U: A + FromA<T>> FromA<T> for U {
| -------- ^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
note: required for `U` to implement `ToA<T>`
--> $DIR/issue-39448.rs:34:12
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: ...which requires evaluating trait selection obligation `u16: FromA<u8>`...
= note: ...which again requires computing whether impls specialize one another, completing the cycle
note: cycle used when building specialization graph of trait `FromA`
--> $DIR/issue-39448.rs:20:1
|
LL | impl<T, U> ToA<U> for T
| ^^^^^^ ^
LL | where
LL | U: FromA<T>,
| -------- unsatisfied trait bound introduced here
LL | trait FromA<T> {
| ^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0275`.
For more information about this error, try `rustc --explain E0391`.

0 comments on commit 919137c

Please sign in to comment.