Fix broken span and related tests

This commit is contained in:
Alexis Bourget 2021-08-10 02:00:25 +02:00
parent 5cf96e70f4
commit 7bc8577d99
4 changed files with 17 additions and 7 deletions

View File

@ -1987,7 +1987,7 @@ impl<'a> Parser<'a> {
// There was no explicit visibility // There was no explicit visibility
if matches!(orig_vis.kind, VisibilityKind::Inherited) { if matches!(orig_vis.kind, VisibilityKind::Inherited) {
err.span_suggestion( err.span_suggestion(
sp, sp_start.to(self.prev_token.span),
&format!("visibility `{}` must come before `{}`", vs, snippet), &format!("visibility `{}` must come before `{}`", vs, snippet),
format!("{} {}", vs, snippet), format!("{} {}", vs, snippet),
Applicability::MachineApplicable, Applicability::MachineApplicable,

View File

@ -1,6 +1,9 @@
fn main() {} fn main() {}
extern "C" { extern "C" { //~ NOTE while parsing this item list starting here
pub pub fn foo(); pub pub fn foo();
//~^ ERROR expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found keyword `pub` //~^ ERROR expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found keyword `pub`
} //~| NOTE expected one of 9 possible tokens
//~| HELP there is already a visibility, remove this one
//~| NOTE explicit visibility first seen here
} //~ NOTE the item list ends here

View File

@ -7,10 +7,16 @@ LL | pub pub fn foo();
| ^^^ | ^^^
| | | |
| expected one of 9 possible tokens | expected one of 9 possible tokens
| help: visibility `pub` must come before `pub pub`: `pub pub pub` | help: there is already a visibility, remove this one
LL | ...
LL | } LL | }
| - the item list ends here | - the item list ends here
|
note: explicit visibility first seen here
--> $DIR/duplicate-visibility.rs:4:5
|
LL | pub pub fn foo();
| ^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,8 +2,9 @@ error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
--> $DIR/issue-87694-misplaced-pub.rs:1:7 --> $DIR/issue-87694-misplaced-pub.rs:1:7
| |
LL | const pub fn test() {} LL | const pub fn test() {}
| ----- ^^^ expected one of `async`, `extern`, `fn`, or `unsafe` | ------^^^
| | | | |
| | expected one of `async`, `extern`, `fn`, or `unsafe`
| help: visibility `pub` must come before `const`: `pub const` | help: visibility `pub` must come before `const`: `pub const`
error: aborting due to previous error error: aborting due to previous error