]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/borrow_check/error_reporting.rs
Various minor/cosmetic improvements to code
[rust.git] / src / librustc_mir / borrow_check / error_reporting.rs
index ba26ed36c20f4a6f5749592f22c0c403395cbdeb..598c2f810beb76958c76a5ffe1180240e7cdd046 100644 (file)
@@ -195,8 +195,8 @@ pub(super) fn report_use_of_moved_or_uninitialized(
                 let needs_note = match ty.sty {
                     ty::Closure(id, _) => {
                         let tables = self.infcx.tcx.typeck_tables_of(id);
-                        let node_id = self.infcx.tcx.hir.as_local_node_id(id).unwrap();
-                        let hir_id = self.infcx.tcx.hir.node_to_hir_id(node_id);
+                        let node_id = self.infcx.tcx.hir().as_local_node_id(id).unwrap();
+                        let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id);
 
                         tables.closure_kind_origins().get(hir_id).is_none()
                     }
@@ -720,13 +720,13 @@ fn report_local_value_does_not_live_long_enough(
                 format!("`{}` would have to be valid for `{}`...", name, region_name),
             );
 
-            if let Some(fn_node_id) = self.infcx.tcx.hir.as_local_node_id(self.mir_def_id) {
+            if let Some(fn_node_id) = self.infcx.tcx.hir().as_local_node_id(self.mir_def_id) {
                 err.span_label(
                     drop_span,
                     format!(
                         "...but `{}` will be dropped here, when the function `{}` returns",
                         name,
-                        self.infcx.tcx.hir.name(fn_node_id),
+                        self.infcx.tcx.hir().name(fn_node_id),
                     ),
                 );
 
@@ -1064,7 +1064,7 @@ fn report_escaping_data(
 
         let escapes_from = if tcx.is_closure(self.mir_def_id) {
             let tables = tcx.typeck_tables_of(self.mir_def_id);
-            let mir_hir_id = tcx.hir.def_index_to_hir_id(self.mir_def_id.index);
+            let mir_hir_id = tcx.hir().def_index_to_hir_id(self.mir_def_id.index);
             match tables.node_id_to_type(mir_hir_id).sty {
                 ty::Closure(..) => "closure",
                 ty::Generator(..) => "generator",
@@ -1249,7 +1249,7 @@ pub(super) fn report_illegal_mutation_of_borrowed(
     /// (part of) a non-`mut` local that occurs potentially after that
     /// local has already been initialized. `place` is the path being
     /// assigned; `err_place` is a place providing a reason why
-    /// `place` is not mutable (e.g. the non-`mut` local `x` in an
+    /// `place` is not mutable (e.g., the non-`mut` local `x` in an
     /// assignment to `x.f`).
     pub(super) fn report_illegal_reassignment(
         &mut self,
@@ -1412,11 +1412,11 @@ pub(super) fn add_closure_invoked_twice_with_moved_variable_suggestion(
                 );
 
                 if let ty::TyKind::Closure(did, _substs) = self.mir.local_decls[closure].ty.sty {
-                    let node_id = match self.infcx.tcx.hir.as_local_node_id(did) {
+                    let node_id = match self.infcx.tcx.hir().as_local_node_id(did) {
                         Some(node_id) => node_id,
                         _ => return,
                     };
-                    let hir_id = self.infcx.tcx.hir.node_to_hir_id(node_id);
+                    let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id);
 
                     if let Some((
                         span, name
@@ -1654,12 +1654,12 @@ fn describe_field_from_ty(&self, ty: &ty::Ty, field: Field) -> String {
                     // the local code in the current crate, so this returns an `Option` in case
                     // the closure comes from another crate. But in that case we wouldn't
                     // be borrowck'ing it, so we can just unwrap:
-                    let node_id = self.infcx.tcx.hir.as_local_node_id(def_id).unwrap();
+                    let node_id = self.infcx.tcx.hir().as_local_node_id(def_id).unwrap();
                     let freevar = self.infcx
                         .tcx
                         .with_freevars(node_id, |fv| fv[field.index()]);
 
-                    self.infcx.tcx.hir.name(freevar.var_id()).to_string()
+                    self.infcx.tcx.hir().name(freevar.var_id()).to_string()
                 }
                 _ => {
                     // Might need a revision when the fields in trait RFC is implemented
@@ -1980,8 +1980,8 @@ fn annotate_fn_sig(
     ) -> Option<AnnotatedBorrowFnSignature> {
         debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
         let is_closure = self.infcx.tcx.is_closure(did);
-        let fn_node_id = self.infcx.tcx.hir.as_local_node_id(did)?;
-        let fn_decl = self.infcx.tcx.hir.fn_decl(fn_node_id)?;
+        let fn_node_id = self.infcx.tcx.hir().as_local_node_id(did)?;
+        let fn_decl = self.infcx.tcx.hir().fn_decl(fn_node_id)?;
 
         // We need to work out which arguments to highlight. We do this by looking
         // at the return type, where there are three cases:
@@ -2423,8 +2423,8 @@ fn closure_span(
             "closure_span: def_id={:?} target_place={:?} places={:?}",
             def_id, target_place, places
         );
-        let node_id = self.infcx.tcx.hir.as_local_node_id(def_id)?;
-        let expr = &self.infcx.tcx.hir.expect_expr(node_id).node;
+        let node_id = self.infcx.tcx.hir().as_local_node_id(def_id)?;
+        let expr = &self.infcx.tcx.hir().expect_expr(node_id).node;
         debug!("closure_span: node_id={:?} expr={:?}", node_id, expr);
         if let hir::ExprKind::Closure(
             .., args_span, _