forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve behavior of IF_LET_RESCOPE around temporaries and place expre…
…ssions
- Loading branch information
1 parent
617aad8
commit bab03bf
Showing
2 changed files
with
92 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//@ edition: 2021 | ||
//@ check-pass | ||
|
||
#![deny(if_let_rescope)] | ||
|
||
struct Drop; | ||
impl std::ops::Drop for Drop { | ||
fn drop(&mut self) { | ||
println!("drop") | ||
} | ||
} | ||
|
||
impl Drop { | ||
fn as_ref(&self) -> Option<i32> { | ||
Some(1) | ||
} | ||
} | ||
|
||
fn consume(_: impl Sized) -> Option<i32> { Some(1) } | ||
|
||
fn main() { | ||
let drop = Drop; | ||
|
||
// Make sure we don't drop if we don't actually make a temporary. | ||
if let None = drop.as_ref() {} else {} | ||
|
||
// Make sure we don't lint if we consume the droppy value. | ||
if let None = consume(Drop) {} else {} | ||
} |