diff options
| author | bors <bors@rust-lang.org> | 2023-12-05 19:10:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-05 19:10:09 +0000 |
| commit | 4a56563154f9c93708ec5ff9ba94d69a0203765e (patch) | |
| tree | 8dfe093f85188c22e506acd5f800640a18f0de8c /compiler/rustc_codegen_llvm/src/errors.rs | |
| parent | 42b017d625a886f39c813990fd91f2648ce4b06d (diff) | |
| parent | 512f302fd29fbc4bc4b920b4b22b1d1c49cc3917 (diff) | |
| download | rust-4a56563154f9c93708ec5ff9ba94d69a0203765e.tar.gz rust-4a56563154f9c93708ec5ff9ba94d69a0203765e.zip | |
Auto merge of #11900 - Enselic:needless-borrow-drop, r=Manishearth
needless_borrows_for_generic_args: Handle when field operand impl Drop
Before this fix, the lint had a false positive, namely when a reference was taken to a field when the field operand implements a custom Drop. The compiler will refuse to partially move a type that implements Drop, because that would put the type in a weird state.
## False Positive Example (Fixed)
```rs
struct CustomDrop(String);
impl Drop for CustomDrop {
fn drop(&mut self) {}
}
fn check_str<P: AsRef<str>>(_to: P) {}
fn test() {
let owner = CustomDrop(String::default());
check_str(&owner.0); // Don't lint. `owner` can't be partially moved because it impl Drop
}
```
changelog: [`needless_borrows_for_generic_args`]: Handle when field operand impl Drop
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
