Skip to content

Commit 16bb429

Browse files
committed
Add minimal coroutine binder regressions
1 parent e04a3e1 commit 16bb429

14 files changed

Lines changed: 118 additions & 17 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@ compile-flags: -Zassumptions-on-binders=min_coroutines
2+
3+
use std::marker::PhantomData;
4+
5+
struct WellFormed<'a, T: 'a>(PhantomData<&'a T>);
6+
7+
trait Trait {}
8+
9+
impl<'a, 'b> Trait for WellFormed<'a, &'b ()>
10+
where
11+
&'b (): 'a,
12+
{
13+
}
14+
15+
fn require()
16+
where
17+
for<'a, 'b> WellFormed<'a, &'b ()>: Trait,
18+
{
19+
}
20+
21+
fn check() {
22+
require();
23+
//~^ ERROR type annotations needed: cannot satisfy
24+
}
25+
26+
fn main() {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0283]: type annotations needed: cannot satisfy `for<'a, 'b> WellFormed<'a, &'b ()>: Trait`
2+
--> $DIR/min-coroutines-only-witness-binders.rs:22:5
3+
|
4+
LL | require();
5+
| ^^^^^^^^^
6+
|
7+
= note: cannot satisfy `for<'a, 'b> WellFormed<'a, &'b ()>: Trait`
8+
help: the trait `Trait` is not implemented for `WellFormed<'a, &'b ()>`
9+
but it is implemented for `WellFormed<'_, &()>`
10+
--> $DIR/min-coroutines-only-witness-binders.rs:9:1
11+
|
12+
LL | / impl<'a, 'b> Trait for WellFormed<'a, &'b ()>
13+
LL | | where
14+
LL | | &'b (): 'a,
15+
| |_______________^
16+
note: required by a bound in `require`
17+
--> $DIR/min-coroutines-only-witness-binders.rs:17:41
18+
|
19+
LL | fn require()
20+
| ------- required by a bound in this function
21+
LL | where
22+
LL | for<'a, 'b> WellFormed<'a, &'b ()>: Trait,
23+
| ^^^^^ required by this bound in `require`
24+
25+
error: aborting due to 1 previous error
26+
27+
For more information about this error, try `rustc --explain E0283`.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ compile-flags: -Zassumptions-on-binders=min_coroutines
2+
//@ normalize-stderr: "\n\n$" -> "\n"
3+
4+
#![feature(test_binder_constraints)]
5+
#![allow(internal_features)]
6+
7+
core::test_binder_constraints! {
8+
impl<'a, 'b> {
9+
forall<'w> where 'b: 'w {
10+
//~^ ERROR higher-ranked lifetime bound could not be satisfied
11+
'b: 'w,
12+
'a: 'b,
13+
} expect {
14+
'a: 'b,
15+
}
16+
}
17+
}
18+
19+
fn main() {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error: higher-ranked lifetime bound could not be satisfied
2+
--> $DIR/min-coroutines-retains-unsatisfied-constraints.rs:9:9
3+
|
4+
LL | forall<'w> where 'b: 'w {
5+
| ^^^^^^
6+
7+
error: aborting due to 1 previous error

tests/ui/assumptions_on_binders/test-infra-works.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ check-pass
2-
//@ compile-flags: -Zassumptions-on-binders
2+
//@ revisions: assumptions min_coroutines
3+
//@[assumptions] compile-flags: -Zassumptions-on-binders
4+
//@[min_coroutines] compile-flags: -Zassumptions-on-binders=min_coroutines
35

46
#![feature(test_binder_constraints, non_lifetime_binders)]
57
#![expect(incomplete_features)]
@@ -19,6 +21,7 @@ core::test_binder_constraints! {
1921

2022
// FIXME(-Zassumptions-on-binders): this should be `impl<'b, 'c: 'b>`, not
2123
// `impl<'b, 'c: 'b + 'static>`, but OR isn't actually implemented yet
24+
#[cfg(assumptions)]
2225
core::test_binder_constraints! {
2326
impl<'b, 'c: 'b + 'static> {
2427
forall<'a> where 'b: 'a {
@@ -41,4 +44,15 @@ core::test_binder_constraints! {
4144
}
4245
}
4346

47+
#[cfg(min_coroutines)]
48+
core::test_binder_constraints! {
49+
impl {
50+
// Minimal mode directly discharges constraints proven by the current binder without
51+
// rewriting either placeholder into a lower universe.
52+
forall<'a, 'b> where 'b: 'a {
53+
'b: 'a,
54+
} expect {}
55+
}
56+
}
57+
4458
fn main() {}

tests/ui/async-await/higher-ranked-auto-trait-1.no_assumptions.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/higher-ranked-auto-trait-1.rs:37:5
2+
--> $DIR/higher-ranked-auto-trait-1.rs:39:5
33
|
44
LL | / async {
55
LL | | let _y = &();
@@ -10,13 +10,13 @@ LL | | drop(_x);
1010
LL | | }
1111
| |_____^ one type is more general than the other
1212
|
13-
= note: expected `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:40:19: 40:29}`
14-
found `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:40:19: 40:29}`
13+
= note: expected `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:42:19: 42:29}`
14+
found `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:42:19: 42:29}`
1515
= note: no two async blocks, even if identical, have the same type
1616
= help: consider pinning your async block and casting it to a trait object
1717

1818
error[E0308]: mismatched types
19-
--> $DIR/higher-ranked-auto-trait-1.rs:37:5
19+
--> $DIR/higher-ranked-auto-trait-1.rs:39:5
2020
|
2121
LL | / async {
2222
LL | | let _y = &();
@@ -27,8 +27,8 @@ LL | | drop(_x);
2727
LL | | }
2828
| |_____^ one type is more general than the other
2929
|
30-
= note: expected `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:40:19: 40:29}`
31-
found `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:40:19: 40:29}`
30+
= note: expected `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:42:19: 42:29}`
31+
found `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:42:19: 42:29}`
3232
= note: no two async blocks, even if identical, have the same type
3333
= help: consider pinning your async block and casting it to a trait object
3434
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

tests/ui/async-await/higher-ranked-auto-trait-1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Repro for <https://github.com/rust-lang/rust/issues/79648#issuecomment-749127947>.
22
//@ edition: 2021
3-
//@ revisions: assumptions no_assumptions
3+
//@ revisions: assumptions min_coroutines no_assumptions
44
//@[assumptions] compile-flags: -Zhigher-ranked-assumptions
55
//@[assumptions] check-pass
6+
//@[min_coroutines] compile-flags: -Zassumptions-on-binders=min_coroutines
7+
//@[min_coroutines] check-pass
68
//@[no_assumptions] known-bug: #110338
79

810
use std::future::Future;

tests/ui/async-await/higher-ranked-auto-trait-10.assumptions.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: implementation of `Foo` is not general enough
2-
--> $DIR/higher-ranked-auto-trait-10.rs:32:5
2+
--> $DIR/higher-ranked-auto-trait-10.rs:34:5
33
|
44
LL | Box::new(async move { get_foo(x).await })
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
@@ -8,7 +8,7 @@ LL | Box::new(async move { get_foo(x).await })
88
= note: ...but `Foo<'2>` is actually implemented for the type `&'2 str`, for some specific lifetime `'2`
99

1010
error: implementation of `Foo` is not general enough
11-
--> $DIR/higher-ranked-auto-trait-10.rs:32:5
11+
--> $DIR/higher-ranked-auto-trait-10.rs:34:5
1212
|
1313
LL | Box::new(async move { get_foo(x).await })
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough

tests/ui/async-await/higher-ranked-auto-trait-10.no_assumptions.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: implementation of `Foo` is not general enough
2-
--> $DIR/higher-ranked-auto-trait-10.rs:32:5
2+
--> $DIR/higher-ranked-auto-trait-10.rs:34:5
33
|
44
LL | Box::new(async move { get_foo(x).await })
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
@@ -8,7 +8,7 @@ LL | Box::new(async move { get_foo(x).await })
88
= note: ...but `Foo<'2>` is actually implemented for the type `&'2 str`, for some specific lifetime `'2`
99

1010
error: implementation of `Foo` is not general enough
11-
--> $DIR/higher-ranked-auto-trait-10.rs:32:5
11+
--> $DIR/higher-ranked-auto-trait-10.rs:34:5
1212
|
1313
LL | Box::new(async move { get_foo(x).await })
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough

tests/ui/async-await/higher-ranked-auto-trait-10.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Repro for <https://github.com/rust-lang/rust/issues/92415#issue-1090723521>.
22
//@ edition: 2021
3-
//@ revisions: assumptions no_assumptions
3+
//@ revisions: assumptions min_coroutines no_assumptions
44
//@[assumptions] compile-flags: -Zhigher-ranked-assumptions
55
//@[assumptions] known-bug: unknown
6+
//@[min_coroutines] compile-flags: -Zassumptions-on-binders=min_coroutines
7+
//@[min_coroutines] check-pass
68
//@[no_assumptions] known-bug: #110338
79

810
use std::any::Any;

0 commit comments

Comments
 (0)