rust/compiler
Dylan DPC 8499a8ba88
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`
2022-03-17 22:55:02 +01:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber 2022-03-15 03:56:33 +00:00
rustc_ast_lowering rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_ast_passes rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_ast_pretty Change syntax for TyAlias where clauses 2022-03-05 13:13:45 -05:00
rustc_attr Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwco 2022-03-10 12:20:51 +01:00
rustc_borrowck rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_builtin_macros Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber 2022-03-15 03:56:33 +00:00
rustc_codegen_cranelift rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_codegen_gcc debuginfo: Refactor debuginfo generation for types -- Rename DebugInfoMethods::create_vtable_metadata() to DebugInfoMethods::create_vtable_debuginfo() 2022-03-14 17:25:24 +01:00
rustc_codegen_llvm Auto merge of #94261 - michaelwoerister:debuginfo-types-refactor, r=wesleywiser 2022-03-15 10:52:32 +00:00
rustc_codegen_ssa Rollup merge of #93745 - tarcieri:stabilize-adx, r=cjgillot 2022-03-17 22:55:01 +01:00
rustc_const_eval rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_data_structures add #[rustc_pass_by_value] to more types 2022-03-08 15:39:52 +01:00
rustc_driver rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_error_codes Rollup merge of #94555 - cuishuang:master, r=oli-obk 2022-03-03 20:01:48 +01:00
rustc_errors rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_expand rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_feature Stabilize ADX target feature 2022-03-14 18:56:39 -06:00
rustc_fs_util
rustc_graphviz
rustc_hir Identify anonymous lifetimes by their DefId in HIR. 2022-03-12 14:18:56 +01:00
rustc_hir_pretty resolve: Fix incorrect results of opt_def_kind query for some built-in macros 2022-02-24 22:54:36 +03:00
rustc_incremental rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_index Fix small typo in FIXME 2022-03-15 12:04:23 +01:00
rustc_infer rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_interface rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_lexer Improve scan_escape. 2022-02-24 17:01:01 +11:00
rustc_lint rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_lint_defs Rollup merge of #94958 - est31:pluralize, r=oli-obk 2022-03-15 17:15:55 +01:00
rustc_llvm RustWrapper: add missing include 2022-03-10 11:16:33 -05:00
rustc_log
rustc_macros add #[rustc_pass_by_value] to more types 2022-03-08 15:39:52 +01:00
rustc_metadata rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_middle rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_mir_build rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_mir_dataflow Improve AdtDef interning. 2022-03-11 13:31:24 +11:00
rustc_mir_transform rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_monomorphize rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_parse Rollup merge of #93222 - mark-i-m:errorreported, r=oli-obk 2022-03-17 22:55:00 +01:00
rustc_parse_format
rustc_passes rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_plugin_impl
rustc_privacy rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_query_impl Auto merge of #94084 - Mark-Simulacrum:drop-sharded, r=cjgillot 2022-02-27 14:04:07 +00:00
rustc_query_system rename ErrorReported -> ErrorGuaranteed 2022-03-02 09:45:25 -06:00
rustc_resolve rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_save_analysis Improve AdtDef interning. 2022-03-11 13:31:24 +11:00
rustc_serialize Delete Decoder::read_unit 2022-02-22 18:14:51 -05:00
rustc_session rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_span Rollup merge of #90621 - adamgemmell:dev/stabilise-target-feature, r=Amanieu 2022-03-14 17:24:56 +01:00
rustc_symbol_mangling Improve AdtDef interning. 2022-03-11 13:31:24 +11:00
rustc_target Add support for targeting riscv32im-unknown-none-elf 2022-03-09 13:51:29 -08:00
rustc_trait_selection rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_traits Improve AdtDef interning. 2022-03-11 13:31:24 +11:00
rustc_ty_utils rustc_error: make ErrorReported impossible to construct 2022-03-16 10:35:24 -05:00
rustc_type_ir
rustc_typeck Rollup merge of #94309 - eholk:issue-57017, r=tmandry 2022-03-17 22:55:02 +01:00