parser: unify item list parsing.

as a consequence, `trait X { #![attr] }` becomes legal.
This commit is contained in:
Mazdak Farrokhzad 2020-01-31 06:43:33 +01:00
parent 9fed2d587c
commit 7737d0ffde
12 changed files with 80 additions and 71 deletions

View file

@ -0,0 +1,7 @@
// pp-exact
trait Foo {
#![allow(bar)]
}
fn main() { }

View file

@ -1,13 +1,7 @@
// Constants (static variables) can be used to match in patterns, but mutable
// statics cannot. This ensures that there's some form of error if this is
// attempted.
// Make sure there's an error when given `extern { ... #[attr] }`.
extern crate libc;
fn main() {}
extern {
static mut rust_dbg_static_mut: libc::c_int;
pub fn rust_dbg_static_mut_check_four();
#[cfg(stage37)] //~ ERROR expected item after attributes
}
pub fn main() {}

View file

@ -1,5 +1,5 @@
error: expected item after attributes
--> $DIR/attrs-after-extern-mod.rs:10:19
--> $DIR/attrs-after-extern-mod.rs:6:19
|
LL | #[cfg(stage37)]
| ^

View file

@ -1,4 +1,6 @@
fn main() {}
extern {
/// hi
//~^ ERROR expected item after doc comment
//~^ ERROR found a documentation comment that doesn't document anything
}

View file

@ -1,8 +1,11 @@
error: expected item after doc comment
--> $DIR/doc-before-extern-rbrace.rs:2:5
error[E0584]: found a documentation comment that doesn't document anything
--> $DIR/doc-before-extern-rbrace.rs:4:5
|
LL | /// hi
| ^^^^^^ this doc comment doesn't document anything
|
= help: doc comments must come before what they document, maybe a comment was intended with `//`?
error: aborting due to previous error
For more information about this error, try `rustc --explain E0584`.

View file

@ -2,7 +2,7 @@ error[E0584]: found a documentation comment that doesn't document anything
--> $DIR/doc-inside-trait-item.rs:3:5
|
LL | /// empty doc
| ^^^^^^^^^^^^^
| ^^^^^^^^^^^^^ this doc comment doesn't document anything
|
= help: doc comments must come before what they document, maybe a comment was intended with `//`?

View file

@ -1,4 +1,7 @@
// error-pattern: expected one of `(`, `async`, `const`, `extern`, `fn`
fn main() {}
extern {
pub pub fn foo();
}

View file

@ -1,5 +1,5 @@
error: expected one of `(`, `async`, `const`, `extern`, `fn`, `static`, `type`, or `unsafe`, found keyword `pub`
--> $DIR/duplicate-visibility.rs:3:9
--> $DIR/duplicate-visibility.rs:6:9
|
LL | pub pub fn foo();
| ^^^ expected one of 8 possible tokens

View file

@ -0,0 +1,9 @@
// check-pass
#![deny(non_camel_case_types)]
fn main() {}
trait foo_bar {
#![allow(non_camel_case_types)]
}