Skip to content

Commit 5a3359d

Browse files
authored
Rollup merge of rust-lang#63299 - spastorino:in-projection-use-ref, r=oli-obk
Make qualify consts in_projection use PlaceRef r? @oli-obk
2 parents d7b49a8 + 30910ee commit 5a3359d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/librustc_mir/transform/qualify_consts.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,17 @@ trait Qualif {
182182

183183
fn in_projection_structurally(
184184
cx: &ConstCx<'_, 'tcx>,
185-
base: &PlaceBase<'tcx>,
186-
proj: &Projection<'tcx>,
185+
place: PlaceRef<'_, 'tcx>,
187186
) -> bool {
187+
let proj = place.projection.as_ref().unwrap();
188+
188189
let base_qualif = Self::in_place(cx, PlaceRef {
189-
base,
190+
base: place.base,
190191
projection: &proj.base,
191192
});
192193
let qualif = base_qualif && Self::mask_for_ty(
193194
cx,
194-
Place::ty_from(&base, &proj.base, cx.body, cx.tcx)
195+
Place::ty_from(place.base, &proj.base, cx.body, cx.tcx)
195196
.projection_ty(cx.tcx, &proj.elem)
196197
.ty,
197198
);
@@ -208,10 +209,9 @@ trait Qualif {
208209

209210
fn in_projection(
210211
cx: &ConstCx<'_, 'tcx>,
211-
base: &PlaceBase<'tcx>,
212-
proj: &Projection<'tcx>,
212+
place: PlaceRef<'_, 'tcx>,
213213
) -> bool {
214-
Self::in_projection_structurally(cx, base, proj)
214+
Self::in_projection_structurally(cx, place)
215215
}
216216

217217
fn in_place(cx: &ConstCx<'_, 'tcx>, place: PlaceRef<'_, 'tcx>) -> bool {
@@ -234,9 +234,9 @@ trait Qualif {
234234
Self::in_static(cx, static_)
235235
},
236236
PlaceRef {
237-
base,
238-
projection: Some(proj),
239-
} => Self::in_projection(cx, base, proj),
237+
base: _,
238+
projection: Some(_),
239+
} => Self::in_projection(cx, place),
240240
}
241241
}
242242

@@ -448,9 +448,10 @@ impl Qualif for IsNotPromotable {
448448

449449
fn in_projection(
450450
cx: &ConstCx<'_, 'tcx>,
451-
base: &PlaceBase<'tcx>,
452-
proj: &Projection<'tcx>,
451+
place: PlaceRef<'_, 'tcx>,
453452
) -> bool {
453+
let proj = place.projection.as_ref().unwrap();
454+
454455
match proj.elem {
455456
ProjectionElem::Deref |
456457
ProjectionElem::Downcast(..) => return true,
@@ -461,7 +462,7 @@ impl Qualif for IsNotPromotable {
461462

462463
ProjectionElem::Field(..) => {
463464
if cx.mode == Mode::NonConstFn {
464-
let base_ty = Place::ty_from(base, &proj.base, cx.body, cx.tcx).ty;
465+
let base_ty = Place::ty_from(place.base, &proj.base, cx.body, cx.tcx).ty;
465466
if let Some(def) = base_ty.ty_adt_def() {
466467
// No promotion of union field accesses.
467468
if def.is_union() {
@@ -472,7 +473,7 @@ impl Qualif for IsNotPromotable {
472473
}
473474
}
474475

475-
Self::in_projection_structurally(cx, base, proj)
476+
Self::in_projection_structurally(cx, place)
476477
}
477478

478479
fn in_rvalue(cx: &ConstCx<'_, 'tcx>, rvalue: &Rvalue<'tcx>) -> bool {

0 commit comments

Comments
 (0)