parser: tweak unmatched wording
This commit is contained in:
parent
d446c73e6a
commit
ab84914fe4
@ -119,17 +119,18 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
let vs = pprust::vis_to_string(&vis);
|
||||
let vs = vs.trim_end();
|
||||
self.struct_span_err(vis.span, &format!("unmatched visibility `{}`", vs))
|
||||
.span_label(vis.span, "the unmatched visibility")
|
||||
self.struct_span_err(vis.span, &format!("visibility `{}` not followed by an item", vs))
|
||||
.span_label(vis.span, "the visibility")
|
||||
.help(&format!("you likely meant to define an item, e.g., `{} fn foo() {{}}`", vs))
|
||||
.emit();
|
||||
}
|
||||
|
||||
/// Error in-case a `default` was parsed but no item followed.
|
||||
fn error_on_unmatched_defaultness(&self, def: Defaultness) {
|
||||
if let Defaultness::Default(span) = def {
|
||||
self.struct_span_err(span, "unmatched `default`")
|
||||
.span_label(span, "the unmatched `default`")
|
||||
if let Defaultness::Default(sp) = def {
|
||||
self.struct_span_err(sp, "`default` not followed by an item")
|
||||
.span_label(sp, "the `default` qualifier")
|
||||
.note("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ fn main() {}
|
||||
trait Foo {
|
||||
default!(); //~ ERROR cannot find macro `default` in this scope
|
||||
default do
|
||||
//~^ ERROR unmatched `default`
|
||||
//~^ ERROR `default` not followed by an item
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
||||
@ -11,6 +11,6 @@ struct S;
|
||||
impl S {
|
||||
default!(); //~ ERROR cannot find macro `default` in this scope
|
||||
default do
|
||||
//~^ ERROR unmatched `default`
|
||||
//~^ ERROR `default` not followed by an item
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
error: unmatched `default`
|
||||
error: `default` not followed by an item
|
||||
--> $DIR/default-unmatched-assoc.rs:5:5
|
||||
|
|
||||
LL | default do
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
| ^^^^^^^ the `default` qualifier
|
||||
|
|
||||
= note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default-unmatched-assoc.rs:5:13
|
||||
@ -16,11 +18,13 @@ LL | default do
|
||||
LL | }
|
||||
| - item list ends here
|
||||
|
||||
error: unmatched `default`
|
||||
error: `default` not followed by an item
|
||||
--> $DIR/default-unmatched-assoc.rs:13:5
|
||||
|
|
||||
LL | default do
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
| ^^^^^^^ the `default` qualifier
|
||||
|
|
||||
= note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default-unmatched-assoc.rs:13:13
|
||||
|
@ -3,6 +3,6 @@ fn main() {}
|
||||
extern "C" {
|
||||
default!(); //~ ERROR cannot find macro `default` in this scope
|
||||
default do
|
||||
//~^ ERROR unmatched `default`
|
||||
//~^ ERROR `default` not followed by an item
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
error: unmatched `default`
|
||||
error: `default` not followed by an item
|
||||
--> $DIR/default-unmatched-extern.rs:5:5
|
||||
|
|
||||
LL | default do
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
| ^^^^^^^ the `default` qualifier
|
||||
|
|
||||
= note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default-unmatched-extern.rs:5:13
|
||||
|
@ -1,6 +1,6 @@
|
||||
mod foo {
|
||||
default!(); // OK.
|
||||
default do
|
||||
//~^ ERROR unmatched `default`
|
||||
//~^ ERROR `default` not followed by an item
|
||||
//~| ERROR expected item, found reserved keyword `do`
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
error: unmatched `default`
|
||||
error: `default` not followed by an item
|
||||
--> $DIR/default-unmatched.rs:3:5
|
||||
|
|
||||
LL | default do
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
| ^^^^^^^ the `default` qualifier
|
||||
|
|
||||
= note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
|
||||
|
||||
error: expected item, found reserved keyword `do`
|
||||
--> $DIR/default-unmatched.rs:3:13
|
||||
|
@ -20,7 +20,7 @@ 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 unmatched `default`
|
||||
//~^ ERROR `default` not followed by an item
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
error: unmatched `default`
|
||||
error: `default` not followed by an item
|
||||
--> $DIR/default.rs:22:5
|
||||
|
|
||||
LL | default pub fn foo<T: Default>() -> T { T::default() }
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
| ^^^^^^^ the `default` qualifier
|
||||
|
|
||||
= note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default.rs:22:13
|
||||
|
@ -2,6 +2,6 @@ fn main() {}
|
||||
|
||||
extern {
|
||||
pub pub fn foo();
|
||||
//~^ ERROR unmatched visibility `pub`
|
||||
//~^ ERROR visibility `pub` not followed by an item
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: unmatched visibility `pub`
|
||||
error: visibility `pub` not followed by an item
|
||||
--> $DIR/duplicate-visibility.rs:4:5
|
||||
|
|
||||
LL | pub pub fn foo();
|
||||
| ^^^ the unmatched visibility
|
||||
| ^^^ the visibility
|
||||
|
|
||||
= help: you likely meant to define an item, e.g., `pub fn foo() {}`
|
||||
|
||||
|
@ -7,4 +7,4 @@ impl ?Sized for Type {} //~ ERROR expected a trait, found type
|
||||
impl ?Sized for .. {} //~ ERROR expected a trait, found type
|
||||
|
||||
default unsafe FAIL //~ ERROR expected item, found keyword `unsafe`
|
||||
//~^ ERROR unmatched `default`
|
||||
//~^ ERROR `default` not followed by an item
|
||||
|
@ -22,11 +22,13 @@ error: expected a trait, found type
|
||||
LL | impl ?Sized for .. {}
|
||||
| ^^^^^^
|
||||
|
||||
error: unmatched `default`
|
||||
error: `default` not followed by an item
|
||||
--> $DIR/impl-parsing.rs:9:1
|
||||
|
|
||||
LL | default unsafe FAIL
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
| ^^^^^^^ the `default` qualifier
|
||||
|
|
||||
= note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
|
||||
|
||||
error: expected item, found keyword `unsafe`
|
||||
--> $DIR/impl-parsing.rs:9:9
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct S;
|
||||
|
||||
impl S {
|
||||
pub //~ ERROR unmatched visibility `pub`
|
||||
pub //~ ERROR visibility `pub` not followed by an item
|
||||
} //~ ERROR non-item in item list
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: unmatched visibility `pub`
|
||||
error: visibility `pub` not followed by an item
|
||||
--> $DIR/issue-41155.rs:4:5
|
||||
|
|
||||
LL | pub
|
||||
| ^^^ the unmatched visibility
|
||||
| ^^^ the visibility
|
||||
|
|
||||
= help: you likely meant to define an item, e.g., `pub fn foo() {}`
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
pub(crate) () fn foo() {} //~ unmatched visibility
|
||||
pub(crate) () fn foo() {} //~ ERROR visibility `pub(crate)` not followed by an item
|
||||
//~^ ERROR expected item, found `(`
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: unmatched visibility `pub(crate)`
|
||||
error: visibility `pub(crate)` not followed by an item
|
||||
--> $DIR/pub-restricted-error-fn.rs:1:1
|
||||
|
|
||||
LL | pub(crate) () fn foo() {}
|
||||
| ^^^^^^^^^^ the unmatched visibility
|
||||
| ^^^^^^^^^^ the visibility
|
||||
|
|
||||
= help: you likely meant to define an item, e.g., `pub(crate) fn foo() {}`
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user