Skip to content

Commit 0ee7cb5

Browse files
committed
Auto merge of rust-lang#130200 - matthiaskrgr:rollup-2g4ijc5, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#130143 (miri-test-libstd: add missing BOOTSTRAP_ARGS) - rust-lang#130173 (rustdoc: add two regression tests) - rust-lang#130175 (`rustc_mir_transform` cleanups 3) - rust-lang#130184 (coverage: Clean up terminology in counter creation) - rust-lang#130185 (abi/compatibility test: remove tests inside repr(C) wrappers) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 33855f8 + a42d67e commit 0ee7cb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+740
-745
lines changed

Diff for: compiler/rustc_mir_transform/src/add_call_guards.rs

-6
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ pub(super) use self::AddCallGuards::*;
3232

3333
impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
3434
fn run_pass(&self, _tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
35-
self.add_call_guards(body);
36-
}
37-
}
38-
39-
impl AddCallGuards {
40-
pub(super) fn add_call_guards(&self, body: &mut Body<'_>) {
4135
let mut pred_count: IndexVec<_, _> =
4236
body.basic_blocks.predecessors().iter().map(|ps| ps.len()).collect();
4337
pred_count[START_BLOCK] += 1;

Diff for: compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs

+22-23
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,34 @@ pub(super) struct AddMovesForPackedDrops;
4040
impl<'tcx> crate::MirPass<'tcx> for AddMovesForPackedDrops {
4141
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
4242
debug!("add_moves_for_packed_drops({:?} @ {:?})", body.source, body.span);
43-
add_moves_for_packed_drops(tcx, body);
44-
}
45-
}
46-
47-
fn add_moves_for_packed_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
48-
let patch = add_moves_for_packed_drops_patch(tcx, body);
49-
patch.apply(body);
50-
}
5143

52-
fn add_moves_for_packed_drops_patch<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> MirPatch<'tcx> {
53-
let def_id = body.source.def_id();
54-
let mut patch = MirPatch::new(body);
55-
let param_env = tcx.param_env(def_id);
44+
let def_id = body.source.def_id();
45+
let mut patch = MirPatch::new(body);
46+
let param_env = tcx.param_env(def_id);
5647

57-
for (bb, data) in body.basic_blocks.iter_enumerated() {
58-
let loc = Location { block: bb, statement_index: data.statements.len() };
59-
let terminator = data.terminator();
48+
for (bb, data) in body.basic_blocks.iter_enumerated() {
49+
let loc = Location { block: bb, statement_index: data.statements.len() };
50+
let terminator = data.terminator();
6051

61-
match terminator.kind {
62-
TerminatorKind::Drop { place, .. }
63-
if util::is_disaligned(tcx, body, param_env, place) =>
64-
{
65-
add_move_for_packed_drop(tcx, body, &mut patch, terminator, loc, data.is_cleanup);
52+
match terminator.kind {
53+
TerminatorKind::Drop { place, .. }
54+
if util::is_disaligned(tcx, body, param_env, place) =>
55+
{
56+
add_move_for_packed_drop(
57+
tcx,
58+
body,
59+
&mut patch,
60+
terminator,
61+
loc,
62+
data.is_cleanup,
63+
);
64+
}
65+
_ => {}
6666
}
67-
_ => {}
6867
}
69-
}
7068

71-
patch
69+
patch.apply(body);
70+
}
7271
}
7372

7473
fn add_move_for_packed_drop<'tcx>(

