-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix a bunch of clippy warnings #5876
Conversation
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
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.
Nice! A few (simple) comments and questions from me.
tests/testsuite/profile_overrides.rs
Outdated
@@ -202,7 +202,7 @@ fn profile_override_bad_settings() { | |||
), | |||
("overrides = {}", "Profile overrides cannot be nested."), | |||
]; | |||
for &(ref snippet, ref expected) in bad_values.iter() { | |||
for &(ref snippet, ref expected) in &bad_values { |
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.
There's a preference in Cargo to use the former over the latter.
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.
Ok, I added a allow(explicit_iter_loop)
to testsuites main.rs.
tests/testsuite/support/mod.rs
Outdated
@@ -1255,7 +1255,7 @@ pub fn basic_lib_manifest(name: &str) -> String { | |||
) | |||
} | |||
|
|||
pub fn path2url(p: PathBuf) -> Url { | |||
pub fn path2url(p: &PathBuf) -> Url { |
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.
Would the use-cases stay simple if this took a p: P
where P: AsRef<Path>
?
tests/testsuite/config.rs
Outdated
@@ -292,7 +292,7 @@ opt-level = 'foo' | |||
|
|||
let config = new_config(&[]); | |||
|
|||
assert_error( | |||
assert_error(& | |||
config.get::<toml::TomlProfile>("profile.dev").unwrap_err(), |
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.
Is this formatting common? Looks strange to me.
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.
Ah oops, fallout of lazy search and replace :/
tests/testsuite/config.rs
Outdated
@@ -68,7 +68,7 @@ fn new_config(env: &[(&str, &str)]) -> Config { | |||
config | |||
} | |||
|
|||
fn assert_error(error: CargoError, msgs: &str) { | |||
fn assert_error(error: &CargoError, msgs: &str) { |
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.
Similarly, would using AsRef<CargoError>
avoid changing all the existing use sites?
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 I could not get these and the path2url to work with AsRef, but I can revert the change altogether if you want.
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.
I'll take a swing at it.
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.
Here's the change that worked for me on path2url
:
-pub fn path2url(p: PathBuf) -> Url {
- Url::from_file_path(&*p).ok().unwrap()
+pub fn path2url<P: AsRef<Path>>(p: P) -> Url {
+ Url::from_file_path(p).ok().unwrap()
}
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.
For assert_error
:
use cargo::CargoError;
use support::{execs, lines_match, paths, project};
use support::hamcrest::assert_that;
+use std::borrow::Borrow;
use std::collections;
use std::fs;
-fn assert_error(error: CargoError, msgs: &str) {
+fn assert_error<E: Borrow<CargoError>>(error: E, msgs: &str) {
let causes = error
+ .borrow()
.iter_chain()
.map(|e| e.to_string())
.collect::<Vec<_>>()
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.
Thanks a lot!
tests/testsuite/build.rs
Outdated
"\ | ||
[COMPILING] present_dep v1.2.3 | ||
[COMPILING] bar v0.1.0 ([..]) | ||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" | ||
)), | ||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]".to_string() |
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.
these to_string()
's aren't necessary as with_stderr
takes S: ToString
, and thus can take a string slice.
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.
Thanks, updated.
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.
LGTM. Thanks @matthiaskrgr!
Thanks for the reviews! |
src/cargo/ops/fix.rs
Outdated
"2018" => { cmd.arg("-Wrust-2018-idioms"); } | ||
_ => {} | ||
} | ||
if let "2018" = &edition[..] { cmd.arg("-Wrust-2018-idioms"); } |
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.
Could this just be if edition == "2018" { ... }
?
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.
Indeed, updated accordingly.
…s --all-features -- --cap-lints warn ) Special thanks to dwijnand for helping me with this! :)
CI is flakey again....
|
@bors: r+ |
📌 Commit 8798bf0 has been approved by |
fix a bunch of clippy warnings (invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )
☀️ Test successful - status-appveyor, status-travis |
Update cargo - Update transitioning url (rust-lang/cargo#5889) - Resolve some clippy lint warnings (rust-lang/cargo#5884) - Don't kill child processes on normal exit on Windows (rust-lang/cargo#5887) - fix a bunch of clippy warnings (rust-lang/cargo#5876) - Add support for rustc's --error-format short (rust-lang/cargo#5879) - Support JSON with rustdoc. (rust-lang/cargo#5878) - Fix rustfmt instructions in CONTRIBUTING.md (rust-lang/cargo#5880) - Allow `cargo run` in workspaces. (rust-lang/cargo#5877) - Change target filters in workspaces. (rust-lang/cargo#5873) - Improve verbose console and log for finding git repo in package check (rust-lang/cargo#5858) - Meta rename (rust-lang/cargo#5871) - fetch: skip target tests when cross_compile is disabled (rust-lang/cargo#5870) - Fully capture rustc and rustdoc output when -Zcompile-progress is passed (rust-lang/cargo#5862) - Fix test --example docs. (rust-lang/cargo#5867) - Add a feature to build a vendored OpenSSL (rust-lang/cargo#5865)
(invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )