diff options
| author | bors <bors@rust-lang.org> | 2025-01-18 12:57:05 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-01-18 12:57:05 +0000 | 
| commit | 8321f00bf4a5f25cad5ec8861c5469afe6e0ce8b (patch) | |
| tree | 3e2b687773a2e6cbf7f93e9b754b1dfb6a629395 /compiler/rustc_borrowck/src/lib.rs | |
| parent | bd62a452f45c2386275c5469f9ae390e7de2dc6f (diff) | |
| parent | e8736955d188a026bfc69d231158964f37cedad0 (diff) | |
| download | rust-8321f00bf4a5f25cad5ec8861c5469afe6e0ce8b.tar.gz rust-8321f00bf4a5f25cad5ec8861c5469afe6e0ce8b.zip  | |
Auto merge of #135678 - matthiaskrgr:rollup-psuyzpn, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #134455 (cleanup promoteds move check) - #135421 (Make tidy warn on unrecognized directives) - #135611 (Remove unnecessary assertion for reference error) - #135620 (ci: improve github action name) - #135639 (new solver: prefer trivial builtin impls) - #135654 (add src/librustdoc and src/rustdoc-json-types to RUSTC_IF_UNCHANGED_ALLOWED_PATHS) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_borrowck/src/lib.rs')
| -rw-r--r-- | compiler/rustc_borrowck/src/lib.rs | 18 | 
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 45764f9c6b8..c6e6d962ce5 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -182,9 +182,6 @@ fn do_mir_borrowck<'tcx>( let location_table = PoloniusLocationTable::new(body); let move_data = MoveData::gather_moves(body, tcx, |_| true); - let promoted_move_data = promoted - .iter_enumerated() - .map(|(idx, body)| (idx, MoveData::gather_moves(body, tcx, |_| true))); let flow_inits = MaybeInitializedPlaces::new(tcx, body, &move_data) .iterate_to_fixpoint(tcx, body, Some("borrowck")) @@ -242,10 +239,14 @@ fn do_mir_borrowck<'tcx>( false }; - for (idx, move_data) in promoted_move_data { + // While promoteds should mostly be correct by construction, we need to check them for + // invalid moves to detect moving out of arrays:`struct S; fn main() { &([S][0]); }`. + for promoted_body in &promoted { use rustc_middle::mir::visit::Visitor; - - let promoted_body = &promoted[idx]; + // This assumes that we won't use some of the fields of the `promoted_mbcx` + // when detecting and reporting move errors. While it would be nice to move + // this check out of `MirBorrowckCtxt`, actually doing so is far from trivial. + let move_data = MoveData::gather_moves(promoted_body, tcx, |_| true); let mut promoted_mbcx = MirBorrowckCtxt { infcx: &infcx, body: promoted_body, @@ -270,9 +271,6 @@ fn do_mir_borrowck<'tcx>( move_errors: Vec::new(), diags_buffer, }; - MoveVisitor { ctxt: &mut promoted_mbcx }.visit_body(promoted_body); - promoted_mbcx.report_move_errors(); - struct MoveVisitor<'a, 'b, 'infcx, 'tcx> { ctxt: &'a mut MirBorrowckCtxt<'b, 'infcx, 'tcx>, } @@ -284,6 +282,8 @@ fn do_mir_borrowck<'tcx>( } } } + MoveVisitor { ctxt: &mut promoted_mbcx }.visit_body(promoted_body); + promoted_mbcx.report_move_errors(); } let mut mbcx = MirBorrowckCtxt {  | 
