parse: use parse_item_common in parse_assoc_item_.
This commit is contained in:
parent
a63f35daee
commit
a05c83b2eb
38 changed files with 669 additions and 287 deletions
|
|
@ -10,10 +10,12 @@ impl S {
|
|||
//~^ ERROR associated `static` items are not allowed
|
||||
static IB: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
//~| ERROR associated constant in `impl` without body
|
||||
default static IC: u8 = 0;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
pub(crate) default static ID: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
//~| ERROR associated constant in `impl` without body
|
||||
}
|
||||
|
||||
trait T {
|
||||
|
|
@ -35,9 +37,11 @@ impl T for S {
|
|||
//~^ ERROR associated `static` items are not allowed
|
||||
static TB: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
//~| ERROR associated constant in `impl` without body
|
||||
default static TC: u8 = 0;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
pub default static TD: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
//~| ERROR associated constant in `impl` without body
|
||||
//~| ERROR unnecessary visibility qualifier
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,67 +11,83 @@ LL | static IB: u8;
|
|||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:13:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:14:5
|
||||
|
|
||||
LL | default static IC: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:15:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:16:5
|
||||
|
|
||||
LL | pub(crate) default static ID: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:20:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:22:5
|
||||
|
|
||||
LL | static TA: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:22:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:24:5
|
||||
|
|
||||
LL | static TB: u8;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:24:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:26:5
|
||||
|
|
||||
LL | default static TC: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:27:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:29:5
|
||||
|
|
||||
LL | pub(crate) default static TD: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:34:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:36:5
|
||||
|
|
||||
LL | static TA: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:36:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:38:5
|
||||
|
|
||||
LL | static TB: u8;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:38:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:41:5
|
||||
|
|
||||
LL | default static TC: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:40:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:43:5
|
||||
|
|
||||
LL | pub default static TD: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/assoc-static-semantic-fail.rs:11:5
|
||||
|
|
||||
LL | static IB: u8;
|
||||
| ^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/assoc-static-semantic-fail.rs:16:5
|
||||
|
|
||||
LL | pub(crate) default static ID: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error: `default` is only allowed on items in `impl` definitions
|
||||
--> $DIR/assoc-static-semantic-fail.rs:24:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:26:5
|
||||
|
|
||||
LL | default static TC: u8 = 0;
|
||||
| -------^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -79,7 +95,7 @@ LL | default static TC: u8 = 0;
|
|||
| `default` because of this
|
||||
|
||||
error: `default` is only allowed on items in `impl` definitions
|
||||
--> $DIR/assoc-static-semantic-fail.rs:27:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:29:5
|
||||
|
|
||||
LL | pub(crate) default static TD: u8;
|
||||
| ^^^^^^^^^^^-------^^^^^^^^^^^^^^^
|
||||
|
|
@ -87,17 +103,33 @@ LL | pub(crate) default static TD: u8;
|
|||
| `default` because of this
|
||||
|
||||
error[E0449]: unnecessary visibility qualifier
|
||||
--> $DIR/assoc-static-semantic-fail.rs:27:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:29:5
|
||||
|
|
||||
LL | pub(crate) default static TD: u8;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/assoc-static-semantic-fail.rs:38:5
|
||||
|
|
||||
LL | static TB: u8;
|
||||
| ^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/assoc-static-semantic-fail.rs:43:5
|
||||
|
|
||||
LL | pub default static TD: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error[E0449]: unnecessary visibility qualifier
|
||||
--> $DIR/assoc-static-semantic-fail.rs:40:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:43:5
|
||||
|
|
||||
LL | pub default static TD: u8;
|
||||
| ^^^ `pub` not permitted here because it's implied
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0449`.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
error: expected item after attributes
|
||||
--> $DIR/attrs-after-extern-mod.rs:6:5
|
||||
|
|
||||
LL | extern {
|
||||
| - while parsing this item list starting here
|
||||
LL | #[cfg(stage37)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -60,3 +60,73 @@ extern "C" {
|
|||
default macro_rules! foo {} //~ ERROR item cannot be `default`
|
||||
//~^ ERROR item kind not supported in `extern` block
|
||||
}
|
||||
|
||||
#[cfg(FALSE)]
|
||||
impl S {
|
||||
default extern crate foo;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default use foo;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default static foo: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
default const foo: u8;
|
||||
default fn foo();
|
||||
default mod foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default extern "C" {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default type foo = u8;
|
||||
default enum foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default struct foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default union foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default trait foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default trait foo = Ord;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default impl foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default!();
|
||||
default::foo::bar!();
|
||||
default macro foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default macro_rules! foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
}
|
||||
|
||||
#[cfg(FALSE)]
|
||||
trait T {
|
||||
default extern crate foo;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default use foo;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default static foo: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
default const foo: u8;
|
||||
default fn foo();
|
||||
default mod foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default extern "C" {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default type foo = u8;
|
||||
default enum foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default struct foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default union foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default trait foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default trait foo = Ord;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default impl foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default!();
|
||||
default::foo::bar!();
|
||||
default macro foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default macro_rules! foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,5 +320,161 @@ error: item kind not supported in `extern` block
|
|||
LL | default macro_rules! foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 43 previous errors
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:66:5
|
||||
|
|
||||
LL | default extern crate foo;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:68:5
|
||||
|
|
||||
LL | default use foo;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/default-on-wrong-item-kind.rs:70:5
|
||||
|
|
||||
LL | default static foo: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:74:5
|
||||
|
|
||||
LL | default mod foo {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:76:5
|
||||
|
|
||||
LL | default extern "C" {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:79:5
|
||||
|
|
||||
LL | default enum foo {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:81:5
|
||||
|
|
||||
LL | default struct foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:83:5
|
||||
|
|
||||
LL | default union foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:85:5
|
||||
|
|
||||
LL | default trait foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:87:5
|
||||
|
|
||||
LL | default trait foo = Ord;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:89:5
|
||||
|
|
||||
LL | default impl foo {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:93:5
|
||||
|
|
||||
LL | default macro foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:95:5
|
||||
|
|
||||
LL | default macro_rules! foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:101:5
|
||||
|
|
||||
LL | default extern crate foo;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:103:5
|
||||
|
|
||||
LL | default use foo;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/default-on-wrong-item-kind.rs:105:5
|
||||
|
|
||||
LL | default static foo: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:109:5
|
||||
|
|
||||
LL | default mod foo {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:111:5
|
||||
|
|
||||
LL | default extern "C" {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:114:5
|
||||
|
|
||||
LL | default enum foo {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:116:5
|
||||
|
|
||||
LL | default struct foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:118:5
|
||||
|
|
||||
LL | default union foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:120:5
|
||||
|
|
||||
LL | default trait foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:122:5
|
||||
|
|
||||
LL | default trait foo = Ord;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:124:5
|
||||
|
|
||||
LL | default impl foo {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:128:5
|
||||
|
|
||||
LL | default macro foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:130:5
|
||||
|
|
||||
LL | default macro_rules! foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 69 previous errors
|
||||
|
||||
|
|
|
|||
16
src/test/ui/parser/default-unmatched-assoc.rs
Normal file
16
src/test/ui/parser/default-unmatched-assoc.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
fn main() {}
|
||||
|
||||
trait Foo {
|
||||
default!(); //~ ERROR cannot find macro `default` in this scope
|
||||
default do
|
||||
//~^ ERROR unmatched `default`
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
||||
struct S;
|
||||
impl S {
|
||||
default!(); //~ ERROR cannot find macro `default` in this scope
|
||||
default do
|
||||
//~^ ERROR unmatched `default`
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
50
src/test/ui/parser/default-unmatched-assoc.stderr
Normal file
50
src/test/ui/parser/default-unmatched-assoc.stderr
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
error: unmatched `default`
|
||||
--> $DIR/default-unmatched-assoc.rs:5:5
|
||||
|
|
||||
LL | default do
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default-unmatched-assoc.rs:5:13
|
||||
|
|
||||
LL | trait Foo {
|
||||
| - item list starts here
|
||||
LL | default!();
|
||||
LL | default do
|
||||
| ^^ non-item starts here
|
||||
...
|
||||
LL | }
|
||||
| - item list ends here
|
||||
|
||||
error: unmatched `default`
|
||||
--> $DIR/default-unmatched-assoc.rs:13:5
|
||||
|
|
||||
LL | default do
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default-unmatched-assoc.rs:13:13
|
||||
|
|
||||
LL | impl S {
|
||||
| - item list starts here
|
||||
LL | default!();
|
||||
LL | default do
|
||||
| ^^ non-item starts here
|
||||
...
|
||||
LL | }
|
||||
| - item list ends here
|
||||
|
||||
error: cannot find macro `default` in this scope
|
||||
--> $DIR/default-unmatched-assoc.rs:12:5
|
||||
|
|
||||
LL | default!();
|
||||
| ^^^^^^^
|
||||
|
||||
error: cannot find macro `default` in this scope
|
||||
--> $DIR/default-unmatched-assoc.rs:4:5
|
||||
|
|
||||
LL | default!();
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
@ -20,7 +20,8 @@ impl Foo for u16 {
|
|||
|
||||
impl Foo for u32 { //~ ERROR not all trait items implemented, missing: `foo`
|
||||
default pub fn foo<T: Default>() -> T { T::default() }
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
//~^ ERROR unmatched `default`
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,19 @@
|
|||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/default.rs:22:12
|
||||
error: unmatched `default`
|
||||
--> $DIR/default.rs:22:5
|
||||
|
|
||||
LL | default pub fn foo<T: Default>() -> T { T::default() }
|
||||
| ^ missing `fn`, `type`, `const`, or `static`
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default.rs:22:13
|
||||
|
|
||||
LL | impl Foo for u32 {
|
||||
| - item list starts here
|
||||
LL | default pub fn foo<T: Default>() -> T { T::default() }
|
||||
| ^^^ non-item starts here
|
||||
...
|
||||
LL | }
|
||||
| - item list ends here
|
||||
|
||||
error[E0449]: unnecessary visibility qualifier
|
||||
--> $DIR/default.rs:16:5
|
||||
|
|
@ -19,7 +30,7 @@ LL | fn foo<T: Default>() -> T;
|
|||
LL | impl Foo for u32 {
|
||||
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0046, E0449.
|
||||
For more information about an error, try `rustc --explain E0046`.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
error: expected one of `!` or `::`, found `(`
|
||||
--> $DIR/extern-no-fn.rs:2:6
|
||||
|
|
||||
LL | extern {
|
||||
| - while parsing this item list starting here
|
||||
LL | f();
|
||||
| ^ expected one of `!` or `::`
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
trait T {
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
extern "Rust" unsafe fn foo();
|
||||
//~^ ERROR expected `{`, found keyword `unsafe`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-19398.rs:1:10
|
||||
error: expected `{`, found keyword `unsafe`
|
||||
--> $DIR/issue-19398.rs:2:19
|
||||
|
|
||||
LL | trait T {
|
||||
| __________^
|
||||
LL | |
|
||||
LL | | extern "Rust" unsafe fn foo();
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait T {
|
||||
| - while parsing this item list starting here
|
||||
LL | extern "Rust" unsafe fn foo();
|
||||
| ^^^^^^ expected `{`
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
error: expected item after attributes
|
||||
--> $DIR/issue-20711-2.rs:6:5
|
||||
|
|
||||
LL | impl Foo {
|
||||
| - while parsing this item list starting here
|
||||
...
|
||||
LL | #[stable(feature = "rust1", since = "1.0.0")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
error: expected item after attributes
|
||||
--> $DIR/issue-20711.rs:4:5
|
||||
|
|
||||
LL | impl Foo {
|
||||
| - while parsing this item list starting here
|
||||
LL | #[stable(feature = "rust1", since = "1.0.0")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
trait MyTrait<T>: Iterator {
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
Item = T;
|
||||
//~^ ERROR expected one of `!` or `::`, found `=`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-21153.rs:1:29
|
||||
error: expected one of `!` or `::`, found `=`
|
||||
--> $DIR/issue-21153.rs:2:10
|
||||
|
|
||||
LL | trait MyTrait<T>: Iterator {
|
||||
| _____________________________^
|
||||
LL | |
|
||||
LL | | Item = T;
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait MyTrait<T>: Iterator {
|
||||
| - while parsing this item list starting here
|
||||
LL | Item = T;
|
||||
| ^ expected one of `!` or `::`
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, `}`, or identifier, found `...`
|
||||
error: non-item in item list
|
||||
--> $DIR/issue-32446.rs:4:11
|
||||
|
|
||||
LL | trait T { ... }
|
||||
| ^^^ expected one of 12 possible tokens
|
||||
| - ^^^ - item list ends here
|
||||
| | |
|
||||
| | non-item starts here
|
||||
| item list starts here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
struct S;
|
||||
|
||||
impl S {
|
||||
pub
|
||||
} //~ ERROR expected one of
|
||||
pub //~ ERROR unmatched visibility `pub`
|
||||
} //~ ERROR non-item in item list
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,22 @@
|
|||
error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `static`, `type`, `unsafe`, or identifier, found `}`
|
||||
--> $DIR/issue-41155.rs:5:1
|
||||
error: unmatched visibility `pub`
|
||||
--> $DIR/issue-41155.rs:4:5
|
||||
|
|
||||
LL | pub
|
||||
| - expected one of 10 possible tokens
|
||||
| ^^^ the unmatched visibility
|
||||
|
|
||||
= help: you likely meant to define an item, e.g., `pub fn foo() {}`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/issue-41155.rs:5:1
|
||||
|
|
||||
LL | impl S {
|
||||
| - item list starts here
|
||||
LL | pub
|
||||
LL | }
|
||||
| ^ unexpected token
|
||||
| ^
|
||||
| |
|
||||
| non-item starts here
|
||||
| item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ error: expected `;` or `{`, found `}`
|
|||
--> $DIR/issue-6610.rs:1:20
|
||||
|
|
||||
LL | trait Foo { fn a() }
|
||||
| ^ expected `;` or `{`
|
||||
| - ^
|
||||
| | |
|
||||
| | expected `;` or `{`
|
||||
| | the item list ends here
|
||||
| while parsing this item list starting here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
macro_rules! bah {
|
||||
($a:expr) => ($a)
|
||||
//~^ ERROR expected one of `async`
|
||||
($a:expr) => {
|
||||
$a
|
||||
}; //~^ ERROR macro expansion ignores token `2` and any following
|
||||
}
|
||||
|
||||
trait bar {
|
||||
trait Bar {
|
||||
bah!(2);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn main() {
|
||||
let _recovery_witness: () = 0; //~ ERROR mismatched types
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,22 @@
|
|||
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, or identifier, found `2`
|
||||
--> $DIR/trait-non-item-macros.rs:2:19
|
||||
error: macro expansion ignores token `2` and any following
|
||||
--> $DIR/trait-non-item-macros.rs:3:9
|
||||
|
|
||||
LL | ($a:expr) => ($a)
|
||||
| ^^ expected one of 11 possible tokens
|
||||
LL | $a
|
||||
| ^^
|
||||
...
|
||||
LL | bah!(2);
|
||||
| -------- in this macro invocation
|
||||
| -------- caused by the macro expansion here
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: the usage of `bah!` is likely invalid in trait item context
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/trait-non-item-macros.rs:12:33
|
||||
|
|
||||
LL | let _recovery_witness: () = 0;
|
||||
| -- ^ expected `()`, found integer
|
||||
| |
|
||||
| expected due to this
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@ fn main() {}
|
|||
impl T for () { //~ ERROR cannot find trait `T` in this scope
|
||||
|
||||
fn foo(&self) {}
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
|
||||
trait T {
|
||||
trait T { //~ ERROR item kind not supported in `trait` or `impl`
|
||||
fn foo(&self);
|
||||
}
|
||||
|
||||
pub(crate) struct Bar<T>();
|
||||
pub(crate) struct Bar<T>(); //~ ERROR item kind not supported in `trait` or `impl`
|
||||
|
||||
//~ ERROR this file contains an unclosed delimiter
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this file contains an unclosed delimiter
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:14:52
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:13:52
|
||||
|
|
||||
LL | impl T for () {
|
||||
| - unclosed delimiter
|
||||
|
|
@ -7,15 +7,17 @@ LL | impl T for () {
|
|||
LL |
|
||||
| ^
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:5:17
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:7:1
|
||||
|
|
||||
LL | fn foo(&self) {}
|
||||
| _________________^
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | trait T {
|
||||
| |_ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait T {
|
||||
| ^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:11:1
|
||||
|
|
||||
LL | pub(crate) struct Bar<T>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0405]: cannot find trait `T` in this scope
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:3:6
|
||||
|
|
@ -23,6 +25,6 @@ error[E0405]: cannot find trait `T` in this scope
|
|||
LL | impl T for () {
|
||||
| ^ not found in this scope
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0405`.
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
trait T {
|
||||
//~^ ERROR `main` function not found in crate `missing_close_brace_in_trait`
|
||||
fn foo(&self);
|
||||
|
||||
pub(crate) struct Bar<T>();
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
|
||||
impl T for Bar<usize> {
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
fn foo(&self) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,24 +7,17 @@ LL | trait T {
|
|||
LL | fn main() {}
|
||||
| ^
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/missing-close-brace-in-trait.rs:5:11
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/missing-close-brace-in-trait.rs:4:1
|
||||
|
|
||||
LL | pub(crate) struct Bar<T>();
|
||||
| ^ missing `fn`, `type`, `const`, or `static`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0601]: `main` function not found in crate `missing_close_brace_in_trait`
|
||||
--> $DIR/missing-close-brace-in-trait.rs:1:1
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/missing-close-brace-in-trait.rs:7:1
|
||||
|
|
||||
LL | / trait T {
|
||||
LL | |
|
||||
LL | | fn foo(&self);
|
||||
LL | |
|
||||
... |
|
||||
LL | |
|
||||
LL | | fn main() {}
|
||||
| |________________________________________________________________^ consider adding a `main` function to `$DIR/missing-close-brace-in-trait.rs`
|
||||
LL | impl T for Bar<usize> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0601`.
|
||||
|
|
|
|||
|
|
@ -7,8 +7,13 @@ LL | static fn f() {}
|
|||
error: expected one of `:`, `;`, or `=`, found `f`
|
||||
--> $DIR/removed-syntax-static-fn.rs:4:15
|
||||
|
|
||||
LL | impl S {
|
||||
| - while parsing this item list starting here
|
||||
LL | static fn f() {}
|
||||
| ^ expected one of `:`, `;`, or `=`
|
||||
...
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: missing type for `static` item
|
||||
--> $DIR/removed-syntax-static-fn.rs:4:12
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue