From 372c6df564616dd461b82def5d75428940ca04ae Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 24 Nov 2016 19:42:10 +0200 Subject: [PATCH] rustc_typeck: don't record associated type resolutions. --- src/librustc/middle/mem_categorization.rs | 4 ++-- src/librustc_typeck/astconv.rs | 8 +------- src/librustc_typeck/check/callee.rs | 2 +- src/librustc_typeck/check/mod.rs | 4 ++-- src/librustc_typeck/check/writeback.rs | 5 +++++ 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index b9542d6fc5c4..8d3e734f8c33 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -489,7 +489,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } hir::ExprPath(ref qpath) => { - let def = self.tcx().tables().qpath_def(qpath, expr.id); + let def = self.infcx.tables.borrow().qpath_def(qpath, expr.id); self.cat_def(expr.id, expr.span, expr_ty, def) } @@ -1087,7 +1087,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { match pat.node { PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => { - let def = self.tcx().tables().qpath_def(qpath, pat.id); + let def = self.infcx.tables.borrow().qpath_def(qpath, pat.id); let expected_len = match def { Def::VariantCtor(def_id, CtorKind::Fn) => { let enum_def = self.tcx().parent_def_id(def_id).unwrap(); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 8a8b34342940..bb7b62533001 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1662,13 +1662,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { } else { Def::Err }; - let (ty, def) = self.associated_path_def_to_ty(ast_ty.id, ast_ty.span, - ty, def, segment); - - // Write back the new resolution. - tcx.tables.borrow_mut().type_relative_path_defs.insert(ast_ty.id, def); - - ty + self.associated_path_def_to_ty(ast_ty.id, ast_ty.span, ty, def, segment).0 } hir::TyArray(ref ty, ref e) => { if let Ok(length) = eval_length(tcx.global_tcx(), &e, "array length") { diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index fdf496b7c86f..6d00f481fa26 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -219,7 +219,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let hir::ExprCall(ref expr, _) = call_expr.node { let def = if let hir::ExprPath(ref qpath) = expr.node { - self.tcx.tables().qpath_def(qpath, expr.id) + self.tables.borrow().qpath_def(qpath, expr.id) } else { Def::Err }; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 76bd961ebd2f..2babb81bc407 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4028,7 +4028,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ty, def, segment); // Write back the new resolution. - self.tcx.tables.borrow_mut().type_relative_path_defs.insert(node_id, def); + self.tables.borrow_mut().type_relative_path_defs.insert(node_id, def); (def, ty) } @@ -4069,7 +4069,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; // Write back the new resolution. - self.tcx.tables.borrow_mut().type_relative_path_defs.insert(node_id, def); + self.tables.borrow_mut().type_relative_path_defs.insert(node_id, def); (def, Some(ty), slice::ref_slice(&**item_segment)) } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 1e26d1b80d31..45b3dae3e9f8 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -358,6 +358,11 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } fn visit_node_id(&self, reason: ResolveReason, id: ast::NodeId) { + // Export associated path extensions. + if let Some(def) = self.fcx.tables.borrow_mut().type_relative_path_defs.remove(&id) { + self.tcx().tables.borrow_mut().type_relative_path_defs.insert(id, def); + } + // Resolve any borrowings for the node with id `id` self.visit_adjustments(reason, id);