mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
renumber: handle ReturnTy better
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user