about summary refs log tree commit diff
path: root/src/librustc_trait_selection
diff options
context:
space:
mode:
authormarmeladema <xademax@gmail.com>2020-04-16 20:36:32 +0100
committermarmeladema <xademax@gmail.com>2020-04-23 23:14:07 +0100
commitbfce24aa675072c832e5160acdefc4e98b7fe8f3 (patch)
tree0f34ec764cbfad806fa1880f0125edf93b0af9e6 /src/librustc_trait_selection
parent6148db719f34a35099eff46097b5d2d9770892e9 (diff)
Modify `as_local_hir_id` to return a bare `HirId`
Diffstat (limited to 'src/librustc_trait_selection')
-rw-r--r--src/librustc_trait_selection/opaque_types.rs4
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/mod.rs3
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/suggestions.rs6
-rw-r--r--src/librustc_trait_selection/traits/specialize/mod.rs2
4 files changed, 7 insertions, 8 deletions
diff --git a/src/librustc_trait_selection/opaque_types.rs b/src/librustc_trait_selection/opaque_types.rs
index 16fef2f6e36..8af9d7ea904 100644
--- a/src/librustc_trait_selection/opaque_types.rs
+++ b/src/librustc_trait_selection/opaque_types.rs
@@ -1037,7 +1037,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
                     // }
                     // ```
                     if let Some(opaque_hir_id) =
-                        def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id).unwrap())
+                        def_id.as_local().map(|def_id| tcx.hir().as_local_hir_id(def_id))
                     {
                         let parent_def_id = self.parent_def_id;
                         let def_scope_default = || {
@@ -1219,7 +1219,7 @@ pub fn may_define_opaque_type(
     def_id: LocalDefId,
     opaque_hir_id: hir::HirId,
 ) -> bool {
-    let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
+    let mut hir_id = tcx.hir().as_local_hir_id(def_id);
 
     // Named opaque types can be defined by any siblings or children of siblings.
     let scope = tcx.hir().get_defining_scope(opaque_hir_id);
diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs
index c6c9b068a5e..fa9f1c9a7d9 100644
--- a/src/librustc_trait_selection/traits/error_reporting/mod.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs
@@ -507,8 +507,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                             self.tcx.sess.source_map().guess_head_span(
                                 self.tcx.hir().span_if_local(closure_def_id).unwrap(),
                             );
-                        let hir_id =
-                            self.tcx.hir().as_local_hir_id(closure_def_id.expect_local()).unwrap();
+                        let hir_id = self.tcx.hir().as_local_hir_id(closure_def_id.expect_local());
                         let mut err = struct_span_err!(
                             self.tcx.sess,
                             closure_span,
diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
index b6d592b3143..88b9d257795 100644
--- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
@@ -430,7 +430,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
             };
 
         let hir = self.tcx.hir();
-        let hir_id = hir.as_local_hir_id(def_id.as_local()?)?;
+        let hir_id = hir.as_local_hir_id(def_id.as_local()?);
         let parent_node = hir.get_parent_node(hir_id);
         match hir.find(parent_node) {
             Some(hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(local), .. })) => {
@@ -1237,7 +1237,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
 
         let generator_body = generator_did
             .as_local()
-            .map(|def_id| hir.as_local_hir_id(def_id).unwrap())
+            .map(|def_id| hir.as_local_hir_id(def_id))
             .and_then(|hir_id| hir.maybe_body_owned_by(hir_id))
             .map(|body_id| hir.body(body_id));
         let mut visitor = AwaitsVisitor::default();
@@ -1388,7 +1388,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                             .tcx
                             .parent(generator_did)
                             .and_then(|parent_did| parent_did.as_local())
-                            .and_then(|parent_did| hir.as_local_hir_id(parent_did))
+                            .map(|parent_did| hir.as_local_hir_id(parent_did))
                             .and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
                             .map(|name| {
                                 format!("future returned by `{}` is not {}", name, trait_name)
diff --git a/src/librustc_trait_selection/traits/specialize/mod.rs b/src/librustc_trait_selection/traits/specialize/mod.rs
index 95bc64fdaff..61583669c6b 100644
--- a/src/librustc_trait_selection/traits/specialize/mod.rs
+++ b/src/librustc_trait_selection/traits/specialize/mod.rs
@@ -452,7 +452,7 @@ fn report_conflicting_impls(
             };
             tcx.struct_span_lint_hir(
                 lint,
-                tcx.hir().as_local_hir_id(impl_def_id).unwrap(),
+                tcx.hir().as_local_hir_id(impl_def_id),
                 impl_span,
                 decorate,
             )