- Notifications
You must be signed in to change notification settings - Fork 1.8k
clippy-driver: pass all args to rustc if --rustc is present #5178
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
Conversation
src/driver.rs Outdated
| // pass all succeeding args to rustc | ||
| let args_for_rustc = &orig_args[2..].to_vec(); | ||
| | ||
| let exitstatus = Command::new("rustc") |
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.
No, this doesn't help. rustc isn't necessarily in the path, and even if it were, doesn't necessarily have anything to do with the version of rustc clippy-driver was built against. If I wanted to know the version of the rustc executable, I could just run rustc --version.
| What we could test for starters, is if the first argument is |
| I just realized, that the Lines 353 to 355 in 06f0ab0
|
| What do you think about |
| This would be the patch for adding this #5178 (comment): diff --git a/src/driver.rs b/src/driver.rs index 097b796e..b280169d 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -299,6 +299,12 @@ pub fn main() { rustc_driver::catch_fatal_errors(move || { let mut orig_args: Vec<String> = env::args().collect(); + if let Some(pos) = orig_args.iter().position(|arg| arg == "--rustc") { + orig_args.remove(pos); + orig_args[0] = "rustc".to_string(); + return rustc_driver::run_compiler(&orig_args, &mut DefaultCallbacks, None, None); + } + if orig_args.iter().any(|a| a == "--version" || a == "-V") { let version_info = rustc_tools_util::get_version_info!(); println!("{}", version_info); |
95b5d86 to a733556 Compare
Urgh that sucks... |
| The patch I posted in #5178 (comment) takes care of this and everything will be passed to |
| ☔ The latest upstream changes (presumably #5608) made this pull request unmergeable. Please resolve the merge conflicts. |
| Friendly ping @matthiaskrgr. Do you think we can/should move forward with this? |
| looks like the |
a733556 to 857ae23 Compare | Can you add a test script, that compares output of some |
857ae23 to 26b144f Compare | Added test for |
| This test would also be nice to have: echo "fn main() {}" > tmp.rs clippy-driver --rustc tmp.rsand maybe a test where |
| Hmm, |
26b144f to 85edeb8 Compare 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.
Hmm,
clippy-driver --version --rustcprintsrustc --version, this is a bug, right?
Nope that is the expected behavior. When the --rustc arg is passed to the clippy-driver everything should be forwarded to the rustc used by Clippy. This is consistent behavior.
Can you add the --rustc arg to the Clippy help:
Lines 200 to 210 in 67ec96c
| fn display_help() { | |
| println!( | |
| "\ | |
| Checks a package to catch common mistakes and improve your Rust code. | |
| Usage: | |
| cargo clippy [options] [--] [<opts>...] | |
| Common options: | |
| -h, --help Print this message | |
| -V, --version Print version info and exit |
d484f44 to 1c32cf3 Compare fe4c7aa to f33b82d Compare | CI was failing because I was testing against a file that I forgot to git-commit... 😆 |
f33b82d to 7a62380 Compare | @bors r+ rollup |
| 📌 Commit 7a62380 has been approved by |
| 🌲 The tree is currently closed for pull requests below priority 10, this pull request will be tested once the tree is reopened |
Rollup of 9 pull requests Successful merges: - #5178 (clippy-driver: pass all args to rustc if --rustc is present) - #5705 (Downgrade unnested_or_patterns to pedantic) - #5709 (Fix ICE in consts::binop) - #5710 (typo) - #5712 (Remove `bar` from blacklisted names) - #5713 (Use lints in Clippy that are enabled in rustc bootstrap) - #5716 (Fix typo in wildcard_imports) - #5724 (redundant_pattern_matching: avoid non-`const fn` calls in const contexts) - #5726 (Fix typo) Failed merges: r? @ghost changelog: rollup
changelog: clippy-driver: pass all args to rustc if --rustc is present