Skip to content

Rollup of 14 pull requests #143233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
66ea349
Use let chains in the new solver
compiler-errors Jun 27, 2025
ccbe983
Use one more let chain
compiler-errors Jun 27, 2025
953cf27
Workaround for mem safety in third party dlls
ChrisDenton Jun 27, 2025
3d81af8
moved tests
Kivooeo Jun 28, 2025
ed16ae8
Do not freshen ReError
compiler-errors Jun 28, 2025
1347b48
Remove additional call to lookup_op_method
compiler-errors Jun 28, 2025
74657a4
Move some UI tests to more apropriate directories
tgross35 Jun 28, 2025
897c4ee
Update README.md
kilavvy Jun 29, 2025
d0bd279
cleaned up some tests
Kivooeo Jun 12, 2025
71a8418
Add my work email to mailmap
yotamofek Jun 29, 2025
9f9cd5e
mir: Add a `new` method to `statement`
dianqk Jun 8, 2025
24e553e
mir: Use the `new` method for `BasicBlockData`
dianqk Jun 16, 2025
a38c78c
moved tests
Kivooeo Jun 29, 2025
54cec0c
Port #[link_section] to the new attribute parsing infrastructure
Periodic1911 Jun 29, 2025
20d69c6
Re-disable `tests/run-make/short-ice` on Windows MSVC again
jieyouxu Jun 29, 2025
60a4828
make some powf and powi cases involving SNaN non-deterministic
LorrensP-2158466 Jun 14, 2025
67ab61e
add float_nan test for powf
RalfJung Jun 29, 2025
d98aaf7
Show auto trait and blanket impls for `!`
zachs18 Jun 29, 2025
580bc12
cleaned up some tests
Kivooeo Jun 27, 2025
1e3a2b2
cleaned up some tests
Kivooeo Jun 29, 2025
c240566
cleaned up some tests
Kivooeo Jun 28, 2025
384d699
Rollup merge of #142429 - Kivooeo:tf13, r=jieyouxu
dianqk Jun 30, 2025
d2dc99c
Rollup merge of #142514 - LorrensP-2158466:miri-float-nondet-pow, r=R…
dianqk Jun 30, 2025
8c4bcb8
Rollup merge of #143066 - compiler-errors:let-chain-solver, r=lcnr
dianqk Jun 30, 2025
a94f0a4
Rollup merge of #143090 - ChrisDenton:workaround1, r=tgross35
dianqk Jun 30, 2025
0952f86
Rollup merge of #143118 - Kivooeo:tf15, r=tgross35
dianqk Jun 30, 2025
3a35f36
Rollup merge of #143159 - compiler-errors:freshen-re-error, r=oli-obk
dianqk Jun 30, 2025
8ccffc9
Rollup merge of #143168 - Kivooeo:tf16, r=tgross35
dianqk Jun 30, 2025
462c7c3
Rollup merge of #143176 - kilavvy:master, r=jieyouxu
dianqk Jun 30, 2025
043fc5b
Rollup merge of #143187 - yotamofek:mailmap, r=jieyouxu
dianqk Jun 30, 2025
ab633af
Rollup merge of #143190 - dianqk:new-method, r=oli-obk
dianqk Jun 30, 2025
327fe35
Rollup merge of #143195 - Kivooeo:tf17, r=tgross35
dianqk Jun 30, 2025
7760cd6
Rollup merge of #143196 - Periodic1911:link_section, r=oli-obk
dianqk Jun 30, 2025
e18342a
Rollup merge of #143199 - jieyouxu:short-ice, r=RalfJung
dianqk Jun 30, 2025
c2904f7
Rollup merge of #143219 - zachs18:patch-5, r=tgross35
dianqk Jun 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mir: Add a new method to statement
Avoid introducing a large number of changes when adding optional initialization fields.
  • Loading branch information
