Files
rust/src/test/ui/structs/struct-path-self.rs

38 lines
880 B
Rust
Raw Normal View History

struct S;
trait Tr {
fn f() {
let s = Self {};
2016-09-15 00:51:46 +03:00
//~^ ERROR expected struct, variant or union type, found Self
let z = Self::<u8> {};
2016-09-15 00:51:46 +03:00
//~^ ERROR expected struct, variant or union type, found Self
2019-03-20 18:32:52 +00:00
//~| ERROR type arguments are not allowed for this type
match s {
Self { .. } => {}
2016-09-15 00:51:46 +03:00
//~^ ERROR expected struct, variant or union type, found Self
}
}
}
impl Tr for S {
fn f() {
let s = Self {}; // OK
2019-03-20 18:32:52 +00:00
let z = Self::<u8> {}; //~ ERROR type arguments are not allowed for this type
match s {
Self { .. } => {} // OK
}
}
}
impl S {
fn g() {
let s = Self {}; // OK
2019-03-20 18:32:52 +00:00
let z = Self::<u8> {}; //~ ERROR type arguments are not allowed for this type
match s {
Self { .. } => {} // OK
}
}
}
fn main() {}