diff options
| author | Ding Xiang Fei <dingxiangfei2009@protonmail.ch> | 2024-04-12 23:24:45 +0800 |
|---|---|---|
| committer | Ding Xiang Fei <dingxiangfei2009@protonmail.ch> | 2024-06-18 04:14:43 +0800 |
| commit | 0f8c3f78825a1b6eb765b97f658b92252b55c5df (patch) | |
| tree | 825b35aea3cd1ebbe53c2e9aaeec6012c30cb494 /tests/ui/drop/tail-expr-drop-order-negative.rs | |
| parent | 11380368dc53d0b2fc3a627408818eff1973ce9a (diff) | |
| download | rust-0f8c3f78825a1b6eb765b97f658b92252b55c5df.tar.gz rust-0f8c3f78825a1b6eb765b97f658b92252b55c5df.zip | |
tail expression behind terminating scope
Diffstat (limited to 'tests/ui/drop/tail-expr-drop-order-negative.rs')
| -rw-r--r-- | tests/ui/drop/tail-expr-drop-order-negative.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/drop/tail-expr-drop-order-negative.rs b/tests/ui/drop/tail-expr-drop-order-negative.rs new file mode 100644 index 00000000000..c570b3a1ee2 --- /dev/null +++ b/tests/ui/drop/tail-expr-drop-order-negative.rs @@ -0,0 +1,17 @@ +//@ revisions: edition2021 edition2024 +//@ [edition2024] compile-flags: -Zunstable-options +//@ [edition2024] edition: 2024 +//@ [edition2021] check-pass + +#![feature(shorter_tail_lifetimes)] + +fn why_would_you_do_this() -> bool { + let mut x = None; + // Make a temporary `RefCell` and put a `Ref` that borrows it in `x`. + x.replace(std::cell::RefCell::new(123).borrow()).is_some() + //[edition2024]~^ ERROR: temporary value dropped while borrowed +} + +fn main() { + why_would_you_do_this(); +} |
