diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-02-22 08:16:39 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-02-24 00:59:38 +0100 |
| commit | a05c83b2ebc4e85e32f723e708a40dbd3f165cd0 (patch) | |
| tree | 8a5fe4fb32c7968db725c058c3991bcd4a3cdfd0 /src/test/ui/parser | |
| parent | a63f35daeefc4ae89ba5b6bd0323d97bb0d050e6 (diff) | |
| download | rust-a05c83b2ebc4e85e32f723e708a40dbd3f165cd0.tar.gz rust-a05c83b2ebc4e85e32f723e708a40dbd3f165cd0.zip | |
parse: use `parse_item_common` in `parse_assoc_item_`.
Diffstat (limited to 'src/test/ui/parser')
27 files changed, 479 insertions, 86 deletions
diff --git a/src/test/ui/parser/assoc-static-semantic-fail.rs b/src/test/ui/parser/assoc-static-semantic-fail.rs index cf3debd77cb..da4015a4620 100644 --- a/src/test/ui/parser/assoc-static-semantic-fail.rs +++ b/src/test/ui/parser/assoc-static-semantic-fail.rs @@ -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 } diff --git a/src/test/ui/parser/assoc-static-semantic-fail.stderr b/src/test/ui/parser/assoc-static-semantic-fail.stderr index dfd0053fda2..ca05b05e9b1 100644 --- a/src/test/ui/parser/assoc-static-semantic-fail.stderr +++ b/src/test/ui/parser/assoc-static-semantic-fail.stderr @@ -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`. diff --git a/src/test/ui/parser/attrs-after-extern-mod.stderr b/src/test/ui/parser/attrs-after-extern-mod.stderr index 6060f3afe1e..3862f5c379f 100644 --- a/src/test/ui/parser/attrs-after-extern-mod.stderr +++ b/src/test/ui/parser/attrs-after-extern-mod.stderr @@ -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 diff --git a/src/test/ui/parser/default-on-wrong-item-kind.rs b/src/test/ui/parser/default-on-wrong-item-kind.rs index 0fe20473587..16bb7735c90 100644 --- a/src/test/ui/parser/default-on-wrong-item-kind.rs +++ b/src/test/ui/parser/default-on-wrong-item-kind.rs @@ -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` +} diff --git a/src/test/ui/parser/default-on-wrong-item-kind.stderr b/src/test/ui/parser/default-on-wrong-item-kind.stderr index e089bbbddde..1812c45eba6 100644 --- a/src/test/ui/parser/default-on-wrong-item-kind.stderr +++ b/src/test/ui/parser/default-on-wrong-item-kind.stderr @@ -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 diff --git a/src/test/ui/parser/default-unmatched-assoc.rs b/src/test/ui/parser/default-unmatched-assoc.rs new file mode 100644 index 00000000000..bca6f5654db --- /dev/null +++ b/src/test/ui/parser/default-unmatched-assoc.rs @@ -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 +} diff --git a/src/test/ui/parser/default-unmatched-assoc.stderr b/src/test/ui/parser/default-unmatched-assoc.stderr new file mode 100644 index 00000000000..f3877f2ca6d --- /dev/null +++ b/src/test/ui/parser/default-unmatched-assoc.stderr @@ -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 + diff --git a/src/test/ui/parser/default.rs b/src/test/ui/parser/default.rs index 50952eef22f..bd9ed0f4524 100644 --- a/src/test/ui/parser/default.rs +++ b/src/test/ui/parser/default.rs @@ -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() {} diff --git a/src/test/ui/parser/default.stderr b/src/test/ui/parser/default.stderr index 07b051ece2b..fbf8101c36a 100644 --- a/src/test/ui/parser/default.stderr +++ b/src/test/ui/parser/default.stderr @@ -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`. diff --git a/src/test/ui/parser/extern-no-fn.stderr b/src/test/ui/parser/extern-no-fn.stderr index 02320125014..0151cb4235b 100644 --- a/src/test/ui/parser/extern-no-fn.stderr +++ b/src/test/ui/parser/extern-no-fn.stderr @@ -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 diff --git a/src/test/ui/parser/issue-19398.rs b/src/test/ui/parser/issue-19398.rs index 014c930ef82..46eb320a172 100644 --- a/src/test/ui/parser/issue-19398.rs +++ b/src/test/ui/parser/issue-19398.rs @@ -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() {} diff --git a/src/test/ui/parser/issue-19398.stderr b/src/test/ui/parser/issue-19398.stderr index b38b39f9bd9..1da00960adf 100644 --- a/src/test/ui/parser/issue-19398.stderr +++ b/src/test/ui/parser/issue-19398.stderr @@ -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 diff --git a/src/test/ui/parser/issue-20711-2.stderr b/src/test/ui/parser/issue-20711-2.stderr index 10ef31584de..12b18bbc594 100644 --- a/src/test/ui/parser/issue-20711-2.stderr +++ b/src/test/ui/parser/issue-20711-2.stderr @@ -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 diff --git a/src/test/ui/parser/issue-20711.stderr b/src/test/ui/parser/issue-20711.stderr index 66768de5694..4af4b22bee2 100644 --- a/src/test/ui/parser/issue-20711.stderr +++ b/src/test/ui/parser/issue-20711.stderr @@ -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 diff --git a/src/test/ui/parser/issue-21153.rs b/src/test/ui/parser/issue-21153.rs index 4fe05e6f041..bf5fdb1f3c6 100644 --- a/src/test/ui/parser/issue-21153.rs +++ b/src/test/ui/parser/issue-21153.rs @@ -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() {} diff --git a/src/test/ui/parser/issue-21153.stderr b/src/test/ui/parser/issue-21153.stderr index e9824bd7290..cbfa9ded3c3 100644 --- a/src/test/ui/parser/issue-21153.stderr +++ b/src/test/ui/parser/issue-21153.stderr @@ -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 diff --git a/src/test/ui/parser/issue-32446.stderr b/src/test/ui/parser/issue-32446.stderr index d25828da0b9..7515369aaa0 100644 --- a/src/test/ui/parser/issue-32446.stderr +++ b/src/test/ui/parser/issue-32446.stderr @@ -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 diff --git a/src/test/ui/parser/issue-41155.rs b/src/test/ui/parser/issue-41155.rs index 3c24d2b447d..bed4805e7ce 100644 --- a/src/test/ui/parser/issue-41155.rs +++ b/src/test/ui/parser/issue-41155.rs @@ -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() {} diff --git a/src/test/ui/parser/issue-41155.stderr b/src/test/ui/parser/issue-41155.stderr index a91ef6c67e8..a9c1035f4d8 100644 --- a/src/test/ui/parser/issue-41155.stderr +++ b/src/test/ui/parser/issue-41155.stderr @@ -1,10 +1,22 @@ -error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `static`, `type`, `unsafe`, or identifier, found `}` +error: unmatched visibility `pub` + --> $DIR/issue-41155.rs:4:5 + | +LL | pub + | ^^^ 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 - | - expected one of 10 possible tokens LL | } - | ^ unexpected token + | ^ + | | + | non-item starts here + | item list ends here -error: aborting due to previous error +error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/issue-6610.stderr b/src/test/ui/parser/issue-6610.stderr index 22d93bffead..a9804208946 100644 --- a/src/test/ui/parser/issue-6610.stderr +++ b/src/test/ui/parser/issue-6610.stderr @@ -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 diff --git a/src/test/ui/parser/macro/trait-non-item-macros.rs b/src/test/ui/parser/macro/trait-non-item-macros.rs index 5021886bf98..97fb564bf64 100644 --- a/src/test/ui/parser/macro/trait-non-item-macros.rs +++ b/src/test/ui/parser/macro/trait-non-item-macros.rs @@ -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 +} diff --git a/src/test/ui/parser/macro/trait-non-item-macros.stderr b/src/test/ui/parser/macro/trait-non-item-macros.stderr index c76b096a1eb..35e5bfe62f5 100644 --- a/src/test/ui/parser/macro/trait-non-item-macros.stderr +++ b/src/test/ui/parser/macro/trait-non-item-macros.stderr @@ -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`. diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs index 748db8983b5..d85255328f7 100644 --- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs +++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs @@ -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 diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr index 240be39eace..2b72c06c9c7 100644 --- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr +++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr @@ -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`. diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs index 4e8cc6489bc..b2515b17ff3 100644 --- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs +++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs @@ -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) {} } diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr index 54afad5755b..89bf2916510 100644 --- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr +++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr @@ -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`. diff --git a/src/test/ui/parser/removed-syntax-static-fn.stderr b/src/test/ui/parser/removed-syntax-static-fn.stderr index dc5625bdade..04e34dc16a8 100644 --- a/src/test/ui/parser/removed-syntax-static-fn.stderr +++ b/src/test/ui/parser/removed-syntax-static-fn.stderr @@ -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 |
