-
-
Notifications
You must be signed in to change notification settings - Fork 3k
initial working version of cargo fix --clippy #7069
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 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c057a06
initial working version of cargo fix --clippy
yaahc 0a943be
initial attempt at argument passthrough
yaahc 4f64aaa
nailed it
yaahc c492205
appease cargo fmt
yaahc 6b233cb
rename passthru arg to make it clearer
yaahc 3a9ac3e
initial clippy tests
yaahc 65afb3f
use json instead of shitty hack
yaahc ad909ac
add warning to cargo incase clippy is missing
yaahc d076f44
allow clippy path override via env variable
yaahc 4ff4c1f
Update src/bin/cargo/commands/fix.rs
yaahc 85ba8e9
Update src/cargo/util/config.rs
yaahc 6fb65f1
some changes, ill clean this up in a hot sec
yaahc 8b1f599
back in tip top shape
yaahc fefcca1
it was still a little broken
yaahc b9f3c16
Fix --clippy arg for fix
yaahc abd9149
centralize diagnostic server stuff
yaahc 46b48f6
implement primary unit rustc
yaahc 1818096
deduplicate code
yaahc c0c6729
missing wiring
yaahc f3d3318
minor fixes
yaahc 03feb61
apply the correct changes
yaahc 22b430d
dont overuse the wrapper
yaahc 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
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 |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| use crate::support::{is_nightly, process, project}; | ||
|
|
||
| #[cargo_test] | ||
| fn clippy() { | ||
|
yaahc marked this conversation as resolved.
Outdated
yaahc marked this conversation as resolved.
Outdated
|
||
| if !is_nightly() { | ||
| // --json-rendered is unstable | ||
| eprintln!("skipping test: requires nightly"); | ||
| return; | ||
| } | ||
| if let Err(e) = process("clippy-driver").arg("-V").exec_with_output() { | ||
| eprintln!("clippy-driver not available, skipping clippy test"); | ||
| eprintln!("{:?}", e); | ||
| return; | ||
| } | ||
|
|
||
| // Caching clippy output. | ||
| // This is just a random clippy lint (assertions_on_constants) that | ||
| // hopefully won't change much in the future. | ||
| let p = project() | ||
| .file("src/lib.rs", "pub fn f() { assert!(true); }") | ||
| .build(); | ||
|
|
||
| p.cargo("clippy-preview -Zunstable-options -Zcache-messages") | ||
| .masquerade_as_nightly_cargo() | ||
| .with_stderr_contains("[..]assert!(true)[..]") | ||
| .run(); | ||
|
|
||
| // Again, reading from the cache. | ||
| p.cargo("clippy-preview -Zunstable-options -Zcache-messages") | ||
| .masquerade_as_nightly_cargo() | ||
| .with_stderr_contains("[..]assert!(true)[..]") | ||
| .run(); | ||
|
|
||
| // FIXME: Unfortunately clippy is sharing the same hash with check. This | ||
| // causes the cache to be reused when it shouldn't. | ||
|
yaahc marked this conversation as resolved.
Outdated
|
||
| p.cargo("check -Zcache-messages") | ||
| .masquerade_as_nightly_cargo() | ||
| .with_stderr_contains("[..]assert!(true)[..]") // This should not be here. | ||
| .run(); | ||
| } | ||
|
|
||
| #[cargo_test] | ||
| fn fix_with_clippy() { | ||
| if !is_nightly() { | ||
| // fix --clippy is unstable | ||
| eprintln!("skipping test: requires nightly"); | ||
| return; | ||
| } | ||
|
|
||
| if let Err(e) = process("clippy-driver").arg("-V").exec_with_output() { | ||
|
yaahc marked this conversation as resolved.
Outdated
|
||
| eprintln!("clippy-driver not available, skipping clippy test"); | ||
| eprintln!("{:?}", e); | ||
| return; | ||
| } | ||
|
|
||
| let p = project() | ||
| .file( | ||
| "src/lib.rs", | ||
| " | ||
| pub fn foo() { | ||
| let mut v = Vec::<String>::new(); | ||
| let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ||
| } | ||
| ", | ||
| ) | ||
| .build(); | ||
|
|
||
| let stderr = "\ | ||
| [CHECKING] foo v0.0.1 ([..]) | ||
| [FIXING] src/lib.rs (1 fix) | ||
| [FINISHED] [..] | ||
| "; | ||
|
|
||
| p.cargo("fix -Zunstable-options --clippy --allow-no-vcs") | ||
| .masquerade_as_nightly_cargo() | ||
| .with_stderr(stderr) | ||
| .with_stdout("") | ||
| .run(); | ||
|
yaahc marked this conversation as resolved.
Outdated
|
||
| } | ||
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
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.