]> git.lizzy.rs Git - rust.git/commitdiff
rename hir::map::name_by_hir_id to ::name
authorljedrz <ljedrz@gmail.com>
Wed, 19 Jun 2019 13:44:51 +0000 (15:44 +0200)
committerljedrz <ljedrz@gmail.com>
Thu, 20 Jun 2019 10:47:26 +0000 (12:47 +0200)
16 files changed:
src/librustc/hir/map/mod.rs
src/librustc/infer/error_reporting/mod.rs
src/librustc/infer/error_reporting/note.rs
src/librustc/mir/mod.rs
src/librustc/ty/print/pretty.rs
src/librustc/ty/structural_impls.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_mir/borrow_check/conflict_errors.rs
src/librustc_mir/borrow_check/error_reporting.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs
src/librustc_mir/borrow_check/nll/universal_regions.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/upvar.rs
src/librustdoc/passes/collect_intra_doc_links.rs

index 10632bc4d8a90c1ab1297063b32ad233b5c80ac9..259f6cd27112fbe602dd2fde729d8194f63faad3 100644 (file)
@@ -940,7 +940,7 @@ pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr {
         }
     }
 
-    pub fn name_by_hir_id(&self, id: HirId) -> Name {
+    pub fn name(&self, id: HirId) -> Name {
         match self.get_by_hir_id(id) {
             Node::Item(i) => i.ident.name,
             Node::ForeignItem(fi) => fi.ident.name,
@@ -951,7 +951,7 @@ pub fn name_by_hir_id(&self, id: HirId) -> Name {
             Node::Lifetime(lt) => lt.name.ident().name,
             Node::GenericParam(param) => param.name.ident().name,
             Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
-            Node::Ctor(..) => self.name_by_hir_id(self.get_parent_item(id)),
+            Node::Ctor(..) => self.name(self.get_parent_item(id)),
             _ => bug!("no name for {}", self.node_to_string(id))
         }
     }
index 321c06897de111a538e7cfbcb0aa05b18caabd7f..2c063aaaa86352625075d53329829b57f57d4c3f 100644 (file)
@@ -1583,7 +1583,7 @@ fn report_inference_failure(
                 format!(" for lifetime parameter `{}` in coherence check", name)
             }
             infer::UpvarRegion(ref upvar_id, _) => {
-                let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
+                let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
                 format!(" for capture of `{}` by closure", var_name)
             }
             infer::NLL(..) => bug!("NLL variable found in lexical phase"),
index 3c6253a9604871f62f80fd6daafd255e3889d61e..caed4288892eff2844e9a0c4728647577ff9a75e 100644 (file)
@@ -31,7 +31,7 @@ pub(super) fn note_region_origin(&self,
                               "...so that reference does not outlive borrowed content");
             }
             infer::ReborrowUpvar(span, ref upvar_id) => {
-                let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
+                let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
                 err.span_note(span,
                               &format!("...so that closure can access `{}`", var_name));
             }
@@ -50,7 +50,7 @@ pub(super) fn note_region_origin(&self,
                 err.span_note(span,
                               &format!("...so that captured variable `{}` does not outlive the \
                                         enclosing closure",
-                                       self.tcx.hir().name_by_hir_id(id)));
+                                       self.tcx.hir().name(id)));
             }
             infer::IndexSlice(span) => {
                 err.span_note(span, "...so that slice is not indexed outside the lifetime");
@@ -163,7 +163,7 @@ pub(super) fn report_concrete_failure(&self,
                 err
             }
             infer::ReborrowUpvar(span, ref upvar_id) => {
-                let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
+                let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
                 let mut err = struct_span_err!(self.tcx.sess,
                                                span,
                                                E0313,
@@ -220,7 +220,7 @@ pub(super) fn report_concrete_failure(&self,
                                                E0474,
                                                "captured variable `{}` does not outlive the \
                                                 enclosing closure",
-                                               self.tcx.hir().name_by_hir_id(id));
+                                               self.tcx.hir().name(id));
                 self.tcx.note_and_explain_region(region_scope_tree, &mut err,
                     "captured variable is valid for ", sup, "");
                 self.tcx.note_and_explain_region(region_scope_tree, &mut err,
index 9dfd8d959a3c4d29f3a3e2564f161ac8caffd3e3..cc78640c8db77a89d7add9d5feba342f559be3d4 100644 (file)
@@ -2571,7 +2571,7 @@ fn fmt_tuple(fmt: &mut Formatter<'_>, places: &[Operand<'_>]) -> fmt::Result {
 
                             if let Some(upvars) = tcx.upvars(def_id) {
                                 for (&var_id, place) in upvars.keys().zip(places) {
-                                    let var_name = tcx.hir().name_by_hir_id(var_id);
+                                    let var_name = tcx.hir().name(var_id);
                                     struct_fmt.field(&var_name.as_str(), place);
                                 }
                             }
@@ -2590,7 +2590,7 @@ fn fmt_tuple(fmt: &mut Formatter<'_>, places: &[Operand<'_>]) -> fmt::Result {
 
                             if let Some(upvars) = tcx.upvars(def_id) {
                                 for (&var_id, place) in upvars.keys().zip(places) {
-                                    let var_name = tcx.hir().name_by_hir_id(var_id);
+                                    let var_name = tcx.hir().name(var_id);
                                     struct_fmt.field(&var_name.as_str(), place);
                                 }
                             }
index d143cc3e6092d00331c829ccc078698361eaf733..cb0ac0f07f28717fa7652b3151b0ebff2a9ee75c 100644 (file)
@@ -600,7 +600,7 @@ fn pretty_print_type(
                         p!(
                             write("{}{}:",
                                     sep,
-                                    self.tcx().hir().name_by_hir_id(var_id)),
+                                    self.tcx().hir().name(var_id)),
                             print(upvar_ty));
                         sep = ", ";
                     }
@@ -643,7 +643,7 @@ fn pretty_print_type(
                         p!(
                             write("{}{}:",
                                     sep,
-                                    self.tcx().hir().name_by_hir_id(var_id)),
+                                    self.tcx().hir().name(var_id)),
                             print(upvar_ty));
                         sep = ", ";
                     }
index 4cd0fd3e824f5d5ddb887da6d1f63f8da4b59894..fed6100b1b2f2bb873f103c983eb9a2e9834a0d1 100644 (file)
@@ -62,7 +62,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 impl fmt::Debug for ty::UpvarId {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         let name = ty::tls::with(|tcx| {
-            tcx.hir().name_by_hir_id(self.var_path.hir_id)
+            tcx.hir().name(self.var_path.hir_id)
         });
         write!(f, "UpvarId({:?};`{}`;{:?})",
             self.var_path.hir_id,
index 025d5adc2b3eaa74058d4ab6b4624dbc848e82ce..bfc61520d51df8fa596e83dd8c32290fbfd899ab 100644 (file)
@@ -1394,10 +1394,10 @@ pub fn append_loan_path_to_string(&self,
                                       out: &mut String) {
         match loan_path.kind {
             LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id }, closure_expr_id: _ }) => {
-                out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
+                out.push_str(&self.tcx.hir().name(id).as_str());
             }
             LpVar(id) => {
-                out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
+                out.push_str(&self.tcx.hir().name(id).as_str());
             }
 
             LpDowncast(ref lp_base, variant_def_id) => {
index dfaad95fa3cb9cf691dd7af9beb8bcad7326f237..f23cffeda689c779eb7a8a558f1f97833a1433e8 100644 (file)
@@ -853,7 +853,7 @@ fn report_local_value_does_not_live_long_enough(
                     format!(
                         "...but `{}` will be dropped here, when the function `{}` returns",
                         name,
-                        self.infcx.tcx.hir().name_by_hir_id(fn_hir_id),
+                        self.infcx.tcx.hir().name(fn_hir_id),
                     ),
                 );
 
index 7eb296353a4949b71e43f4d3ed5bfc6db25cfcf0..27049119b2615220c004b54aa420045150e75d9c 100644 (file)
@@ -349,7 +349,7 @@ fn describe_field_from_ty(
                     let (&var_id, _) = self.infcx.tcx.upvars(def_id).unwrap()
                         .get_index(field.index()).unwrap();
 
-                    self.infcx.tcx.hir().name_by_hir_id(var_id).to_string()
+                    self.infcx.tcx.hir().name(var_id).to_string()
                 }
                 _ => {
                     // Might need a revision when the fields in trait RFC is implemented
index 72e392fdddc8a80c4641538eb6f9e49f4975b39d..a78bf0356d12affeb9d6c29ce0da46f64e2c84bf 100644 (file)
@@ -130,7 +130,7 @@ fn do_mir_borrowck<'a, 'tcx>(
                 ty::UpvarCapture::ByRef(..) => true,
             };
             let mut upvar = Upvar {
-                name: tcx.hir().name_by_hir_id(var_hir_id),
+                name: tcx.hir().name(var_hir_id),
                 var_hir_id,
                 by_ref,
                 mutability: Mutability::Not,
index 59fc4113794a45ff8ecbaa0d68d221f768a60f19..750a1324faeb3de025ba76910d2d1e0d6086aa0e 100644 (file)
@@ -72,7 +72,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         let upvar_hir_id = upvars[upvar_index].var_hir_id;
         debug!("get_upvar_name_and_span_for_region: upvar_hir_id={:?}", upvar_hir_id);
 
-        let upvar_name = tcx.hir().name_by_hir_id(upvar_hir_id);
+        let upvar_name = tcx.hir().name(upvar_hir_id);
         let upvar_span = tcx.hir().span(upvar_hir_id);
         debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}",
                upvar_name, upvar_span);
index fa3c7b9613e19906274cfc55df7f6f8ab2d875bc..a85f4776a8bee2638def80071668c35cb35cb875 100644 (file)
@@ -767,7 +767,7 @@ fn for_each_late_bound_region_defined_on<'tcx>(
                 owner: fn_def_id.index,
                 local_id: *late_bound,
             };
-            let name = tcx.hir().name_by_hir_id(hir_id).as_interned_str();
+            let name = tcx.hir().name(hir_id).as_interned_str();
             let region_def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
             let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
                 scope: fn_def_id,
index baf9086a4800e4a0ab184c075c5c5759f87947bd..597f172da671f52c02e02a00011bd22d13d4316b 100644 (file)
@@ -914,7 +914,7 @@ fn convert_path_expr<'a, 'tcx>(
             let generics = cx.tcx.generics_of(item_def_id);
             let local_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
             let index = generics.param_def_id_to_index[&local_def_id];
-            let name = cx.tcx.hir().name_by_hir_id(hir_id).as_interned_str();
+            let name = cx.tcx.hir().name(hir_id).as_interned_str();
             let val = ConstValue::Param(ty::ParamConst::new(index, name));
             ExprKind::Literal {
                 literal: cx.tcx.mk_const(
index 267f3798bd1e3d619b9e359a21f7f0c386efd7d1..514a400d90e8c781e917c5ecefebd299fad83dab 100644 (file)
@@ -123,7 +123,7 @@ pub fn ast_region_to_region(&self,
     {
         let tcx = self.tcx();
         let lifetime_name = |def_id| {
-            tcx.hir().name_by_hir_id(tcx.hir().as_local_hir_id(def_id).unwrap()).as_interned_str()
+            tcx.hir().name(tcx.hir().as_local_hir_id(def_id).unwrap()).as_interned_str()
         };
 
         let r = match tcx.named_region(lifetime.hir_id) {
@@ -2004,7 +2004,7 @@ pub fn res_to_ty(&self,
                 let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
                 let generics = tcx.generics_of(item_def_id);
                 let index = generics.param_def_id_to_index[&def_id];
-                tcx.mk_ty_param(index, tcx.hir().name_by_hir_id(hir_id).as_interned_str())
+                tcx.mk_ty_param(index, tcx.hir().name(hir_id).as_interned_str())
             }
             Res::SelfTy(Some(_), None) => {
                 // `Self` in trait or type alias.
@@ -2194,7 +2194,7 @@ pub fn ast_const_to_const(
             let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
             let generics = tcx.generics_of(item_def_id);
             let index = generics.param_def_id_to_index[&tcx.hir().local_def_id_from_hir_id(hir_id)];
-            let name = tcx.hir().name_by_hir_id(hir_id).as_interned_str();
+            let name = tcx.hir().name(hir_id).as_interned_str();
             const_.val = ConstValue::Param(ty::ParamConst::new(index, name));
         }
 
index bba108aa282a9db653b7435058771683bc2e3032..ac39757df74dc38b69a94e707bd4b9f0815f246a 100644 (file)
@@ -652,5 +652,5 @@ fn mutate(
 }
 
 fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> ast::Name {
-    tcx.hir().name_by_hir_id(var_hir_id)
+    tcx.hir().name(var_hir_id)
 }
index 68b96a408294b9429aff7b525d47d575ef6355f5..e6f09927796fae3705187b417b0c7db2af2de696 100644 (file)
@@ -246,7 +246,7 @@ fn fold_item(&mut self, mut item: Item) -> Option<Item> {
                     match parent_node.or(self.mod_ids.last().cloned()) {
                         Some(parent) if parent != hir::CRATE_HIR_ID => {
                             // FIXME: can we pull the parent module's name from elsewhere?
-                            Some(self.cx.tcx.hir().name_by_hir_id(parent).to_string())
+                            Some(self.cx.tcx.hir().name(parent).to_string())
                         }
                         _ => None,
                     }