about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
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
commit59dd179ad3b89c404cae4d251015a510289a048f (patch)
tree7d0a395c7709e24da035afa1ea02b7745568b4a1 /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
parent5ed40229acb46d11b6c37ac53bf85eea3af9bf1d (diff)
parent05008fe1272942e07f819e526b1cfb85d431dcbd (diff)
downloadrust-59dd179ad3b89c404cae4d251015a510289a048f.tar.gz
rust-59dd179ad3b89c404cae4d251015a510289a048f.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_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions