-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rollup of 2 pull requests #4625
Merged
Merged
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
Co-Authored-By: ecstatic-morse <ecstaticmorse@gmail.com>
Fix false-positive of redundant_clone and move to clippy::perf This PR introduces dataflow analysis to `redundant_clone` lint to filter out borrowed variables, which had been incorrectly detected. Depends on rust-lang/rust#64207. changelog: Moved `redundant_clone` lint to `perf` group # What this lint catches ## `clone`/`to_owned` ```rust let s = String::new(); let t = s.clone(); ``` ```rust // MIR _1 = String::new(); _2 = &_1; _3 = clone(_2); // (*) ``` We can turn this `clone` call into a move if 1. `_2` is the sole borrow of `_1` at the statement `(*)` 2. `_1` is not used hereafter ## `Deref` + type-specific `to_owned` method ```rust let s = std::path::PathBuf::new(); let t = s.to_path_buf(); ``` ```rust // MIR _1 = PathBuf::new(); _2 = &1; _3 = call deref(_2); _4 = _3; // Copies borrow StorageDead(_2); _5 = Path::to_path_buf(_4); // (*) ``` We can turn this `to_path_buf` call into a move if 1. `_3` `_4` are the sole borrow of `_1` at `(*)` 2. `_1` is not used hereafter # What this PR introduces 1. `MaybeStorageLive` that determines whether a local lives at a particular location 2. `PossibleBorrowerVisitor` that constructs [`TransitiveRelation`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/transitive_relation/struct.TransitiveRelation.html) of possible borrows, e.g. visiting `_2 = &1; _3 = &_2:` will result in `_3 -> _2 -> _1` relation. Then `_3` and `_2` will be counted as possible borrowers of `_1` in the sole-borrow analysis above.
Allow casts from the result of `abs` to unsigned changelog: Allow casts from the result of `abs` to unsigned in `cast_sign_loss` Fixes rust-lang#4605
@bors r+ |
📌 Commit 19c58d2 has been approved by |
💔 Test failed - checks-travis |
@bors retry (changelog: none) |
☀️ Test successful - checks-travis, status-appveyor |
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.
Successful merges:
abs
to unsigned #4614 (Allow casts from the result ofabs
to unsigned)Failed merges:
changelog: none
r? @ghost