-
Notifications
You must be signed in to change notification settings - Fork 37
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 rustc and clippy warnings #247
Open
taiki-e
wants to merge
15
commits into
gnzlbg:master
Choose a base branch
from
taiki-e:warn
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
master is currently broken because platforms crate yanked the old versions. ``` cargo install -f --path . Installing cargo-asm v0.1.17 (/Users/taiki/projects/cargo-asm) Updating crates.io index error: failed to compile `cargo-asm v0.1.17 (/Users/taiki/projects/cargo-asm)`, intermediate artifacts can be found at `/Users/taiki/projects/cargo-asm/target` Caused by: failed to select a version for the requirement `platforms = "^0.2"` candidate versions found which didn't match: 2.0.0, 1.1.0, 1.0.3, ... location searched: crates.io index required by package `cargo-asm v0.1.17 (/Users/taiki/projects/cargo-asm) ```
```text warning: unnecessary braces around block return value --> src/options.rs:12:9 | 12 | { ::parking_lot::RwLock::new(read()) }; | ^^ ^^ | = note: `#[warn(unused_braces)]` on by default help: remove these braces | 12 - { ::parking_lot::RwLock::new(read()) }; 12 + ::parking_lot::RwLock::new(read()); | ```
```text warning: unused return value of `Path::parent` that must be used --> src/rust.rs:176:5 | 176 | sysroot.parent(); | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_must_use)]` on by default ```
```text warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/llvmir.rs:166:62 | 166 | crate::demangle::demangle(&mangled_name, &target) | ^^^^^^^ help: change this to: `target` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow ```
```text warning: this import is redundant --> src/demangle.rs:5:1 | 5 | use rustc_demangle; | ^^^^^^^^^^^^^^^^^^^ help: remove it entirely | = note: `#[warn(clippy::single_component_path_imports)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports ```
```text warning: redundant clone --> src/target.rs:114:42 | 114 | ... return target.to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use --> src/target.rs:114:36 | 114 | ... return target.to_owned(); | ^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone ```
```text arning: unneeded `return` statement --> src/display.rs:304:9 | 304 | return; | ^^^^^^^ help: remove `return` | = note: `#[warn(clippy::needless_return)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return ```
```text warning: this loop could be written as a `for` loop --> src/asm/parse.rs:207:17 | 207 | while let Some(l) = line_iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for l in line_iter.by_ref()` | = note: `#[warn(clippy::while_let_on_iterator)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator ```
```text warning: manual implementation of `Option::map` --> src/display.rs:252:31 | 252 | let function_file_index = if let Some(loc) = f.loc { | _______________________________^ 253 | | Some(loc.file_index) 254 | | } else { 255 | | None 256 | | }; | |_____^ help: try this: `f.loc.map(|loc| loc.file_index)` | = note: `#[warn(clippy::manual_map)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map ```
```text warning: field assignment outside of initializer for an instance created with Default::default() --> src/target.rs:26:9 | 26 | ti.triple = triple; | ^^^^^^^^^^^^^^^^^^^ | = note: requested on the command line with `-W clippy::field-reassign-with-default` note: consider initializing the variable with `target::TargetInfo { triple: triple }` and removing relevant reassignments --> src/target.rs:25:9 | 25 | let mut ti = TargetInfo::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default ```
```text warning: this `if let` can be collapsed into the outer `if let` --> src/path.rs:19:13 | 19 | / if let ::std::path::Component::RootDir = next_sp { 20 | | if !cfg!(target_os = "windows") { 21 | | next_sub_path = sub_path_iter.next(); 22 | | } 23 | | } | |_____________^ | = note: requested on the command line with `-W clippy::collapsible-match` help: the outer pattern can be modified to include the inner pattern --> src/path.rs:18:21 | 18 | if let Some(next_sp) = next_sub_path { | ^^^^^^^ replace this binding 19 | if let ::std::path::Component::RootDir = next_sp { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ with this pattern = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match warning: this `if let` can be collapsed into the outer `if let` --> src/path.rs:63:17 | 63 | / if let ::std::path::Component::RootDir = next_sp { 64 | | if !cfg!(target_os = "windows") { 65 | | next_sub_path = sub_path_iter.next(); 66 | | } 67 | | } | |_________________^ | help: the outer pattern can be modified to include the inner pattern --> src/path.rs:62:25 | 62 | if let Some(next_sp) = next_sub_path { | ^^^^^^^ replace this binding 63 | if let ::std::path::Component::RootDir = next_sp { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ with this pattern = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match warning: this `if let` can be collapsed into the outer `if let` --> src/rust.rs:17:13 | 17 | / if let Some(ref l) = l { 18 | | return Some(l.clone()); 19 | | } | |_____________^ | help: the outer pattern can be modified to include the inner pattern --> src/rust.rs:16:21 | 16 | if let Some(l) = self.lines.get(&line_idx) { | ^ replace this binding 17 | if let Some(ref l) = l { | ^^^^^^^^^^^ with this pattern = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match ```
```text warning: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent --> src/demangle.rs:23:9 | 23 | n.split("@plt").nth(0).unwrap().to_string() | ^^^^^^^^^^^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `n.split("@plt").next()` | = note: `#[warn(clippy::iter_nth_zero)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero ```
```text warning: manual `RangeInclusive::contains` implementation --> src/demangle.rs:18:5 | 18 | byte >= b'0' && byte <= b'9' || byte >= b'a' && byte <= b'f' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `(b'0'..=b'9').contains(&byte)` | = note: `#[warn(clippy::manual_range_contains)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains warning: manual `RangeInclusive::contains` implementation --> src/demangle.rs:18:37 | 18 | byte >= b'0' && byte <= b'9' || byte >= b'a' && byte <= b'f' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `(b'a'..=b'f').contains(&byte)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains ```
```text warning: name `ATT` contains a capitalized acronym --> src/asm/mod.rs:10:5 | 10 | ATT, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Att` | = note: `#[warn(clippy::upper_case_acronyms)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms ```
False positive has been fixed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Basically, each commit corresponds to one warning each.
Each commit message contains the details of the warning.
(the first commit is from #245 -- without it, master fails to build)