rust/tests/ui/structs/struct-path-self.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
907 B
Rust
Raw Normal View History

struct S;
trait Tr {
fn f() {
let s = Self {};
//~^ ERROR expected struct, variant or union type, found type parameter
let z = Self::<u8> {};
//~^ ERROR expected struct, variant or union type, found type parameter
2022-06-01 23:55:30 +00:00
//~| ERROR type arguments are not allowed on self type
match s {
Self { .. } => {}
//~^ ERROR expected struct, variant or union type, found type parameter
}
}
}
impl Tr for S {
fn f() {
let s = Self {}; // OK
2022-06-01 23:55:30 +00:00
let z = Self::<u8> {}; //~ ERROR type arguments are not allowed on self type
match s {
Self { .. } => {} // OK
}
}
}
impl S {
fn g() {
let s = Self {}; // OK
2022-06-01 23:55:30 +00:00
let z = Self::<u8> {}; //~ ERROR type arguments are not allowed on self type
match s {
Self { .. } => {} // OK
}
}
}
fn main() {}