Skip to content

Make well-formedness predicates no longer coinductive #140208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
self.infcx.tcx.trait_is_coinductive(data.def_id())
}
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => true,
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => {
// FIXME(generic_const_exprs): GCE needs well-formedness predicates to be
// coinductive, but GCE is on the way out anyways, so this should eventually
// be replaced with `false`.
self.infcx.tcx.features().generic_const_exprs()
}
_ => false,
})
}
Expand Down
16 changes: 0 additions & 16 deletions tests/crashes/123456.rs

This file was deleted.

5 changes: 4 additions & 1 deletion tests/ui/associated-types/issue-64855-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//@ check-pass
// This was originally a test for a `ReEmpty` ICE, but became an unintentional test of
// the coinductiveness of WF predicates. That behavior was removed, and thus this is
// also inadvertently a test for the (non-)co-inductiveness of WF predicates.

pub struct Bar<'a>(&'a Self) where Self: ;
//~^ ERROR overflow evaluating the requirement `Bar<'a> well-formed`

fn main() {}
15 changes: 15 additions & 0 deletions tests/ui/associated-types/issue-64855-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0275]: overflow evaluating the requirement `Bar<'a> well-formed`
--> $DIR/issue-64855-2.rs:5:36
|
LL | pub struct Bar<'a>(&'a Self) where Self: ;
| ^^^^
|
note: required by a bound in `Bar`
--> $DIR/issue-64855-2.rs:5:36
|
LL | pub struct Bar<'a>(&'a Self) where Self: ;
| ^^^^ required by this bound in `Bar`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0275`.
5 changes: 5 additions & 0 deletions tests/ui/associated-types/issue-64855.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// This was originally a test for a `ReEmpty` ICE, but became an unintentional test of
// the coinductiveness of WF predicates. That behavior was removed, and thus this is
// also inadvertently a test for the (non-)co-inductiveness of WF predicates.

pub trait Foo {
type Type;
}

pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
//~^ ERROR the trait bound `Bar<T>: Foo` is not satisfied
//~| ERROR overflow evaluating the requirement `Bar<T> well-formed`

fn main() {}
21 changes: 17 additions & 4 deletions tests/ui/associated-types/issue-64855.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied
--> $DIR/issue-64855.rs:5:19
--> $DIR/issue-64855.rs:9:19
|
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
| ^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bar<T>`
|
help: this trait has no implementations, consider adding one
--> $DIR/issue-64855.rs:1:1
--> $DIR/issue-64855.rs:5:1
|
LL | pub trait Foo {
| ^^^^^^^^^^^^^

error: aborting due to 1 previous error
error[E0275]: overflow evaluating the requirement `Bar<T> well-formed`
--> $DIR/issue-64855.rs:9:46
|
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
| ^^^^
|
note: required by a bound in `Bar`
--> $DIR/issue-64855.rs:9:46
|
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
| ^^^^ required by this bound in `Bar`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
Some errors have detailed explanations: E0275, E0277.
For more information about an error, try `rustc --explain E0275`.
9 changes: 4 additions & 5 deletions tests/ui/higher-ranked/trait-bounds/issue-95230.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
//@ revisions: old next
//@[next] compile-flags: -Znext-solver
//@[old] check-pass
//@[next] known-bug: #109764

// This used to be a test for overflow handling + higher-ranked outlives
// in the new solver, but this test isn't expected to pass since WF preds
// are not coinductive anymore.

pub struct Bar
where
for<'a> &'a mut Self:;
//~^ ERROR overflow evaluating the requirement `for<'a> &'a mut Bar well-formed`

fn main() {}
18 changes: 18 additions & 0 deletions tests/ui/higher-ranked/trait-bounds/issue-95230.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0275]: overflow evaluating the requirement `for<'a> &'a mut Bar well-formed`
--> $DIR/issue-95230.rs:7:13
|
LL | for<'a> &'a mut Self:;
| ^^^^^^^^^^^^
|
note: required by a bound in `Bar`
--> $DIR/issue-95230.rs:7:13
|
LL | pub struct Bar
| --- required by a bound in this struct
LL | where
LL | for<'a> &'a mut Self:;
| ^^^^^^^^^^^^ required by this bound in `Bar`

error: aborting due to 1 previous error

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