Add tests for misplaced/duplicated pub in fn decl

This commit is contained in:
Alexis Bourget 2021-08-10 01:36:39 +02:00
parent b88a612d9a
commit 5cf96e70f4
4 changed files with 37 additions and 0 deletions

View 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

View 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

View 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

View 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