about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2022-08-30 15:17:45 -0700
committerEric Holk <ericholk@microsoft.com>2022-08-30 15:17:45 -0700
commitb9d3f654128ce6ba29e1e9ff31fcc44f2f04b59f (patch)
tree97badec6bf25b1c3e4c84453d6e09f44ee1e93aa /src/test
parent230a8ee364b693c286a2187e56239cd2cc3be318 (diff)
downloadrust-b9d3f654128ce6ba29e1e9ff31fcc44f2f04b59f.tar.gz
rust-b9d3f654128ce6ba29e1e9ff31fcc44f2f04b59f.zip
[drop tracking] Use parent expression for scope
Previously we were just using the parent node as the scope for a
temporary value, but it turns out this is too narrow. For example, in
an expression like

    Foo {
        b: &42,
        a: async { 0 }.await,
    }

the scope for the &42 was set to the ExprField node for `b: &42`, when
we actually want to use the Foo struct expression.

We fix this by recursively searching through parent nodes until we find
a Node::Expr. It may be that we don't find one, and if so that's okay,
we will just fall back on the enclosing temporary scope which is always
sufficient.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/async-await/issue-73137.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issue-73137.rs b/src/test/ui/async-await/issue-73137.rs
index c43ce2cadba..dcbe7765a9e 100644
--- a/src/test/ui/async-await/issue-73137.rs
+++ b/src/test/ui/async-await/issue-73137.rs
@@ -2,6 +2,9 @@
 
 // run-pass
 // edition:2018
+// revisions: normal drop-tracking
+// [normal]compile-flags: -Zdrop-tracking=no
+// [drop-tracking]compile-flags: -Zdrop-tracking
 
 #![allow(dead_code)]
 use std::future::Future;