diff options
| author | bors <bors@rust-lang.org> | 2020-10-06 06:59:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-06 06:59:33 +0000 |
| commit | c9fdeef643329266cedb67369328795c4abb7740 (patch) | |
| tree | 04e575fde9c7c9ca78d004a116a2756bd71a3f7b /compiler/rustc_codegen_llvm/src/builder.rs | |
| parent | 3239b46e920be50dd486d7565db070598aa65a46 (diff) | |
| parent | 9365660a2fc57210996df733efe468019c671b2f (diff) | |
| download | rust-c9fdeef643329266cedb67369328795c4abb7740.tar.gz rust-c9fdeef643329266cedb67369328795c4abb7740.zip | |
Auto merge of #6078 - ebroto:unnecessary_sort_by_take_2, r=phansch
unnecessary sort by: avoid dereferencing the suggested closure parameter This change tries to simplify the solution for problematic cases but is less restrictive than #6006. * We can't dereference shared references to non-Copy types, so the new suggestion does not do that. Note that this implies that the suggested closure parameter will be a reference. * We can't take a reference to the closure parameter in the returned key, so we don't lint in those cases. This can happen either because the key borrows from the parameter (e.g. `|a| a.borrows()`), or because we suggest `|a| Reverse(a)`. If we did we would hit this error: ``` error: lifetime may not live long enough --> /home/ebroto/src/ebroto-clippy/tests/ui/unnecessary_sort_by.fixed:19:25 | 19 | vec.sort_by_key(|b| Reverse(b)); | -- ^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | || | |return type of closure is Reverse<&'2 isize> | has type `&'1 isize` error: aborting due to previous error ``` Note that Clippy does not currently have the (MIR-based) machinery necessary to check that what is borrowed is actually the closure parameter. changelog: [`unnecessary_sort_by`]: avoid dereferencing the suggested closure parameter Fixes #6001
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
0 files changed, 0 insertions, 0 deletions
