-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #107285 - compiler-errors:new-solver-future-and-gener…
…ator, r=lcnr Implement `Generator` and `Future` in the new solver r? `@lcnr`
- Loading branch information
Showing
9 changed files
with
316 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0271]: expected `[async block@$DIR/async.rs:12:17: 12:25]` to be a future that resolves to `i32`, but it resolves to `()` | ||
--> $DIR/async.rs:12:17 | ||
| | ||
LL | needs_async(async {}); | ||
| ----------- ^^^^^^^^ expected `i32`, found `()` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `needs_async` | ||
--> $DIR/async.rs:8:31 | ||
| | ||
LL | fn needs_async(_: impl Future<Output = i32>) {} | ||
| ^^^^^^^^^^^^ required by this bound in `needs_async` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0271`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// compile-flags: -Ztrait-solver=next | ||
// edition: 2021 | ||
// revisions: pass fail | ||
//[pass] check-pass | ||
|
||
use std::future::Future; | ||
|
||
fn needs_async(_: impl Future<Output = i32>) {} | ||
|
||
#[cfg(fail)] | ||
fn main() { | ||
needs_async(async {}); | ||
//[fail]~^ ERROR to be a future that resolves to `i32`, but it resolves to `()` | ||
} | ||
|
||
#[cfg(pass)] | ||
fn main() { | ||
needs_async(async { 1i32 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
error[E0277]: the trait bound `[generator@$DIR/generator.rs:18:21: 18:23]: Generator<A>` is not satisfied | ||
--> $DIR/generator.rs:18:21 | ||
| | ||
LL | needs_generator(|| { | ||
| _____---------------_^ | ||
| | | | ||
| | required by a bound introduced by this call | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | yield (); | ||
LL | | }); | ||
| |_____^ the trait `Generator<A>` is not implemented for `[generator@$DIR/generator.rs:18:21: 18:23]` | ||
| | ||
note: required by a bound in `needs_generator` | ||
--> $DIR/generator.rs:14:28 | ||
| | ||
LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `needs_generator` | ||
|
||
error[E0271]: type mismatch resolving `<[generator@$DIR/generator.rs:18:21: 18:23] as Generator<A>>::Yield == B` | ||
--> $DIR/generator.rs:18:21 | ||
| | ||
LL | needs_generator(|| { | ||
| _____---------------_^ | ||
| | | | ||
| | required by a bound introduced by this call | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | yield (); | ||
LL | | }); | ||
| |_____^ types differ | ||
| | ||
note: required by a bound in `needs_generator` | ||
--> $DIR/generator.rs:14:41 | ||
| | ||
LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} | ||
| ^^^^^^^^^ required by this bound in `needs_generator` | ||
|
||
error[E0271]: type mismatch resolving `<[generator@$DIR/generator.rs:18:21: 18:23] as Generator<A>>::Return == C` | ||
--> $DIR/generator.rs:18:21 | ||
| | ||
LL | needs_generator(|| { | ||
| _____---------------_^ | ||
| | | | ||
| | required by a bound introduced by this call | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | yield (); | ||
LL | | }); | ||
| |_____^ types differ | ||
| | ||
note: required by a bound in `needs_generator` | ||
--> $DIR/generator.rs:14:52 | ||
| | ||
LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} | ||
| ^^^^^^^^^^ required by this bound in `needs_generator` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0271, E0277. | ||
For more information about an error, try `rustc --explain E0271`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// compile-flags: -Ztrait-solver=next | ||
// edition: 2021 | ||
// revisions: pass fail | ||
//[pass] check-pass | ||
|
||
#![feature(generator_trait, generators)] | ||
|
||
use std::ops::Generator; | ||
|
||
struct A; | ||
struct B; | ||
struct C; | ||
|
||
fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} | ||
|
||
#[cfg(fail)] | ||
fn main() { | ||
needs_generator(|| { | ||
//[fail]~^ ERROR Generator<A>` is not satisfied | ||
//[fail]~| ERROR as Generator<A>>::Yield == B` | ||
//[fail]~| ERROR as Generator<A>>::Return == C` | ||
yield (); | ||
}); | ||
} | ||
|
||
#[cfg(pass)] | ||
fn main() { | ||
needs_generator(|_: A| { | ||
let _: A = yield B; | ||
C | ||
}) | ||
} |