about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-12-11 15:33:45 -0800
committerEsteban Küber <esteban@kuber.com.ar>2019-12-11 15:33:45 -0800
commit45550ef2ff47020ab8af5feb08669c8c4ab879e9 (patch)
treeb248b1c949177080e1ba4ac64c6d78108ca49292 /src
parent94ab9ec36bd3401b3185aff7b623ff0317b96356 (diff)
downloadrust-45550ef2ff47020ab8af5feb08669c8c4ab879e9.tar.gz
rust-45550ef2ff47020ab8af5feb08669c8c4ab879e9.zip
Reuse existing HirId → DefId table
Diffstat (limited to 'src')
-rw-r--r--src/librustc/infer/error_reporting/need_type_info.rs9
-rw-r--r--src/librustc/ty/context.rs19
-rw-r--r--src/librustc_typeck/check/expr.rs20
3 files changed, 4 insertions, 44 deletions
diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs
index 487736dee30..4baab0492a5 100644
--- a/src/librustc/infer/error_reporting/need_type_info.rs
+++ b/src/librustc/infer/error_reporting/need_type_info.rs
@@ -1,4 +1,4 @@
-use crate::hir::def::Namespace;
+use crate::hir::def::{DefKind, Namespace};
 use crate::hir::{self, Body, FunctionRetTy, Expr, ExprKind, HirId, Local, Pat};
 use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
 use crate::infer::InferCtxt;
@@ -447,9 +447,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
             &segment.args,
         ) {
             let borrow = tables.borrow();
-            let method_defs = borrow.node_method_def_id();
-            if let Some(did) = method_defs.get(e.hir_id) {
-                let generics = self.tcx.generics_of(*did);
+            if let Some((DefKind::Method, did)) = borrow.type_dependent_def(e.hir_id) {
+                let generics = self.tcx.generics_of(did);
                 if !generics.params.is_empty() {
                     err.span_suggestion(
                         segment.ident.span,
@@ -468,7 +467,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                         Applicability::HasPlaceholders,
                     );
                 } else {
-                    let sig = self.tcx.fn_sig(*did);
+                    let sig = self.tcx.fn_sig(did);
                     err.span_label(e.span, &format!(
                         "this method call resolves to `{:?}`",
                         sig.output().skip_binder(),
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index fa4ad021072..f7e422b0403 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -338,8 +338,6 @@ pub struct TypeckTables<'tcx> {
     /// typeck::check::fn_ctxt for details.
     node_types: ItemLocalMap<Ty<'tcx>>,
 
-    node_method_def_id: ItemLocalMap<DefId>,
-
     /// Stores the type parameters which were substituted to obtain the type
     /// of this node. This only applies to nodes that refer to entities
     /// parameterized by type parameters, such as generic fns, types, or
@@ -444,7 +442,6 @@ impl<'tcx> TypeckTables<'tcx> {
             user_provided_types: Default::default(),
             user_provided_sigs: Default::default(),
             node_types: Default::default(),
-            node_method_def_id: Default::default(),
             node_substs: Default::default(),
             adjustments: Default::default(),
             pat_binding_modes: Default::default(),
@@ -545,20 +542,6 @@ impl<'tcx> TypeckTables<'tcx> {
         }
     }
 
-    pub fn node_method_def_id(&self) -> LocalTableInContext<'_, DefId> {
-        LocalTableInContext {
-            local_id_root: self.local_id_root,
-            data: &self.node_method_def_id
-        }
-    }
-
-    pub fn node_method_def_id_mut(&mut self) -> LocalTableInContextMut<'_, DefId> {
-        LocalTableInContextMut {
-            local_id_root: self.local_id_root,
-            data: &mut self.node_method_def_id
-        }
-    }
-
     pub fn node_type(&self, id: hir::HirId) -> Ty<'tcx> {
         self.node_type_opt(id).unwrap_or_else(||
             bug!("node_type: no type for node `{}`",
@@ -765,7 +748,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckTables<'tcx> {
             ref user_provided_types,
             ref user_provided_sigs,
             ref node_types,
-            ref node_method_def_id,
             ref node_substs,
             ref adjustments,
             ref pat_binding_modes,
@@ -792,7 +774,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckTables<'tcx> {
             user_provided_types.hash_stable(hcx, hasher);
             user_provided_sigs.hash_stable(hcx, hasher);
             node_types.hash_stable(hcx, hasher);
-            node_method_def_id.hash_stable(hcx, hasher);
             node_substs.hash_stable(hcx, hasher);
             adjustments.hash_stable(hcx, hasher);
             pat_binding_modes.hash_stable(hcx, hasher);
diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs
index 999038e7ea7..fc7d1976637 100644
--- a/src/librustc_typeck/check/expr.rs
+++ b/src/librustc_typeck/check/expr.rs
@@ -874,26 +874,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 // We could add a "consider `foo::<params>`" suggestion here, but I wasn't able to
                 // trigger this codepath causing `structuraly_resolved_type` to emit an error.
 
-                // We could do this only when type params are present in the method to reducte
-                // memory usage, but doing it unconditionally lets us also point at the method
-                // expression and state the resolved return value:
-                // ```
-                // error[E0282]: type annotations needed
-                //    --> $DIR/issue-65611.rs:59:20
-                //    |
-                // LL |     let x = buffer.last().unwrap().0.clone();
-                //    |             -------^^^^--
-                //    |             |      |
-                //    |             |      cannot infer type for `T`
-                //    |             this method call resolves to `std::option::Option<&T>`
-                //    |
-                //    = note: type must be known at this point
-                // ```
-                self.tables.borrow_mut().node_method_def_id_mut().insert(
-                    expr.hir_id,
-                    method.def_id,
-                );
-
                 self.write_method_call(expr.hir_id, method);
                 Ok(method)
             }