Skip to content

Commit 8c14588

Browse files
authored
Rollup merge of #140208 - compiler-errors:wf-coinductive, r=lcnr
Make well-formedness predicates no longer coinductive This PR makes well-formedness no longer coinductive. It was made coinductive in #98542, but AFAICT this was only to fix UI tests since we stopped lowering `where Ty:` to an empty-region outlives predicate but to a WF predicate instead. Arguably it should lower to something completely different, something like a "type mentioned no-op predicate", but well-formedness serves this purpose fine today, and since no code (according to crater) relies on this coinductive behavior, we'd like to avoid having to emulate it in the new solver. Fixes #123456 (I didn't want to add a test since it seems low-value to have a ICE test for a fuzzer minimization that is basically garbage code.) Fixes #109764 (not sure if this behavior is emulatable w/o coinductive WF?) Fixes rust-lang/trait-system-refactor-initiative#169 r? lcnr
2 parents a69bc17 + 38c05a6 commit 8c14588

File tree

8 files changed

+69
-27
lines changed

8 files changed

+69
-27
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12411241
ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
12421242
self.infcx.tcx.trait_is_coinductive(data.def_id())
12431243
}
1244-
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => true,
1244+
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => {
1245+
// FIXME(generic_const_exprs): GCE needs well-formedness predicates to be
1246+
// coinductive, but GCE is on the way out anyways, so this should eventually
1247+
// be replaced with `false`.
1248+
self.infcx.tcx.features().generic_const_exprs()
1249+
}
12451250
_ => false,
12461251
})
12471252
}

tests/crashes/123456.rs

-16
This file was deleted.
+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
//@ check-pass
1+
// This was originally a test for a `ReEmpty` ICE, but became an unintentional test of
2+
// the coinductiveness of WF predicates. That behavior was removed, and thus this is
3+
// also inadvertently a test for the (non-)co-inductiveness of WF predicates.
24

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

58
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0275]: overflow evaluating the requirement `Bar<'a> well-formed`
2+
--> $DIR/issue-64855-2.rs:5:36
3+
|
4+
LL | pub struct Bar<'a>(&'a Self) where Self: ;
5+
| ^^^^
6+
|
7+
note: required by a bound in `Bar`
8+
--> $DIR/issue-64855-2.rs:5:36
9+
|
10+
LL | pub struct Bar<'a>(&'a Self) where Self: ;
11+
| ^^^^ required by this bound in `Bar`
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0275`.
+5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
// This was originally a test for a `ReEmpty` ICE, but became an unintentional test of
2+
// the coinductiveness of WF predicates. That behavior was removed, and thus this is
3+
// also inadvertently a test for the (non-)co-inductiveness of WF predicates.
4+
15
pub trait Foo {
26
type Type;
37
}
48

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

813
fn main() {}
+17-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied
2-
--> $DIR/issue-64855.rs:5:19
2+
--> $DIR/issue-64855.rs:9:19
33
|
44
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
55
| ^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bar<T>`
66
|
77
help: this trait has no implementations, consider adding one
8-
--> $DIR/issue-64855.rs:1:1
8+
--> $DIR/issue-64855.rs:5:1
99
|
1010
LL | pub trait Foo {
1111
| ^^^^^^^^^^^^^
1212

13-
error: aborting due to 1 previous error
13+
error[E0275]: overflow evaluating the requirement `Bar<T> well-formed`
14+
--> $DIR/issue-64855.rs:9:46
15+
|
16+
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
17+
| ^^^^
18+
|
19+
note: required by a bound in `Bar`
20+
--> $DIR/issue-64855.rs:9:46
21+
|
22+
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
23+
| ^^^^ required by this bound in `Bar`
24+
25+
error: aborting due to 2 previous errors
1426

15-
For more information about this error, try `rustc --explain E0277`.
27+
Some errors have detailed explanations: E0275, E0277.
28+
For more information about an error, try `rustc --explain E0275`.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
//@ revisions: old next
2-
//@[next] compile-flags: -Znext-solver
3-
//@[old] check-pass
4-
//@[next] known-bug: #109764
5-
1+
// This used to be a test for overflow handling + higher-ranked outlives
2+
// in the new solver, but this test isn't expected to pass since WF preds
3+
// are not coinductive anymore.
64

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

1110
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0275]: overflow evaluating the requirement `for<'a> &'a mut Bar well-formed`
2+
--> $DIR/issue-95230.rs:7:13
3+
|
4+
LL | for<'a> &'a mut Self:;
5+
| ^^^^^^^^^^^^
6+
|
7+
note: required by a bound in `Bar`
8+
--> $DIR/issue-95230.rs:7:13
9+
|
10+
LL | pub struct Bar
11+
| --- required by a bound in this struct
12+
LL | where
13+
LL | for<'a> &'a mut Self:;
14+
| ^^^^^^^^^^^^ required by this bound in `Bar`
15+
16+
error: aborting due to 1 previous error
17+
18+
For more information about this error, try `rustc --explain E0275`.

0 commit comments

Comments
 (0)