mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
Add tests for misplaced/duplicated pub in fn decl
This commit is contained in:
parent
b88a612d9a
commit
5cf96e70f4
5
src/test/ui/parser/issue-87694-duplicated-pub.rs
Normal file
5
src/test/ui/parser/issue-87694-duplicated-pub.rs
Normal file
@ -0,0 +1,5 @@
|
||||
pub const pub fn test() {}
|
||||
//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
|
||||
//~| NOTE expected one of `async`, `extern`, `fn`, or `unsafe`
|
||||
//~| HELP there is already a visibility, remove this one
|
||||
//~| NOTE explicit visibility first seen here
|
17
src/test/ui/parser/issue-87694-duplicated-pub.stderr
Normal file
17
src/test/ui/parser/issue-87694-duplicated-pub.stderr
Normal file
@ -0,0 +1,17 @@
|
||||
error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
|
||||
--> $DIR/issue-87694-duplicated-pub.rs:1:11
|
||||
|
|
||||
LL | pub const pub fn test() {}
|
||||
| ^^^
|
||||
| |
|
||||
| expected one of `async`, `extern`, `fn`, or `unsafe`
|
||||
| help: there is already a visibility, remove this one
|
||||
|
|
||||
note: explicit visibility first seen here
|
||||
--> $DIR/issue-87694-duplicated-pub.rs:1:1
|
||||
|
|
||||
LL | pub const pub fn test() {}
|
||||
| ^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
5
src/test/ui/parser/issue-87694-misplaced-pub.rs
Normal file
5
src/test/ui/parser/issue-87694-misplaced-pub.rs
Normal file
@ -0,0 +1,5 @@
|
||||
const pub fn test() {}
|
||||
//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
|
||||
//~| NOTE expected one of `async`, `extern`, `fn`, or `unsafe`
|
||||
//~| HELP visibility `pub` must come before `const`
|
||||
//~| SUGGESTION pub const
|
10
src/test/ui/parser/issue-87694-misplaced-pub.stderr
Normal file
10
src/test/ui/parser/issue-87694-misplaced-pub.stderr
Normal file
@ -0,0 +1,10 @@
|
||||
error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
|
||||
--> $DIR/issue-87694-misplaced-pub.rs:1:7
|
||||
|
|
||||
LL | const pub fn test() {}
|
||||
| ----- ^^^ expected one of `async`, `extern`, `fn`, or `unsafe`
|
||||
| |
|
||||
| help: visibility `pub` must come before `const`: `pub const`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user