rust/compiler
Matthias Krüger 81ba55746d
Rollup merge of #138514 - compiler-errors:fake-borrow-ref-to-value, r=oli-obk
Remove fake borrows of refs that are converted into non-refs in `MakeByMoveBody`

Remove fake borrows of closure captures if that capture has been replaced with a by-move version of that capture.

For example, given an async closure that looks like:

```
let f: Foo;
let c = async move || {
    match f { ... }
};
```

... in this pair of coroutine-closure + coroutine, we capture `Foo` in the parent and `&Foo` in the child. We will emit two fake borrows like:

```
_2 = &fake shallow (*(_1.0: &Foo));
_3 = &fake shallow (_1.0: &Foo);
```

However, since the by-move-body transform is responsible for replacing `_1.0: &Foo` with `_1.0: Foo` (since the `AsyncFnOnce` coroutine will own `Foo` by value), that makes the second fake borrow obsolete since we never have an upvar of type `&Foo`, and we should replace it with a `nop`.

As a side-note, we don't actually even care about fake borrows here at all since they're fully a MIR borrowck artifact, and we don't need to borrowck by-move MIR bodies. But it's best to preserve as much as we can between these two bodies :)

Fixes #138501

r? oli-obk
2025-03-15 11:29:27 +01:00
..
rustc Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_abi Auto merge of #137152 - saethlin:bss-const-allocs, r=wesleywiser 2025-03-13 16:41:22 +00:00
rustc_arena Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_ast Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_ast_ir Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_ast_lowering Rollup merge of #138482 - nnethercote:fix-hir-printing, r=compiler-errors 2025-03-15 00:18:25 +01:00
rustc_ast_passes Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_ast_pretty Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_attr_data_structures Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_attr_parsing Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_baked_icu_data Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_borrowck Check type of const param correctly in MIR typeck 2025-03-14 03:10:19 +00:00
rustc_builtin_macros Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_codegen_cranelift atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance 2025-03-13 08:14:34 +01:00
rustc_codegen_gcc intrinsics: remove unnecessary leading underscore from argument names 2025-03-12 08:04:09 +01:00
rustc_codegen_llvm Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_codegen_ssa feat(linker): check ARG_MAX on Unix platforms 2025-03-14 09:45:49 -04:00
rustc_const_eval Rollup merge of #138417 - RalfJung:interpret-cleanup, r=oli-obk 2025-03-13 17:44:09 +01:00
rustc_data_structures resolve: Avoid some unstable iteration 2025-03-14 18:34:08 +03:00
rustc_driver Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_driver_impl Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_error_codes Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_error_messages Rollup merge of #138404 - bjorn3:sysroot_handling_cleanup, r=petrochenkov,jieyouxu 2025-03-13 11:28:35 +01:00
rustc_errors Do not suggest using -Zmacro-backtrace for builtin macros 2025-03-14 19:50:03 +00:00
rustc_expand Do not suggest using -Zmacro-backtrace for builtin macros 2025-03-14 19:50:03 +00:00
rustc_feature Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_fluent_macro Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_fs_util Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_graphviz Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_hashes Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hir Rollup merge of #138109 - Kohei316:feat/rust-doc-precise-capturing-arg, r=aDotInTheVoid,compiler-errors 2025-03-13 11:28:26 +01:00
rustc_hir_analysis Small grammar fix in comment 2025-03-14 21:03:21 +00:00
rustc_hir_pretty Fix HIR param pretty printing some more. 2025-03-14 09:45:41 +11:00
rustc_hir_typeck Rollup merge of #138482 - nnethercote:fix-hir-printing, r=compiler-errors 2025-03-15 00:18:25 +01:00
rustc_incremental Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_index Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_index_macros Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_infer Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_interface Rollup merge of #138404 - bjorn3:sysroot_handling_cleanup, r=petrochenkov,jieyouxu 2025-03-13 11:28:35 +01:00
rustc_lexer Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_lint Rollup merge of #138474 - remexre:refactor-is-snake-case, r=compiler-errors 2025-03-15 00:18:25 +01:00
rustc_lint_defs Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_llvm Rollup merge of #138420 - zmodem:cfifunctionindex_fix, r=durin42 2025-03-13 17:44:09 +01:00
rustc_log Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_macros Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_metadata Auto merge of #138450 - matthiaskrgr:rollup-4im25vf, r=matthiaskrgr 2025-03-13 13:34:28 +00:00
rustc_middle Rollup merge of #138502 - petrochenkov:resinstab, r=compiler-errors 2025-03-15 11:29:26 +01:00
rustc_mir_build Delegation: allow foreign fns reuse 2025-03-13 14:13:07 +03:00
rustc_mir_dataflow Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_mir_transform Rollup merge of #138514 - compiler-errors:fake-borrow-ref-to-value, r=oli-obk 2025-03-15 11:29:27 +01:00
rustc_monomorphize Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_next_trait_solver Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 17:59:08 +01:00
rustc_parse Rollup merge of #138511 - mohe2015:rustc-parse-pub-parse-expr-cond, r=oli-obk 2025-03-15 00:18:26 +01:00
rustc_parse_format Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_passes Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_pattern_analysis Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_privacy Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_query_impl Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_query_system Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 17:59:08 +01:00
rustc_resolve resolve: Avoid some unstable iteration 2025-03-14 18:34:08 +03:00
rustc_sanitizers Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_serialize Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_session Show valid crate types when the user passes unknown --crate-type value 2025-03-14 15:53:42 +08:00
rustc_smir Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_span Do not suggest using -Zmacro-backtrace for builtin macros 2025-03-14 19:50:03 +00:00
rustc_symbol_mangling Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_target Rollup merge of #138056 - heiher:loong64v1.1-features, r=petrochenkov 2025-03-15 00:18:22 +01:00
rustc_trait_selection Rollup merge of #138482 - nnethercote:fix-hir-printing, r=compiler-errors 2025-03-15 00:18:25 +01:00
rustc_traits Rollup merge of #138394 - lcnr:yeet-variant, r=compiler-errors 2025-03-12 10:19:32 -07:00
rustc_transmute Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_ty_utils Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_type_ir Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_type_ir_macros Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
stable_mir Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00