Auto merge of #11161 - c410-f3r:let-chain, r=dswij

[significant_drop_tightening] Fix #11160

Fix #11160

```
changelog: [`significant_drop_tightening`]: Ignore literals in function returns
```
This commit is contained in:
bors 2023-07-20 07:28:08 +00:00
commit d764a0ea5e
4 changed files with 24 additions and 7 deletions

View file

@ -51,6 +51,13 @@ pub fn issue_11128() {
}
}
pub fn issue_11160() -> bool {
let mutex = Mutex::new(1i32);
let lock = mutex.lock().unwrap();
let _ = lock.abs();
true
}
pub fn path_return_can_be_ignored() -> i32 {
let mutex = Mutex::new(1);
let lock = mutex.lock().unwrap();

View file

@ -50,6 +50,13 @@ pub fn issue_11128() {
}
}
pub fn issue_11160() -> bool {
let mutex = Mutex::new(1i32);
let lock = mutex.lock().unwrap();
let _ = lock.abs();
true
}
pub fn path_return_can_be_ignored() -> i32 {
let mutex = Mutex::new(1);
let lock = mutex.lock().unwrap();

View file

@ -23,7 +23,7 @@ LL + drop(lock);
|
error: temporary with significant `Drop` can be early dropped
--> $DIR/significant_drop_tightening.rs:79:13
--> $DIR/significant_drop_tightening.rs:86:13
|
LL | / {
LL | | let mutex = Mutex::new(1i32);
@ -43,7 +43,7 @@ LL + drop(lock);
|
error: temporary with significant `Drop` can be early dropped
--> $DIR/significant_drop_tightening.rs:100:13
--> $DIR/significant_drop_tightening.rs:107:13
|
LL | / {
LL | | let mutex = Mutex::new(1i32);
@ -67,7 +67,7 @@ LL +
|
error: temporary with significant `Drop` can be early dropped
--> $DIR/significant_drop_tightening.rs:106:17
--> $DIR/significant_drop_tightening.rs:113:17
|
LL | / {
LL | | let mutex = Mutex::new(vec![1i32]);