about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-03-17 22:55:02 +0100
committerGitHub <noreply@github.com>2022-03-17 22:55:02 +0100
commit8499a8ba88dafe76d376d2de2394e6816aaa72de (patch)
tree770bdd93cabb8734a0411f33da4785fc0a97f4bf /compiler/rustc_codegen_llvm/src
parent07121c88ad63ff47649f0b0c533a5baa51371fc1 (diff)
parent2fcd5427345154661f8d512745bdedaf072a55b6 (diff)
downloadrust-8499a8ba88dafe76d376d2de2394e6816aaa72de.tar.gz
rust-8499a8ba88dafe76d376d2de2394e6816aaa72de.zip
Rollup merge of #94309 - eholk:issue-57017, r=tmandry
[generator_interior] Be more precise with scopes of borrowed places

Previously the generator interior type checking analysis would use the nearest temporary scope as the scope of a borrowed value. This ends up being overly broad for cases such as:

```rust
fn status(_client_status: &Client) -> i16 {
    200
}

fn main() {
    let client = Client;
    let g = move || match status(&client) {
        _status => yield,
    };
    assert_send(g);
}
```

In this case, the borrow `&client` could be considered in scope for the entirety of the `match` expression, meaning it would be viewed as live across the `yield`, therefore making the generator not `Send`.

In most cases, we want to use the enclosing expression as the scope for a borrowed value which will be less than or equal to the nearest temporary scope. This PR changes the analysis to use the enclosing expression as the scope for most borrows, with the exception of borrowed RValues which are true temporary values that should have the temporary scope. There's one further exception where borrows of a copy such as happens in autoref cases also should be ignored despite being RValues.

Joint work with `@nikomatsakis`

Fixes #57017

r? `@tmandry`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions