Skip to content

Commit e8e53b5

Browse files
committed
Ensure that we process projections during MIR inlining
Fixes #67710 Previously, we were not calling `super_place`, which resulted in us failing to update any local references that occur in ProjectionElem::Index. This caused the post-inlining MIR to contain a reference to a local ID from the inlined callee, leading to an ICE due to a type mismatch.
1 parent 0ec3706 commit e8e53b5

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/librustc_mir/transform/inline.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
671671
*local = self.make_integrate_local(local);
672672
}
673673

674-
fn visit_place(
675-
&mut self,
676-
place: &mut Place<'tcx>,
677-
_context: PlaceContext,
678-
_location: Location,
679-
) {
674+
fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, location: Location) {
680675
match &mut place.base {
681676
PlaceBase::Static(_) => {}
682677
PlaceBase::Local(l) => {
@@ -689,10 +684,11 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
689684

690685
place.projection = self.tcx.intern_place_elems(&*projs);
691686
}
692-
693-
*l = self.make_integrate_local(l);
694687
}
695688
}
689+
// Handles integrating any locals that occur in the base
690+
// or projections
691+
self.super_place(place, context, location)
696692
}
697693

698694
fn process_projection_elem(&mut self, elem: &PlaceElem<'tcx>) -> Option<PlaceElem<'tcx>> {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// compile-flags: -Z mir-opt-level=2
2+
// build-pass
3+
4+
// This used to ICE due to the inling pass not examining projections
5+
// for references to locals
6+
7+
pub fn parse(version: ()) {
8+
p(&b'.', b"0");
9+
}
10+
#[inline(always)]
11+
fn p(byte: &u8, s: &[u8]) {
12+
!(s[0] == *byte);
13+
}
14+
15+
fn main() {
16+
parse(());
17+
}

0 commit comments

Comments
 (0)