diff options
| author | Eric Mark Martin <ericmarkmartin@gmail.com> | 2023-06-25 20:38:01 -0400 |
|---|---|---|
| committer | Eric Mark Martin <ericmarkmartin@gmail.com> | 2023-06-25 20:38:01 -0400 |
| commit | c07c10d1e424d01e61c5900ec0700dd4c3caadb6 (patch) | |
| tree | 7b57baa9e2151db389cf81f49ed03065788e3990 /compiler/rustc_const_eval/src/transform/validate.rs | |
| parent | 0c2c243342ec2a2427f0624fac5ac59f0ee6fbcd (diff) | |
| download | rust-c07c10d1e424d01e61c5900ec0700dd4c3caadb6.tar.gz rust-c07c10d1e424d01e61c5900ec0700dd4c3caadb6.zip | |
use PlaceRef abstractions more consistently
Diffstat (limited to 'compiler/rustc_const_eval/src/transform/validate.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 3c350e25ba6..eda50d3a767 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -318,8 +318,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { fn visit_projection_elem( &mut self, - local: Local, - proj_base: &[PlaceElem<'tcx>], + place_ref: PlaceRef<'tcx>, elem: PlaceElem<'tcx>, context: PlaceContext, location: Location, @@ -334,7 +333,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ProjectionElem::Deref if self.mir_phase >= MirPhase::Runtime(RuntimePhase::PostCleanup) => { - let base_ty = Place::ty_from(local, proj_base, &self.body.local_decls, self.tcx).ty; + let base_ty = place_ref.ty(&self.body.local_decls, self.tcx).ty; if base_ty.is_box() { self.fail( @@ -344,8 +343,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } } ProjectionElem::Field(f, ty) => { - let parent = Place { local, projection: self.tcx.mk_place_elems(proj_base) }; - let parent_ty = parent.ty(&self.body.local_decls, self.tcx); + let parent_ty = place_ref.ty(&self.body.local_decls, self.tcx); let fail_out_of_bounds = |this: &Self, location| { this.fail(location, format!("Out of bounds field {:?} for {:?}", f, parent_ty)); }; @@ -355,7 +353,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { location, format!( "Field projection `{:?}.{:?}` specified type `{:?}`, but actual type is `{:?}`", - parent, f, ty, f_ty + place_ref, f, ty, f_ty ) ) } @@ -434,7 +432,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } _ => {} } - self.super_projection_elem(local, proj_base, elem, context, location); + self.super_projection_elem(place_ref, elem, context, location); } fn visit_var_debug_info(&mut self, debuginfo: &VarDebugInfo<'tcx>) { |
