diff options
| author | bors <bors@rust-lang.org> | 2021-05-21 14:53:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-21 14:53:04 +0000 |
| commit | 029c3260585bbc16300ef572da439bbecd5c22da (patch) | |
| tree | aae4aeaeee6414302fbf85cb5bd61337d96da860 /src/test/incremental/thinlto | |
| parent | 853f59354de710c9ca445e6568925d3416055c69 (diff) | |
| parent | 6d4dc35882a55610e9da81237d62bea1c0c1634e (diff) | |
| download | rust-029c3260585bbc16300ef572da439bbecd5c22da.tar.gz rust-029c3260585bbc16300ef572da439bbecd5c22da.zip | |
Auto merge of #7105 - Jarcho:needless_borrow_pat, r=camsteffen
fix `needless_borrow` suggestion
fixes: #2610
While I'm working on this, should needless_borrow be split into two? One lint for expressions and another for patterns. In expression it only lints when the compiler inserts a dereference, but for patterns it's whenever a double reference is created. I think at least the case where a double reference is needed should be split into a new lint as it's not 'needless', it can just be done without a ref binding.
For illustration:
```rust
fn foo(x: &&str) {}
match Some("test") {
// ref binding is useless here
Some(ref x) => *x,
_ => (),
}
match Some("test") {
// ref binding is useless here
Some(ref x) => x.len(),
_ => (),
}
match Some("test") {
// double reference is needed, but could be `Some(x) => foo(&x)`
Some(ref x) => foo(x),
_ => (),
}
```
changelog: Improve the suggestion for `needless_borrow` in patterns to change all usage sites as needed.
changelog: Add lint `ref_binding_to_reference`
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions
