renumber: handle ReturnTy better

This commit is contained in:
Niko Matsakis
2017-11-07 04:30:06 -05:00
parent 5592bb7c33
commit 12534e9159
2 changed files with 15 additions and 6 deletions
+6 -5
View File
@@ -292,11 +292,10 @@ macro_rules! basic_blocks {
self.visit_visibility_scope_data(scope);
}
let lookup = TyContext::SourceInfo(SourceInfo {
self.visit_ty(&$($mutability)* mir.return_ty, TyContext::ReturnTy(SourceInfo {
span: mir.span,
scope: ARGUMENT_VISIBILITY_SCOPE,
});
self.visit_ty(&$($mutability)* mir.return_ty, lookup);
}));
for local in mir.local_decls.indices() {
self.visit_local_decl(local, & $($mutability)* mir.local_decls[local]);
@@ -821,9 +820,11 @@ pub enum TyContext {
source_info: SourceInfo,
},
Location(Location),
/// The return type of the function.
ReturnTy(SourceInfo),
SourceInfo(SourceInfo),
/// A type found at some location.
Location(Location),
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+9 -1
View File
@@ -92,8 +92,15 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
let is_arg = match ty_context {
TyContext::LocalDecl { local, .. } => self.is_argument_or_return_slot(local),
_ => false,
TyContext::ReturnTy(..) => true,
TyContext::Location(..) => false,
};
debug!(
"visit_ty(ty={:?}, is_arg={:?}, ty_context={:?})",
ty,
is_arg,
ty_context
);
let old_ty = *ty;
*ty = if is_arg {
@@ -101,6 +108,7 @@ fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
} else {
self.renumber_regions(ty_context, &old_ty)
};
debug!("visit_ty: ty={:?}", ty);
}
fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, location: Location) {