diff options
Diffstat (limited to 'src/test/ui/structs')
5 files changed, 52 insertions, 11 deletions
diff --git a/src/test/ui/structs/incomplete-fn-in-struct-definition.rs b/src/test/ui/structs/incomplete-fn-in-struct-definition.rs new file mode 100644 index 000000000..cd8a79ba6 --- /dev/null +++ b/src/test/ui/structs/incomplete-fn-in-struct-definition.rs @@ -0,0 +1,5 @@ +fn main() {} + +struct S { + fn: u8 //~ ERROR expected identifier, found keyword `fn` +} diff --git a/src/test/ui/structs/incomplete-fn-in-struct-definition.stderr b/src/test/ui/structs/incomplete-fn-in-struct-definition.stderr new file mode 100644 index 000000000..0d12ba9c9 --- /dev/null +++ b/src/test/ui/structs/incomplete-fn-in-struct-definition.stderr @@ -0,0 +1,15 @@ +error: expected identifier, found keyword `fn` + --> $DIR/incomplete-fn-in-struct-definition.rs:4:5 + | +LL | struct S { + | - while parsing this struct +LL | fn: u8 + | ^^ expected identifier, found keyword + | +help: escape `fn` to use it as an identifier + | +LL | r#fn: u8 + | ++ + +error: aborting due to previous error + diff --git a/src/test/ui/structs/struct-fn-in-definition.stderr b/src/test/ui/structs/struct-fn-in-definition.stderr index 1d7cd5272..472365c6e 100644 --- a/src/test/ui/structs/struct-fn-in-definition.stderr +++ b/src/test/ui/structs/struct-fn-in-definition.stderr @@ -1,6 +1,9 @@ error: functions are not allowed in struct definitions --> $DIR/struct-fn-in-definition.rs:9:5 | +LL | struct S { + | - while parsing this struct +... LL | fn foo() {} | ^^^^^^^^^^^ | @@ -10,6 +13,9 @@ LL | fn foo() {} error: functions are not allowed in union definitions --> $DIR/struct-fn-in-definition.rs:18:5 | +LL | union U { + | - while parsing this union +... LL | fn foo() {} | ^^^^^^^^^^^ | @@ -19,6 +25,9 @@ LL | fn foo() {} error: functions are not allowed in enum definitions --> $DIR/struct-fn-in-definition.rs:27:5 | +LL | enum E { + | - while parsing this enum +... LL | fn foo() {} | ^^^^^^^^^^^ | diff --git a/src/test/ui/structs/struct-path-associated-type.rs b/src/test/ui/structs/struct-path-associated-type.rs index f88572f84..2dd7174a9 100644 --- a/src/test/ui/structs/struct-path-associated-type.rs +++ b/src/test/ui/structs/struct-path-associated-type.rs @@ -13,7 +13,7 @@ fn f<T: Tr>() { //~^ ERROR expected struct, variant or union type, found associated type let z = T::A::<u8> {}; //~^ ERROR expected struct, variant or union type, found associated type - //~| ERROR type arguments are not allowed on this type + //~| ERROR this associated type takes 0 generic arguments but 1 generic argument was supplied match S { T::A {} => {} //~^ ERROR expected struct, variant or union type, found associated type @@ -22,7 +22,7 @@ fn f<T: Tr>() { fn g<T: Tr<A = S>>() { let s = T::A {}; // OK - let z = T::A::<u8> {}; //~ ERROR type arguments are not allowed on this type + let z = T::A::<u8> {}; //~ ERROR this associated type takes 0 generic arguments but 1 generic argument was supplied match S { T::A {} => {} // OK } diff --git a/src/test/ui/structs/struct-path-associated-type.stderr b/src/test/ui/structs/struct-path-associated-type.stderr index bdce0e1b3..abb445214 100644 --- a/src/test/ui/structs/struct-path-associated-type.stderr +++ b/src/test/ui/structs/struct-path-associated-type.stderr @@ -4,13 +4,19 @@ error[E0071]: expected struct, variant or union type, found associated type LL | let s = T::A {}; | ^^^^ not a struct -error[E0109]: type arguments are not allowed on this type - --> $DIR/struct-path-associated-type.rs:14:20 +error[E0107]: this associated type takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/struct-path-associated-type.rs:14:16 | LL | let z = T::A::<u8> {}; - | - ^^ type argument not allowed + | ^------ help: remove these generics | | - | not allowed on this type + | expected 0 generic arguments + | +note: associated type defined here, with 0 generic parameters + --> $DIR/struct-path-associated-type.rs:4:10 + | +LL | type A; + | ^ error[E0071]: expected struct, variant or union type, found associated type --> $DIR/struct-path-associated-type.rs:14:13 @@ -24,13 +30,19 @@ error[E0071]: expected struct, variant or union type, found associated type LL | T::A {} => {} | ^^^^ not a struct -error[E0109]: type arguments are not allowed on this type - --> $DIR/struct-path-associated-type.rs:25:20 +error[E0107]: this associated type takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/struct-path-associated-type.rs:25:16 | LL | let z = T::A::<u8> {}; - | - ^^ type argument not allowed + | ^------ help: remove these generics | | - | not allowed on this type + | expected 0 generic arguments + | +note: associated type defined here, with 0 generic parameters + --> $DIR/struct-path-associated-type.rs:4:10 + | +LL | type A; + | ^ error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:32:13 @@ -52,5 +64,5 @@ LL | S::A {} => {} error: aborting due to 8 previous errors -Some errors have detailed explanations: E0071, E0109, E0223. +Some errors have detailed explanations: E0071, E0107, E0223. For more information about an error, try `rustc --explain E0071`. |