about summary refs log tree commit diff
path: root/src/test/incremental/thinlto
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-05-21 14:53:04 +0000
committerbors <bors@rust-lang.org>2021-05-21 14:53:04 +0000
commit029c3260585bbc16300ef572da439bbecd5c22da (patch)
treeaae4aeaeee6414302fbf85cb5bd61337d96da860 /src/test/incremental/thinlto
parent853f59354de710c9ca445e6568925d3416055c69 (diff)
parent6d4dc35882a55610e9da81237d62bea1c0c1634e (diff)
downloadrust-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