Skip to content

Commit 2a59a53

Browse files
committed
renumber: handle ReturnTy better
1 parent 5fdab90 commit 2a59a53

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/librustc/mir/visit.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,10 @@ macro_rules! make_mir_visitor {
292292
self.visit_visibility_scope_data(scope);
293293
}
294294

295-
let lookup = TyContext::SourceInfo(SourceInfo {
295+
self.visit_ty(&$($mutability)* mir.return_ty, TyContext::ReturnTy(SourceInfo {
296296
span: mir.span,
297297
scope: ARGUMENT_VISIBILITY_SCOPE,
298-
});
299-
self.visit_ty(&$($mutability)* mir.return_ty, lookup);
298+
}));
300299

301300
for local in mir.local_decls.indices() {
302301
self.visit_local_decl(local, & $($mutability)* mir.local_decls[local]);
@@ -821,9 +820,11 @@ pub enum TyContext {
821820
source_info: SourceInfo,
822821
},
823822

824-
Location(Location),
823+
/// The return type of the function.
824+
ReturnTy(SourceInfo),
825825

826-
SourceInfo(SourceInfo),
826+
/// A type found at some location.
827+
Location(Location),
827828
}
828829

829830
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

src/librustc_mir/transform/nll/renumber.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,23 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
9292
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
9393
let is_arg = match ty_context {
9494
TyContext::LocalDecl { local, .. } => self.is_argument_or_return_slot(local),
95-
_ => false,
95+
TyContext::ReturnTy(..) => true,
96+
TyContext::Location(..) => false,
9697
};
98+
debug!(
99+
"visit_ty(ty={:?}, is_arg={:?}, ty_context={:?})",
100+
ty,
101+
is_arg,
102+
ty_context
103+
);
97104

98105
let old_ty = *ty;
99106
*ty = if is_arg {
100107
self.renumber_free_regions(&old_ty)
101108
} else {
102109
self.renumber_regions(ty_context, &old_ty)
103110
};
111+
debug!("visit_ty: ty={:?}", ty);
104112
}
105113

106114
fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, location: Location) {

0 commit comments

Comments
 (0)