diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-06 08:17:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-06 08:17:50 +0200 |
| commit | 5a3359d7cc921888ccf289120c2f85e46d9417cd (patch) | |
| tree | 926937a2bc128594d21e5c0486401fdc10778fd0 | |
| parent | d7b49a8a85442bc190cb26d23d28e2df2605d491 (diff) | |
| parent | 30910eef367fb305615597885242045e6c9949ba (diff) | |
| download | rust-5a3359d7cc921888ccf289120c2f85e46d9417cd.tar.gz rust-5a3359d7cc921888ccf289120c2f85e46d9417cd.zip | |
Rollup merge of #63299 - spastorino:in-projection-use-ref, r=oli-obk
Make qualify consts in_projection use PlaceRef r? @oli-obk
| -rw-r--r-- | src/librustc_mir/transform/qualify_consts.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 163d10b9bd5..dcfc80968f3 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -182,16 +182,17 @@ trait Qualif { fn in_projection_structurally( cx: &ConstCx<'_, 'tcx>, - base: &PlaceBase<'tcx>, - proj: &Projection<'tcx>, + place: PlaceRef<'_, 'tcx>, ) -> bool { + let proj = place.projection.as_ref().unwrap(); + let base_qualif = Self::in_place(cx, PlaceRef { - base, + base: place.base, projection: &proj.base, }); let qualif = base_qualif && Self::mask_for_ty( cx, - Place::ty_from(&base, &proj.base, cx.body, cx.tcx) + Place::ty_from(place.base, &proj.base, cx.body, cx.tcx) .projection_ty(cx.tcx, &proj.elem) .ty, ); @@ -208,10 +209,9 @@ trait Qualif { fn in_projection( cx: &ConstCx<'_, 'tcx>, - base: &PlaceBase<'tcx>, - proj: &Projection<'tcx>, + place: PlaceRef<'_, 'tcx>, ) -> bool { - Self::in_projection_structurally(cx, base, proj) + Self::in_projection_structurally(cx, place) } fn in_place(cx: &ConstCx<'_, 'tcx>, place: PlaceRef<'_, 'tcx>) -> bool { @@ -234,9 +234,9 @@ trait Qualif { Self::in_static(cx, static_) }, PlaceRef { - base, - projection: Some(proj), - } => Self::in_projection(cx, base, proj), + base: _, + projection: Some(_), + } => Self::in_projection(cx, place), } } @@ -448,9 +448,10 @@ impl Qualif for IsNotPromotable { fn in_projection( cx: &ConstCx<'_, 'tcx>, - base: &PlaceBase<'tcx>, - proj: &Projection<'tcx>, + place: PlaceRef<'_, 'tcx>, ) -> bool { + let proj = place.projection.as_ref().unwrap(); + match proj.elem { ProjectionElem::Deref | ProjectionElem::Downcast(..) => return true, @@ -461,7 +462,7 @@ impl Qualif for IsNotPromotable { ProjectionElem::Field(..) => { if cx.mode == Mode::NonConstFn { - let base_ty = Place::ty_from(base, &proj.base, cx.body, cx.tcx).ty; + let base_ty = Place::ty_from(place.base, &proj.base, cx.body, cx.tcx).ty; if let Some(def) = base_ty.ty_adt_def() { // No promotion of union field accesses. if def.is_union() { @@ -472,7 +473,7 @@ impl Qualif for IsNotPromotable { } } - Self::in_projection_structurally(cx, base, proj) + Self::in_projection_structurally(cx, place) } fn in_rvalue(cx: &ConstCx<'_, 'tcx>, rvalue: &Rvalue<'tcx>) -> bool { |
