append more test cases for issue 61076

This commit is contained in:
csmoe 2020-05-30 22:57:12 +08:00
parent ee541284bf
commit 1d30de6202
2 changed files with 58 additions and 4 deletions

View File

@ -6,6 +6,16 @@ use core::task::{Context, Poll};
struct T;
struct UnionStruct(i32);
struct Struct {
a: i32
}
enum Enum {
A
}
impl Future for T {
type Output = Result<(), ()>;
@ -26,7 +36,19 @@ async fn bar() -> Result<(), ()> {
async fn baz() -> Result<(), ()> {
let t = T;
t?; //~ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
let _: i32 = async {
UnionStruct(1i32)
}.0; //~ ERROR no field `0`
let _: i32 = async {
Struct { a: 1i32 }
}.a; //~ ERROR no field `a`
if let Enum::A = async { Enum::A } {} //~ ERROR mismatched type
Ok(())
}
fn main() {}

View File

@ -1,5 +1,5 @@
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
--> $DIR/issue-61076.rs:22:5
--> $DIR/issue-61076.rs:32:5
|
LL | foo()?;
| ^^^^^^
@ -11,7 +11,7 @@ LL | foo()?;
= note: required by `std::ops::Try::into_result`
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
--> $DIR/issue-61076.rs:28:5
--> $DIR/issue-61076.rs:38:5
|
LL | t?;
| ^^
@ -22,6 +22,38 @@ LL | t?;
= help: the trait `std::ops::Try` is not implemented for `T`
= note: required by `std::ops::Try::into_result`
error: aborting due to 2 previous errors
error[E0609]: no field `0` on type `impl std::future::Future`
--> $DIR/issue-61076.rs:42:7
|
LL | }.0;
| ^
For more information about this error, try `rustc --explain E0277`.
error[E0609]: no field `a` on type `impl std::future::Future`
--> $DIR/issue-61076.rs:46:7
|
LL | }.a;
| ^
error[E0308]: mismatched types
--> $DIR/issue-61076.rs:48:12
|
LL | A
| - unit variant defined here
...
LL | if let Enum::A = async { Enum::A } {}
| ^^^^^^^ ----------- the expected generator
| |
| expected opaque type, found enum `Enum`
|
::: $SRC_DIR/libcore/future/mod.rs:LL:COL
|
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the expected opaque type
|
= note: expected opaque type `impl std::future::Future`
found enum `Enum`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0277, E0308, E0609.
For more information about an error, try `rustc --explain E0277`.