Diff for: compiler/rustc_mir_transform/src/add_retag.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ impl<'tcx> crate::MirPass<'tcx> for AddRetag {
6060
let basic_blocks = body.basic_blocks.as_mut();
6161
let local_decls = &body.local_decls;
6262
let needs_retag = |place: &Place<'tcx>| {
63-
!place.is_indirect_first_projection() // we're not really interested in stores to "outside" locations, they are hard to keep track of anyway
63+
// We're not really interested in stores to "outside" locations, they are hard to keep
64+
// track of anyway.
65+
!place.is_indirect_first_projection()
6466
&& may_contain_reference(place.ty(&*local_decls, tcx).ty, /*depth*/ 3, tcx)
6567
&& !local_decls[place.local].is_deref_temp()
6668
};
@@ -129,9 +131,9 @@ impl<'tcx> crate::MirPass<'tcx> for AddRetag {
129131
StatementKind::Assign(box (ref place, ref rvalue)) => {
130132
let add_retag = match rvalue {
131133
// Ptr-creating operations already do their own internal retagging, no
132-
// need to also add a retag statement.
133-
// *Except* if we are deref'ing a Box, because those get desugared to directly working
134-
// with the inner raw pointer! That's relevant for `RawPtr` as Miri otherwise makes it
134+
// need to also add a retag statement. *Except* if we are deref'ing a
135+
// Box, because those get desugared to directly working with the inner
136+
// raw pointer! That's relevant for `RawPtr` as Miri otherwise makes it
135137
// a NOP when the original pointer is already raw.
136138
Rvalue::RawPtr(_mutbl, place) => {
137139
// Using `is_box_global` here is a bit sketchy: if this code is

Diff for: compiler/rustc_mir_transform/src/add_subtyping_projections.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for SubTypeChecker<'a, 'tcx> {
5151
// // gets transformed to
5252
// let temp: rval_ty = rval;
5353
// let place: place_ty = temp as place_ty;
54-
fn subtype_finder<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
55-
let patch = MirPatch::new(body);
56-
let mut checker = SubTypeChecker { tcx, patcher: patch, local_decls: &body.local_decls };
57-
58-
for (bb, data) in body.basic_blocks.as_mut_preserves_cfg().iter_enumerated_mut() {
59-
checker.visit_basic_block_data(bb, data);
60-
}
61-
checker.patcher.apply(body);
62-
}
63-
6454
impl<'tcx> crate::MirPass<'tcx> for Subtyper {
6555
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
66-
subtype_finder(tcx, body);
56+
let patch = MirPatch::new(body);
57+
let mut checker = SubTypeChecker { tcx, patcher: patch, local_decls: &body.local_decls };
58+
59+
for (bb, data) in body.basic_blocks.as_mut_preserves_cfg().iter_enumerated_mut() {
60+
checker.visit_basic_block_data(bb, data);
61+
}
62+
checker.patcher.apply(body);
6763
}
6864
}

Diff for: compiler/rustc_mir_transform/src/check_const_item_mutation.rs

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> {
123123
self.super_statement(stmt, loc);
124124
self.target_local = None;
125125
}
126+
126127
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, loc: Location) {
127128
if let Rvalue::Ref(_, BorrowKind::Mut { .. }, place) = rvalue {
128129
let local = place.local;

Diff for: compiler/rustc_mir_transform/src/copy_prop.rs

+23-25
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,34 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
2727
#[instrument(level = "trace", skip(self, tcx, body))]
2828
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
2929
debug!(def_id = ?body.source.def_id());
30-
propagate_ssa(tcx, body);
31-
}
32-
}
3330

34-
fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
35-
let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id());
36-
let ssa = SsaLocals::new(tcx, body, param_env);
31+
let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id());
32+
let ssa = SsaLocals::new(tcx, body, param_env);
3733

38-
let fully_moved = fully_moved_locals(&ssa, body);
39-
debug!(?fully_moved);
34+
let fully_moved = fully_moved_locals(&ssa, body);
35+
debug!(?fully_moved);
4036

41-
let mut storage_to_remove = BitSet::new_empty(fully_moved.domain_size());
42-
for (local, &head) in ssa.copy_classes().iter_enumerated() {
43-
if local != head {
44-
storage_to_remove.insert(head);
37+
let mut storage_to_remove = BitSet::new_empty(fully_moved.domain_size());
38+
for (local, &head) in ssa.copy_classes().iter_enumerated() {
39+
if local != head {
40+
storage_to_remove.insert(head);
41+
}
4542
}
46-
}
4743

48-
let any_replacement = ssa.copy_classes().iter_enumerated().any(|(l, &h)| l != h);
44+
let any_replacement = ssa.copy_classes().iter_enumerated().any(|(l, &h)| l != h);
4945

50-
Replacer {
51-
tcx,
52-
copy_classes: ssa.copy_classes(),
53-
fully_moved,
54-
borrowed_locals: ssa.borrowed_locals(),
55-
storage_to_remove,
56-
}
57-
.visit_body_preserves_cfg(body);
46+
Replacer {
47+
tcx,
48+
copy_classes: ssa.copy_classes(),
49+
fully_moved,
50+
borrowed_locals: ssa.borrowed_locals(),
51+
storage_to_remove,
52+
}
53+
.visit_body_preserves_cfg(body);
5854

59-
if any_replacement {
60-
crate::simplify::remove_unused_definitions(body);
55+
if any_replacement {
56+
crate::simplify::remove_unused_definitions(body);
57+
}
6158
}
6259
}
6360

@@ -140,7 +137,8 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
140137

141138
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) {
142139
if let Operand::Move(place) = *operand
143-
// A move out of a projection of a copy is equivalent to a copy of the original projection.
140+
// A move out of a projection of a copy is equivalent to a copy of the original
141+
// projection.
144142
&& !place.is_indirect_first_projection()
145143
&& !self.fully_moved.contains(place.local)
146144
{

0 commit comments

Comments
 (0)