Skip to content

Commit 7bc8577

Browse files
committed
Fix broken span and related tests
1 parent 5cf96e7 commit 7bc8577

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

compiler/rustc_parse/src/parser/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ impl<'a> Parser<'a> {
19871987
// There was no explicit visibility
19881988
if matches!(orig_vis.kind, VisibilityKind::Inherited) {
19891989
err.span_suggestion(
1990-
sp,
1990+
sp_start.to(self.prev_token.span),
19911991
&format!("visibility `{}` must come before `{}`", vs, snippet),
19921992
format!("{} {}", vs, snippet),
19931993
Applicability::MachineApplicable,
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
fn main() {}
22

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

src/test/ui/parser/duplicate-visibility.stderr

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ LL | pub pub fn foo();
77
| ^^^
88
| |
99
| expected one of 9 possible tokens
10-
| help: visibility `pub` must come before `pub pub`: `pub pub pub`
11-
LL |
10+
| help: there is already a visibility, remove this one
11+
...
1212
LL | }
1313
| - the item list ends here
14+
|
15+
note: explicit visibility first seen here
16+
--> $DIR/duplicate-visibility.rs:4:5
17+
|
18+
LL | pub pub fn foo();
19+
| ^^^
1420

1521
error: aborting due to previous error
1622

src/test/ui/parser/issue-87694-misplaced-pub.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
22
--> $DIR/issue-87694-misplaced-pub.rs:1:7
33
|
44
LL | const pub fn test() {}
5-
| ----- ^^^ expected one of `async`, `extern`, `fn`, or `unsafe`
6-
| |
5+
| ------^^^
6+
| | |
7+
| | expected one of `async`, `extern`, `fn`, or `unsafe`
78
| help: visibility `pub` must come before `const`: `pub const`
89

910
error: aborting due to previous error

0 commit comments

Comments
 (0)