Skip to content
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

Merged
merged 1 commit into from
Aug 12, 2018
Merged

Conversation

matthiaskrgr
Copy link
Member

(invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )

@rust-highfive
Copy link

r? @matklad

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link
Member

@dwijnand dwijnand left a 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.

@@ -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 {
Copy link
Member

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.

Copy link
Member Author

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.

@@ -1255,7 +1255,7 @@ pub fn basic_lib_manifest(name: &str) -> String {
)
}

pub fn path2url(p: PathBuf) -> Url {
pub fn path2url(p: &PathBuf) -> Url {
Copy link
Member

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>?

@@ -292,7 +292,7 @@ opt-level = 'foo'

let config = new_config(&[]);

assert_error(
assert_error(&
config.get::<toml::TomlProfile>("profile.dev").unwrap_err(),
Copy link
Member

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.

Copy link
Member Author

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 :/

@@ -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) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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()
 }

Copy link
Member

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<_>>()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

"\
[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()
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @matthiaskrgr!

@matthiaskrgr
Copy link
Member Author

Thanks for the reviews!

"2018" => { cmd.arg("-Wrust-2018-idioms"); }
_ => {}
}
if let "2018" = &edition[..] { cmd.arg("-Wrust-2018-idioms"); }
Copy link
Member

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" { ... }?

Copy link
Member Author

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! :)
@matthiaskrgr
Copy link
Member Author

CI is flakey again....

info: downloading component 'rust-std' for 'i686-unknown-linux-gnu'
error: component download failed for rust-std-i686-unknown-linux-gnu
info: caused by: could not download file from 'https://static.rust-lang.org/dist/2018-08-10/rust-std-beta-i686-unknown-linux-gnu.tar.xz' to '/home/travis/.rustup/downloads/e37304d2a8920fcefa8f7f9c8af01c7ba4fe7dddb0cdf0876554b61a1702ff80.partial'
info: caused by: error during download
info: caused by: [28] Timeout was reached (Connection timed out after 30001 milliseconds)

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 12, 2018

📌 Commit 8798bf0 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Aug 12, 2018

⌛ Testing commit 8798bf0 with merge ae97799...

bors added a commit that referenced this pull request Aug 12, 2018
fix a bunch of clippy warnings

 (invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )
@bors
Copy link
Contributor

bors commented Aug 12, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing ae97799 to master...

@bors bors merged commit 8798bf0 into rust-lang:master Aug 12, 2018
bors added a commit to rust-lang/rust that referenced this pull request Aug 15, 2018
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)
@matthiaskrgr matthiaskrgr deleted the clippy_2 branch September 3, 2018 08:06
@ehuss ehuss added this to the 1.30.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants