summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/mir/visit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/mir/visit.rs')
-rw-r--r--compiler/rustc_middle/src/mir/visit.rs58
1 files changed, 31 insertions, 27 deletions
diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs
index 069b38591..f2745b32c 100644
--- a/compiler/rustc_middle/src/mir/visit.rs
+++ b/compiler/rustc_middle/src/mir/visit.rs
@@ -186,7 +186,7 @@ macro_rules! make_mir_visitor {
fn visit_constant(
&mut self,
- constant: & $($mutability)? Constant<'tcx>,
+ constant: & $($mutability)? ConstOperand<'tcx>,
location: Location,
) {
self.super_constant(constant, location);
@@ -469,8 +469,8 @@ macro_rules! make_mir_visitor {
self.visit_source_info(source_info);
match kind {
TerminatorKind::Goto { .. } |
- TerminatorKind::Resume |
- TerminatorKind::Terminate |
+ TerminatorKind::UnwindResume |
+ TerminatorKind::UnwindTerminate(_) |
TerminatorKind::GeneratorDrop |
TerminatorKind::Unreachable |
TerminatorKind::FalseEdge { .. } |
@@ -647,8 +647,8 @@ macro_rules! make_mir_visitor {
BorrowKind::Shared => PlaceContext::NonMutatingUse(
NonMutatingUseContext::SharedBorrow
),
- BorrowKind::Shallow => PlaceContext::NonMutatingUse(
- NonMutatingUseContext::ShallowBorrow
+ BorrowKind::Fake => PlaceContext::NonMutatingUse(
+ NonMutatingUseContext::FakeBorrow
),
BorrowKind::Mut { .. } =>
PlaceContext::MutatingUse(MutatingUseContext::Borrow),
@@ -838,12 +838,20 @@ macro_rules! make_mir_visitor {
let VarDebugInfo {
name: _,
source_info,
+ composite,
value,
argument_index: _,
} = var_debug_info;
self.visit_source_info(source_info);
let location = Location::START;
+ if let Some(box VarDebugInfoFragment { ref $($mutability)? ty, ref $($mutability)? projection }) = composite {
+ self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
+ for elem in projection {
+ let ProjectionElem::Field(_, ty) = elem else { bug!() };
+ self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
+ }
+ }
match value {
VarDebugInfoContents::Const(c) => self.visit_constant(c, location),
VarDebugInfoContents::Place(place) =>
@@ -852,17 +860,6 @@ macro_rules! make_mir_visitor {
PlaceContext::NonUse(NonUseContext::VarDebugInfo),
location
),
- VarDebugInfoContents::Composite { ty, fragments } => {
- // FIXME(eddyb) use a better `TyContext` here.
- self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
- for VarDebugInfoFragment { projection: _, contents } in fragments {
- self.visit_place(
- contents,
- PlaceContext::NonUse(NonUseContext::VarDebugInfo),
- location,
- );
- }
- }
}
}
@@ -873,20 +870,20 @@ macro_rules! make_mir_visitor {
fn super_constant(
&mut self,
- constant: & $($mutability)? Constant<'tcx>,
+ constant: & $($mutability)? ConstOperand<'tcx>,
location: Location
) {
- let Constant {
+ let ConstOperand {
span,
user_ty: _, // no visit method for this
- literal,
+ const_,
} = constant;
self.visit_span($(& $mutability)? *span);
- match literal {
- ConstantKind::Ty(ct) => self.visit_ty_const($(&$mutability)? *ct, location),
- ConstantKind::Val(_, ty) => self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)),
- ConstantKind::Unevaluated(_, ty) => self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)),
+ match const_ {
+ Const::Ty(ct) => self.visit_ty_const($(&$mutability)? *ct, location),
+ Const::Val(_, ty) => self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)),
+ Const::Unevaluated(_, ty) => self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)),
}
}
@@ -1112,6 +1109,11 @@ macro_rules! visit_place_fns {
self.visit_ty(&mut new_ty, TyContext::Location(location));
if ty != new_ty { Some(PlaceElem::OpaqueCast(new_ty)) } else { None }
}
+ PlaceElem::Subtype(ty) => {
+ let mut new_ty = ty;
+ self.visit_ty(&mut new_ty, TyContext::Location(location));
+ if ty != new_ty { Some(PlaceElem::Subtype(new_ty)) } else { None }
+ }
PlaceElem::Deref
| PlaceElem::ConstantIndex { .. }
| PlaceElem::Subslice { .. }
@@ -1178,7 +1180,9 @@ macro_rules! visit_place_fns {
location: Location,
) {
match elem {
- ProjectionElem::OpaqueCast(ty) | ProjectionElem::Field(_, ty) => {
+ ProjectionElem::OpaqueCast(ty)
+ | ProjectionElem::Subtype(ty)
+ | ProjectionElem::Field(_, ty) => {
self.visit_ty(ty, TyContext::Location(location));
}
ProjectionElem::Index(local) => {
@@ -1256,8 +1260,8 @@ pub enum NonMutatingUseContext {
Move,
/// Shared borrow.
SharedBorrow,
- /// Shallow borrow.
- ShallowBorrow,
+ /// A fake borrow.
+ FakeBorrow,
/// AddressOf for *const pointer.
AddressOf,
/// PlaceMention statement.
@@ -1336,7 +1340,7 @@ impl PlaceContext {
matches!(
self,
PlaceContext::NonMutatingUse(
- NonMutatingUseContext::SharedBorrow | NonMutatingUseContext::ShallowBorrow
+ NonMutatingUseContext::SharedBorrow | NonMutatingUseContext::FakeBorrow
) | PlaceContext::MutatingUse(MutatingUseContext::Borrow)
)
}