-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Support lint tool names in rustc command line options #86639
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
Show all changes
5 commits
Select commit
Hold shift + click to select a range
65b28a9
Add ui test for command line lints with tool names
eholk 1e0db4c
Parse tool name for command line lint options
eholk 8b4f538
Unify lint tool and lint name checking
eholk 5413d2e
Fix test case
eholk 4a83a93
Cleanup: unify lint name checking
eholk 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 |
---|---|---|
|
@@ -494,3 +494,6 @@ fn register_internals(store: &mut LintStore) { | |
], | ||
); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests; |
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,24 @@ | ||
use crate::context::parse_lint_and_tool_name; | ||
use rustc_span::{with_default_session_globals, Symbol}; | ||
|
||
#[test] | ||
fn parse_lint_no_tool() { | ||
with_default_session_globals(|| assert_eq!(parse_lint_and_tool_name("foo"), (None, "foo"))); | ||
} | ||
|
||
#[test] | ||
fn parse_lint_with_tool() { | ||
with_default_session_globals(|| { | ||
assert_eq!(parse_lint_and_tool_name("clippy::foo"), (Some(Symbol::intern("clippy")), "foo")) | ||
}); | ||
} | ||
|
||
#[test] | ||
fn parse_lint_multiple_path() { | ||
with_default_session_globals(|| { | ||
assert_eq!( | ||
parse_lint_and_tool_name("clippy::foo::bar"), | ||
(Some(Symbol::intern("clippy")), "foo::bar") | ||
) | ||
}); | ||
} |
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 @@ | ||
// compile-flags: -A known_tool::foo | ||
// check-pass | ||
|
||
#![feature(register_tool)] | ||
#![register_tool(known_tool)] | ||
|
||
fn main() {} |
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,4 @@ | ||
// compile-flags: -A unknown_tool::foo | ||
// error-pattern: unknown lint tool: `unknown_tool` | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/lint/command-line-register-unknown-lint-tool.stderr
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[E0602]: unknown lint tool: `unknown_tool` | ||
| | ||
= note: requested on the command line with `-A unknown_tool::foo` | ||
|
||
error[E0602]: unknown lint tool: `unknown_tool` | ||
| | ||
= note: requested on the command line with `-A unknown_tool::foo` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0602`. |
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.
Uh oh!
There was an error while loading. Please reload this page.