]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Rollup merge of #101217 - eholk:drop-tracking-73137, r=jyn514
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Sat, 3 Sep 2022 05:03:06 +0000 (10:33 +0530)
committerGitHub <noreply@github.com>
Sat, 3 Sep 2022 05:03:06 +0000 (10:33 +0530)
commitdc8fe633d5812096008d94d47fa692264d327a46
tree7c3d92ed9171f0e079166db53dbb8ba3166bcfd1
parenta0056795da7a51f0ebebf0d5ad8f0b663d089420
parentf921f5626d1dcc08f2707ed2c22e22fd1ad678b7
Rollup merge of #101217 - eholk:drop-tracking-73137, r=jyn514

[drop tracking] Use parent expression for scope, not parent node

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.

Helps with #97331

r? ``@jyn514``
compiler/rustc_typeck/src/check/generator_interior.rs