mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Skip reinterning if nothing changed
This commit is contained in:
parent
6ea2db7c2d
commit
2d4201f7c6
@ -674,14 +674,6 @@ impl<'tcx> CPlace<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn place_opaque_cast(
|
|
||||||
self,
|
|
||||||
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
|
||||||
ty: Ty<'tcx>,
|
|
||||||
) -> CPlace<'tcx> {
|
|
||||||
CPlace { inner: self.inner, layout: fx.layout_of(ty) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn place_field(
|
pub(crate) fn place_field(
|
||||||
self,
|
self,
|
||||||
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
||||||
|
@ -316,7 +316,9 @@ where
|
|||||||
{
|
{
|
||||||
use rustc_middle::mir::ProjectionElem::*;
|
use rustc_middle::mir::ProjectionElem::*;
|
||||||
Ok(match proj_elem {
|
Ok(match proj_elem {
|
||||||
OpaqueCast(ty) => bug!("OpaqueCast({ty}) encountered after borrowck"),
|
OpaqueCast(ty) => {
|
||||||
|
span_bug!(self.cur_span(), "OpaqueCast({ty}) encountered after borrowck")
|
||||||
|
}
|
||||||
Field(field, _) => self.project_field(base, field.index())?,
|
Field(field, _) => self.project_field(base, field.index())?,
|
||||||
Downcast(_, variant) => self.project_downcast(base, variant)?,
|
Downcast(_, variant) => self.project_downcast(base, variant)?,
|
||||||
Deref => self.deref_pointer(&base.to_op(self)?)?.into(),
|
Deref => self.deref_pointer(&base.to_op(self)?)?.into(),
|
||||||
|
@ -32,6 +32,10 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
|
|||||||
_context: PlaceContext,
|
_context: PlaceContext,
|
||||||
_location: Location,
|
_location: Location,
|
||||||
) {
|
) {
|
||||||
|
// Performance optimization: don't reintern if there is no `OpaqueCast` to remove.
|
||||||
|
if place.projection.iter().all(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// `OpaqueCast` projections are only needed if there are opaque types on which projections are performed.
|
// `OpaqueCast` projections are only needed if there are opaque types on which projections are performed.
|
||||||
// After the `RevealAll` pass, all opaque types are replaced with their hidden types, so we don't need these
|
// After the `RevealAll` pass, all opaque types are replaced with their hidden types, so we don't need these
|
||||||
// projections anymore.
|
// projections anymore.
|
||||||
|
Loading…
Reference in New Issue
Block a user