Add ui test: suggest-struct-or-union-add-generic-impl-trait.rs
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
parent
d7ed32b0c0
commit
7e199b10c9
2 changed files with 81 additions and 0 deletions
|
@ -0,0 +1,30 @@
|
|||
//@ edition:2021
|
||||
trait Trait {}
|
||||
|
||||
struct Foo1 {
|
||||
a: Trait,
|
||||
//~^ ERROR expected a type, found a trait
|
||||
b: u32,
|
||||
}
|
||||
|
||||
struct Foo2 {
|
||||
a: i32,
|
||||
b: Trait,
|
||||
//~^ ERROR expected a type, found a trait
|
||||
}
|
||||
|
||||
|
||||
enum Enum1 {
|
||||
A(Trait),
|
||||
//~^ ERROR expected a type, found a trait
|
||||
B(u32),
|
||||
}
|
||||
|
||||
enum Enum2 {
|
||||
A(u32),
|
||||
B(Trait),
|
||||
//~^ ERROR expected a type, found a trait
|
||||
}
|
||||
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,51 @@
|
|||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/suggest-struct-or-union-add-generic-impl-trait.rs:5:8
|
||||
|
|
||||
LL | a: Trait,
|
||||
| ^^^^^
|
||||
|
|
||||
help: you might be missing a type parameter
|
||||
|
|
||||
LL ~ struct Foo1<T: Trait> {
|
||||
LL ~ a: T,
|
||||
|
|
||||
|
||||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/suggest-struct-or-union-add-generic-impl-trait.rs:12:8
|
||||
|
|
||||
LL | b: Trait,
|
||||
| ^^^^^
|
||||
|
|
||||
help: you can add the `dyn` keyword if you want a trait object
|
||||
|
|
||||
LL | b: dyn Trait,
|
||||
| +++
|
||||
|
||||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/suggest-struct-or-union-add-generic-impl-trait.rs:18:7
|
||||
|
|
||||
LL | A(Trait),
|
||||
| ^^^^^
|
||||
|
|
||||
help: you might be missing a type parameter
|
||||
|
|
||||
LL ~ enum Enum1<T: Trait> {
|
||||
LL ~ A(T),
|
||||
|
|
||||
|
||||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/suggest-struct-or-union-add-generic-impl-trait.rs:25:7
|
||||
|
|
||||
LL | B(Trait),
|
||||
| ^^^^^
|
||||
|
|
||||
help: you might be missing a type parameter
|
||||
|
|
||||
LL ~ enum Enum2<T: Trait> {
|
||||
LL | A(u32),
|
||||
LL ~ B(T),
|
||||
|
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0782`.
|
Loading…
Add table
Add a link
Reference in a new issue