Skip to content

Commit 2d4201f

Browse files
committed
Skip reinterning if nothing changed
1 parent 6ea2db7 commit 2d4201f

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

compiler/rustc_codegen_cranelift/src/value_and_place.rs

-8
Original file line numberDiff line numberDiff line change
@@ -674,14 +674,6 @@ impl<'tcx> CPlace<'tcx> {
674674
}
675675
}
676676

677-
pub(crate) fn place_opaque_cast(
678-
self,
679-
fx: &mut FunctionCx<'_, '_, 'tcx>,
680-
ty: Ty<'tcx>,
681-
) -> CPlace<'tcx> {
682-
CPlace { inner: self.inner, layout: fx.layout_of(ty) }
683-
}
684-
685677
pub(crate) fn place_field(
686678
self,
687679
fx: &mut FunctionCx<'_, '_, 'tcx>,

compiler/rustc_const_eval/src/interpret/projection.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ where
316316
{
317317
use rustc_middle::mir::ProjectionElem::*;
318318
Ok(match proj_elem {
319-
OpaqueCast(ty) => bug!("OpaqueCast({ty}) encountered after borrowck"),
319+
OpaqueCast(ty) => {
320+
span_bug!(self.cur_span(), "OpaqueCast({ty}) encountered after borrowck")
321+
}
320322
Field(field, _) => self.project_field(base, field.index())?,
321323
Downcast(_, variant) => self.project_downcast(base, variant)?,
322324
Deref => self.deref_pointer(&base.to_op(self)?)?.into(),

compiler/rustc_mir_transform/src/reveal_all.rs

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
3232
_context: PlaceContext,
3333
_location: Location,
3434
) {
35+
// Performance optimization: don't reintern if there is no `OpaqueCast` to remove.
36+
if place.projection.iter().all(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_))) {
37+
return;
38+
}
3539
// `OpaqueCast` projections are only needed if there are opaque types on which projections are performed.
3640
// After the `RevealAll` pass, all opaque types are replaced with their hidden types, so we don't need these
3741
// projections anymore.

0 commit comments

Comments
 (0)