Skip to content

Commit 1bc802e

Browse files
committed
Auto merge of rust-lang#97642 - oli-obk:backport_undo_closure_wf_check, r=compiler-errors
Revert "Check that closures satisfy their where bounds" This reverts commit 253408b from rust-lang#96899 This is only performed on beta to give us another few weeks to fix rust-lang#97607 on nightly. The planned fix is likely way too large to backport anyway. r? `@compiler-errors`
2 parents 8fd9e5f + a0bf36c commit 1bc802e

File tree

10 files changed

+25
-82
lines changed

10 files changed

+25
-82
lines changed

compiler/rustc_trait_selection/src/traits/wf.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
575575
// generators don't take arguments.
576576
}
577577

578-
ty::Closure(did, substs) => {
578+
ty::Closure(_, substs) => {
579579
// Only check the upvar types for WF, not the rest
580580
// of the types within. This is needed because we
581581
// capture the signature and it may not be WF
@@ -614,8 +614,10 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
614614
// can cause compiler crashes when the user abuses unsafe
615615
// code to procure such a closure.
616616
// See src/test/ui/type-alias-impl-trait/wf_check_closures.rs
617-
let obligations = self.nominal_obligations(did, substs);
618-
self.out.extend(obligations);
617+
// We should be checking the nominal_obligations here, but that caused
618+
// a regression in https://github.com/rust-lang/rust/issues/97607
619+
// The regression will be fixed on nightly, but the fix is too large
620+
// to be backported.
619621
}
620622

621623
ty::FnPtr(_) => {
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(generic_const_exprs)]
22
#![allow(incomplete_features)]
33
fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
4-
//~^ ERROR cycle detected when building an abstract representation
4+
//~^ ERROR overly complex generic constant
55

66
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1-
error[E0391]: cycle detected when building an abstract representation for test::{constant#0}
1+
error: overly complex generic constant
22
--> $DIR/closures.rs:3:35
33
|
44
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
5-
| ^^^^^^^^^^^^^
5+
| ^^^^-------^^
6+
| |
7+
| borrowing is not supported in generic constants
68
|
7-
note: ...which requires building THIR for `test::{constant#0}`...
8-
--> $DIR/closures.rs:3:35
9-
|
10-
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
11-
| ^^^^^^^^^^^^^
12-
note: ...which requires type-checking `test::{constant#0}`...
13-
--> $DIR/closures.rs:3:35
14-
|
15-
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
16-
| ^^^^^^^^^^^^^
17-
= note: ...which again requires building an abstract representation for test::{constant#0}, completing the cycle
18-
note: cycle used when checking that `test` is well-formed
19-
--> $DIR/closures.rs:3:1
20-
|
21-
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
22-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+
= help: consider moving this anonymous constant into a `const` function
10+
= note: this operation may be supported in the future
2311

2412
error: aborting due to previous error
2513

26-
For more information about this error, try `rustc --explain E0391`.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
error: higher-ranked lifetime error
2-
--> $DIR/issue-59311.rs:17:5
3-
|
4-
LL | v.t(|| {});
5-
| ^^^^^^^^^^
6-
|
7-
= note: could not prove [closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed
8-
91
error: higher-ranked lifetime error
102
--> $DIR/issue-59311.rs:17:9
113
|
@@ -14,5 +6,5 @@ LL | v.t(|| {});
146
|
157
= note: could not prove for<'a> &'a V: 'static
168

17-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
1810

src/test/ui/higher-rank-trait-bounds/issue-59311.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn crash<V>(v: &V)
1414
where
1515
for<'a> &'a V: T + 'static,
1616
{
17-
v.t(|| {}); //~ ERROR: `&'a V` does not fulfill the required lifetime
17+
v.t(|| {}); //~ ERROR: higher-ranked lifetime error
1818
}
1919

2020
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
error[E0477]: the type `&'a V` does not fulfill the required lifetime
2-
--> $DIR/issue-59311.rs:17:5
1+
error: higher-ranked lifetime error
2+
--> $DIR/issue-59311.rs:17:9
33
|
44
LL | v.t(|| {});
5-
| ^^^^^^^^^^
5+
| ^^^^^
66
|
7-
note: type must satisfy the static lifetime as required by this binding
8-
--> $DIR/issue-59311.rs:15:24
9-
|
10-
LL | for<'a> &'a V: T + 'static,
11-
| ^^^^^^^
7+
= note: could not prove for<'a> &'a V: 'static
128

139
error: aborting due to previous error
1410

15-
For more information about this error, try `rustc --explain E0477`.

src/test/ui/type-alias-impl-trait/issue-53092.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#![feature(type_alias_impl_trait)]
22
#![allow(dead_code)]
33

4+
// check-pass
5+
// known-bug #53092 #90409
6+
47
type Bug<T, U> = impl Fn(T) -> U + Copy;
58

69
const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
710

811
fn make_bug<T, U: From<T>>() -> Bug<T, U> {
9-
|x| x.into() //~ ERROR the trait bound `U: From<T>` is not satisfied
12+
|x| x.into()
1013
}
1114

1215
fn main() {

src/test/ui/type-alias-impl-trait/issue-53092.stderr

-19
This file was deleted.

src/test/ui/type-alias-impl-trait/wf_check_closures.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#![feature(type_alias_impl_trait)]
22

3+
// check-pass
4+
// known-bug #53092 #90409
5+
36
trait Bar {
47
fn bar(&self);
58
}
@@ -8,7 +11,6 @@ type FooFn<B> = impl FnOnce();
811

912
fn foo<B: Bar>(bar: B) -> FooFn<B> {
1013
move || { bar.bar() }
11-
//~^ ERROR the trait bound `B: Bar` is not satisfied
1214
}
1315

1416
fn main() {

src/test/ui/type-alias-impl-trait/wf_check_closures.stderr

-19
This file was deleted.

0 commit comments

Comments
 (0)