-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Detect async visibility wrong order, async pub
#76447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
// ignore-tidy-linelength | ||
|
||
fn main() {} | ||
|
||
extern "C" { | ||
pub pub fn foo(); | ||
//~^ ERROR visibility `pub` is not followed by an item | ||
//~| ERROR non-item in item list | ||
//~^ ERROR expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found keyword `pub` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
error: visibility `pub` is not followed by an item | ||
--> $DIR/duplicate-visibility.rs:4:5 | ||
| | ||
LL | pub pub fn foo(); | ||
| ^^^ the visibility | ||
| | ||
= help: you likely meant to define an item, e.g., `pub fn foo() {}` | ||
|
||
error: non-item in item list | ||
--> $DIR/duplicate-visibility.rs:4:9 | ||
error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found keyword `pub` | ||
--> $DIR/duplicate-visibility.rs:6:9 | ||
| | ||
LL | extern "C" { | ||
| - item list starts here | ||
| - while parsing this item list starting here | ||
LL | pub pub fn foo(); | ||
| ^^^ non-item starts here | ||
... | ||
| ^^^ | ||
| | | ||
| expected one of 9 possible tokens | ||
| help: visibility `pub` must come before `pub pub`: `pub pub pub` | ||
LL | | ||
LL | } | ||
| - item list ends here | ||
| - the item list ends here | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to previous error | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// edition:2018 | ||
|
||
mod t { | ||
async pub fn t() {} | ||
//~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub` | ||
//~| HELP visibility `pub` must come before `async` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub` | ||
--> $DIR/issue-76437-async.rs:4:11 | ||
| | ||
LL | async pub fn t() {} | ||
| ------^^^ | ||
| | | | ||
| | expected one of `extern`, `fn`, or `unsafe` | ||
| help: visibility `pub` must come before `async`: `pub async` | ||
|
||
error: aborting due to previous error | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// edition:2018 | ||
|
||
mod t { | ||
const async unsafe pub fn t() {} | ||
//~^ ERROR expected one of `extern` or `fn`, found keyword `pub` | ||
//~| HELP visibility `pub` must come before `const async unsafe` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: expected one of `extern` or `fn`, found keyword `pub` | ||
--> $DIR/issue-76437-const-async-unsafe.rs:4:24 | ||
| | ||
LL | const async unsafe pub fn t() {} | ||
| -------------------^^^ | ||
| | | | ||
| | expected one of `extern` or `fn` | ||
| help: visibility `pub` must come before `const async unsafe`: `pub const async unsafe` | ||
|
||
error: aborting due to previous error | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// edition:2018 | ||
|
||
mod t { | ||
const async pub fn t() {} | ||
//~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub` | ||
//~| HELP visibility `pub` must come before `const async` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub` | ||
--> $DIR/issue-76437-const-async.rs:4:17 | ||
| | ||
LL | const async pub fn t() {} | ||
| ------------^^^ | ||
| | | | ||
| | expected one of `extern`, `fn`, or `unsafe` | ||
| help: visibility `pub` must come before `const async`: `pub const async` | ||
|
||
error: aborting due to previous error | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// edition:2018 | ||
|
||
mod t { | ||
const pub fn t() {} | ||
//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` | ||
//~| HELP visibility `pub` must come before `const` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` | ||
--> $DIR/issue-76437-const.rs:4:11 | ||
| | ||
LL | const pub fn t() {} | ||
| ------^^^ | ||
| | | | ||
| | expected one of `async`, `extern`, `fn`, or `unsafe` | ||
| help: visibility `pub` must come before `const`: `pub const` | ||
|
||
error: aborting due to previous error | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// edition:2018 | ||
|
||
mod t { | ||
unsafe pub(crate) fn t() {} | ||
//~^ ERROR expected one of `extern` or `fn`, found keyword `pub` | ||
//~| HELP visibility `pub(crate)` must come before `unsafe` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: expected one of `extern` or `fn`, found keyword `pub` | ||
--> $DIR/issue-76437-pub-crate-unsafe.rs:4:12 | ||
| | ||
LL | unsafe pub(crate) fn t() {} | ||
| -------^^^------- | ||
| | | | ||
| | expected one of `extern` or `fn` | ||
| help: visibility `pub(crate)` must come before `unsafe`: `pub(crate) unsafe` | ||
|
||
error: aborting due to previous error | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// edition:2018 | ||
|
||
mod t { | ||
unsafe pub fn t() {} | ||
//~^ ERROR expected one of `extern` or `fn`, found keyword `pub` | ||
//~| HELP visibility `pub` must come before `unsafe` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: expected one of `extern` or `fn`, found keyword `pub` | ||
--> $DIR/issue-76437-unsafe.rs:4:12 | ||
| | ||
LL | unsafe pub fn t() {} | ||
| -------^^^ | ||
| | | | ||
| | expected one of `extern` or `fn` | ||
| help: visibility `pub` must come before `unsafe`: `pub unsafe` | ||
|
||
error: aborting due to previous error | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird, but at least users can know that visibility is duplicated. We could add a check but I probably don't want to do it in this patch.