Skip to content

Commit 5cf96e7

Browse files
committed
Add tests for misplaced/duplicated pub in fn decl
1 parent b88a612 commit 5cf96e7

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub const pub fn test() {}
2+
//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
3+
//~| NOTE expected one of `async`, `extern`, `fn`, or `unsafe`
4+
//~| HELP there is already a visibility, remove this one
5+
//~| NOTE explicit visibility first seen here
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
2+
--> $DIR/issue-87694-duplicated-pub.rs:1:11
3+
|
4+
LL | pub const pub fn test() {}
5+
| ^^^
6+
| |
7+
| expected one of `async`, `extern`, `fn`, or `unsafe`
8+
| help: there is already a visibility, remove this one
9+
|
10+
note: explicit visibility first seen here
11+
--> $DIR/issue-87694-duplicated-pub.rs:1:1
12+
|
13+
LL | pub const pub fn test() {}
14+
| ^^^
15+
16+
error: aborting due to previous error
17+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const pub fn test() {}
2+
//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
3+
//~| NOTE expected one of `async`, `extern`, `fn`, or `unsafe`
4+
//~| HELP visibility `pub` must come before `const`
5+
//~| SUGGESTION pub const
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
2+
--> $DIR/issue-87694-misplaced-pub.rs:1:7
3+
|
4+
LL | const pub fn test() {}
5+
| ----- ^^^ expected one of `async`, `extern`, `fn`, or `unsafe`
6+
| |
7+
| help: visibility `pub` must come before `const`: `pub const`
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)