forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#86639 - eholk:lint-tool, r=petrochenkov
Support lint tool names in rustc command line options When rustc is running without a lint tool such as clippy enabled, options for lints such as `clippy::foo` are meant to be ignored. This was already working for those specified by attrs, such as `#![allow(clippy::foo)]`, but this did not work for command line arguments like `-A clippy::foo`. This PR fixes that issue. Note that we discovered this issue while discussing rust-lang/cargo#5034. Fixes rust-lang#86628.
- Loading branch information
Showing
7 changed files
with
123 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -497,3 +497,6 @@ fn register_internals(store: &mut LintStore) { | |
], | ||
); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests; |
This file contains 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 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 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 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`. |