dianqk committed Jun 29, 2025
commit 9f9cd5e2837f57504b92b5acbadb48ff0cb9e29c
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,15 @@ fn optimize_use_clone<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(

let destination_block = target.unwrap();

bb.statements.push(mir::Statement {
source_info: bb.terminator().source_info,
kind: mir::StatementKind::Assign(Box::new((
bb.statements.push(mir::Statement::new(
bb.terminator().source_info,
mir::StatementKind::Assign(Box::new((
*destination,
mir::Rvalue::Use(mir::Operand::Copy(
arg_place.project_deeper(&[mir::ProjectionElem::Deref], tcx),
)),
))),
});
));

bb.terminator_mut().kind = mir::TerminatorKind::Goto { target: destination_block };
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_middle/src/mir/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ pub struct Statement<'tcx> {
pub kind: StatementKind<'tcx>,
}

impl Statement<'_> {
impl<'tcx> Statement<'tcx> {
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
/// invalidating statement indices in `Location`s.
pub fn make_nop(&mut self) {
self.kind = StatementKind::Nop
}

pub fn new(source_info: SourceInfo, kind: StatementKind<'tcx>) -> Self {
Statement { source_info, kind }
}
}

impl<'tcx> StatementKind<'tcx> {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_mir_build/src/builder/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'tcx> CFG<'tcx> {
) {
self.push(
block,
Statement { source_info, kind: StatementKind::Assign(Box::new((place, rvalue))) },
Statement::new(source_info, StatementKind::Assign(Box::new((place, rvalue)))),
);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ impl<'tcx> CFG<'tcx> {
place: Place<'tcx>,
) {
let kind = StatementKind::FakeRead(Box::new((cause, place)));
let stmt = Statement { source_info, kind };
let stmt = Statement::new(source_info, kind);
self.push(block, stmt);
}

Expand All @@ -99,7 +99,7 @@ impl<'tcx> CFG<'tcx> {
place: Place<'tcx>,
) {
let kind = StatementKind::PlaceMention(Box::new(place));
let stmt = Statement { source_info, kind };
let stmt = Statement::new(source_info, kind);
self.push(block, stmt);
}

Expand All @@ -110,7 +110,7 @@ impl<'tcx> CFG<'tcx> {
/// syntax (e.g. `continue` or `if !`) that would otherwise not appear in MIR.
pub(crate) fn push_coverage_span_marker(&mut self, block: BasicBlock, source_info: SourceInfo) {
let kind = StatementKind::Coverage(coverage::CoverageKind::SpanMarker);
let stmt = Statement { source_info, kind };
let stmt = Statement::new(source_info, kind);
self.push(block, stmt);
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/builder/coverageinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl BlockMarkerGen {
block: BasicBlock,
) -> BlockMarkerId {
let id = self.next_block_marker_id();
let marker_statement = mir::Statement {
let marker_statement = mir::Statement::new(
source_info,
kind: mir::StatementKind::Coverage(CoverageKind::BlockMarker { id }),
};
mir::StatementKind::Coverage(CoverageKind::BlockMarker { id }),
);
cfg.push(block, marker_statement);

id
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_mir_build/src/builder/custom/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,8 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
let stmt = self.statement_as_expr(*stmt_id)?;
let span = self.thir[stmt].span;
let statement = self.parse_statement(stmt)?;
data.statements.push(Statement {
source_info: SourceInfo { span, scope: self.source_scope },
kind: statement,
});
data.statements
.push(Statement::new(SourceInfo { span, scope: self.source_scope }, statement));
}

let Some(trailing) = block.expr else { return Err(self.expr_error(expr_id, "terminator")) };
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_mir_build/src/builder/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let place = place_builder.to_place(this);
this.cfg.push(
block,
Statement {
source_info: ty_source_info,
kind: StatementKind::AscribeUserType(
Statement::new(
ty_source_info,
StatementKind::AscribeUserType(
Box::new((
place,
UserTypeProjection { base: annotation_index, projs: vec![] },
)),
Variance::Invariant,
),
},
),
);
}
block.and(place_builder)
Expand All @@ -518,16 +518,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
});
this.cfg.push(
block,
Statement {
source_info: ty_source_info,
kind: StatementKind::AscribeUserType(
Statement::new(
ty_source_info,
StatementKind::AscribeUserType(
Box::new((
Place::from(temp),
UserTypeProjection { base: annotation_index, projs: vec![] },
)),
Variance::Invariant,
),
},
),
);
}
block.and(PlaceBuilder::from(temp))
Expand Down
18 changes: 8 additions & 10 deletions compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// and therefore is not considered during coroutine auto-trait
// determination. See the comment about `box` at `yield_in_scope`.
let result = this.local_decls.push(LocalDecl::new(expr.ty, expr_span));
this.cfg.push(
block,
Statement { source_info, kind: StatementKind::StorageLive(result) },
);
this.cfg
.push(block, Statement::new(source_info, StatementKind::StorageLive(result)));
if let Some(scope) = scope.temp_lifetime {
// schedule a shallow free of that memory, lest we unwind:
this.schedule_drop_storage_and_value(expr_span, scope, result);
Expand Down Expand Up @@ -278,12 +276,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
};
this.cfg.push(
block,
Statement {
Statement::new(
source_info,
kind: StatementKind::Intrinsic(Box::new(
NonDivergingIntrinsic::Assume(Operand::Move(assert_place)),
)),
},
StatementKind::Intrinsic(Box::new(NonDivergingIntrinsic::Assume(
Operand::Move(assert_place),
))),
),
);
}

Expand Down Expand Up @@ -789,7 +787,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let source_info = this.source_info(upvar_span);
let temp = this.local_decls.push(LocalDecl::new(upvar_ty, upvar_span));

this.cfg.push(block, Statement { source_info, kind: StatementKind::StorageLive(temp) });
this.cfg.push(block, Statement::new(source_info, StatementKind::StorageLive(temp)));

let arg_place_builder = unpack!(block = this.as_place_builder(block, arg));

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_build/src/builder/expr/as_temp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if let Block { expr: None, targeted_by_break: false, .. } = this.thir[block]
&& expr_ty.is_never() => {}
_ => {
this.cfg
.push(block, Statement { source_info, kind: StatementKind::StorageLive(temp) });
this.cfg.push(block, Statement::new(source_info, StatementKind::StorageLive(temp)));

// In constants, `temp_lifetime` is `None` for temporaries that
// live for the `'static` lifetime. Thus we do not drop these
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_mir_build/src/builder/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let base = self.canonical_user_type_annotations.push(annotation.clone());
self.cfg.push(
block,
Statement {
source_info: ty_source_info,
kind: StatementKind::AscribeUserType(
Statement::new(
ty_source_info,
StatementKind::AscribeUserType(
Box::new((place, UserTypeProjection { base, projs: Vec::new() })),
// We always use invariant as the variance here. This is because the
// variance field from the ascription refers to the variance to use
Expand All @@ -666,7 +666,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// `<expr>`.
ty::Invariant,
),
},
),
);

self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard);
Expand Down Expand Up @@ -828,7 +828,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
) -> Place<'tcx> {
let local_id = self.var_local_id(var, for_guard);
let source_info = self.source_info(span);
self.cfg.push(block, Statement { source_info, kind: StatementKind::StorageLive(local_id) });
self.cfg.push(block, Statement::new(source_info, StatementKind::StorageLive(local_id)));
// Although there is almost always scope for given variable in corner cases
// like #92893 we might get variable with no scope.
if let Some(region_scope) = self.region_scope_tree.var_scope(var.0.local_id)
Expand Down Expand Up @@ -2578,16 +2578,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let base = self.canonical_user_type_annotations.push(ascription.annotation);
self.cfg.push(
block,
Statement {
Statement::new(
source_info,
kind: StatementKind::AscribeUserType(
StatementKind::AscribeUserType(
Box::new((
ascription.source,
UserTypeProjection { base, projs: Vec::new() },
)),
ascription.variance,
),
},
),
);
}
}
Expand Down
32 changes: 16 additions & 16 deletions compiler/rustc_mir_build/src/builder/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,13 @@ impl DropTree {
cfg.terminate(block, drop_node.data.source_info, terminator);
}
DropKind::ForLint => {
let stmt = Statement {
source_info: drop_node.data.source_info,
kind: StatementKind::BackwardIncompatibleDropHint {
let stmt = Statement::new(
drop_node.data.source_info,
StatementKind::BackwardIncompatibleDropHint {
place: Box::new(drop_node.data.local.into()),
reason: BackwardIncompatibleDropReason::Edition2024,
},
};
);
cfg.push(block, stmt);
let target = blocks[drop_node.next].unwrap();
if target != block {
Expand All @@ -454,10 +454,10 @@ impl DropTree {
// Root nodes don't correspond to a drop.
DropKind::Storage if drop_idx == ROOT_NODE => {}
DropKind::Storage => {
let stmt = Statement {
source_info: drop_node.data.source_info,
kind: StatementKind::StorageDead(drop_node.data.local),
};
let stmt = Statement::new(
drop_node.data.source_info,
StatementKind::StorageDead(drop_node.data.local),
);
cfg.push(block, stmt);
let target = blocks[drop_node.next].unwrap();
if target != block {
Expand Down Expand Up @@ -1124,21 +1124,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
DropKind::ForLint => {
self.cfg.push(
block,
Statement {
Statement::new(
source_info,
kind: StatementKind::BackwardIncompatibleDropHint {
StatementKind::BackwardIncompatibleDropHint {
place: Box::new(local.into()),
reason: BackwardIncompatibleDropReason::Edition2024,
},
},
),
);
}
DropKind::Storage => {
// Only temps and vars need their storage dead.
assert!(local.index() > self.arg_count);
self.cfg.push(
block,
Statement { source_info, kind: StatementKind::StorageDead(local) },
Statement::new(source_info, StatementKind::StorageDead(local)),
);
}
}
Expand Down Expand Up @@ -1880,13 +1880,13 @@ where

cfg.push(
block,
Statement {
Statement::new(
source_info,
kind: StatementKind::BackwardIncompatibleDropHint {
StatementKind::BackwardIncompatibleDropHint {
place: Box::new(local.into()),
reason: BackwardIncompatibleDropReason::Edition2024,
},
},
),
);
}
DropKind::Storage => {
Expand All @@ -1910,7 +1910,7 @@ where
}
// Only temps and vars need their storage dead.
assert!(local.index() > arg_count);
cfg.push(block, Statement { source_info, kind: StatementKind::StorageDead(local) });
cfg.push(block, Statement::new(source_info, StatementKind::StorageDead(local)));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/framework/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn mock_body<'tcx>() -> mir::Body<'tcx> {

let mut blocks = IndexVec::new();
let mut block = |n, kind| {
let nop = mir::Statement { source_info, kind: mir::StatementKind::Nop };
let nop = mir::Statement::new(source_info, mir::StatementKind::Nop);

blocks.push(mir::BasicBlockData {
statements: std::iter::repeat(&nop).cloned().take(n).collect(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn add_move_for_packed_drop<'tcx>(
let temp = patch.new_temp(ty, source_info.span);

let storage_dead_block = patch.new_block(BasicBlockData {
statements: vec![Statement { source_info, kind: StatementKind::StorageDead(temp) }],
statements: vec![Statement::new(source_info, StatementKind::StorageDead(temp))],
terminator: Some(Terminator { source_info, kind: TerminatorKind::Goto { target } }),
is_cleanup,
});
Expand Down
19 changes: 9 additions & 10 deletions compiler/rustc_mir_transform/src/add_retag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ impl<'tcx> crate::MirPass<'tcx> for AddRetag {
// Emit their retags.
basic_blocks[START_BLOCK].statements.splice(
0..0,
places.map(|(place, source_info)| Statement {
source_info,
kind: StatementKind::Retag(RetagKind::FnEntry, Box::new(place)),
places.map(|(place, source_info)| {
Statement::new(
source_info,
StatementKind::Retag(RetagKind::FnEntry, Box::new(place)),
)
}),
);
}
Expand Down Expand Up @@ -113,10 +115,10 @@ impl<'tcx> crate::MirPass<'tcx> for AddRetag {
for (source_info, dest_place, dest_block) in returns {
basic_blocks[dest_block].statements.insert(
0,
Statement {
Statement::new(
source_info,
kind: StatementKind::Retag(RetagKind::Default, Box::new(dest_place)),
},
StatementKind::Retag(RetagKind::Default, Box::new(dest_place)),
),
);
}

Expand Down Expand Up @@ -174,10 +176,7 @@ impl<'tcx> crate::MirPass<'tcx> for AddRetag {
let source_info = block_data.statements[i].source_info;
block_data.statements.insert(
i + 1,
Statement {
source_info,
kind: StatementKind::Retag(retag_kind, Box::new(place)),
},
Statement::new(source_info, StatementKind::Retag(retag_kind, Box::new(place))),
);
}
}
Expand Down
Loading