about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_middle/ty/error.rs4
-rw-r--r--src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/librustc_middle/ty/error.rs b/src/librustc_middle/ty/error.rs
index 4b0b648b3b4..16da3eac875 100644
--- a/src/librustc_middle/ty/error.rs
+++ b/src/librustc_middle/ty/error.rs
@@ -698,7 +698,9 @@ impl<T> Trait<T> for X {
             suggested |=
                 self.suggest_constraint(db, &msg, body_owner_def_id, proj_ty, values.found);
         }
-        if let (Some(hir_id), false) = (self.hir().as_local_hir_id(body_owner_def_id), suggested) {
+        if let (Some(hir_id), false) =
+            (body_owner_def_id.as_local().map(|id| self.hir().as_local_hir_id(id)), suggested)
+        {
             // When `body_owner` is an `impl` or `trait` item, look in its associated types for
             // `expected` and point at it.
             let parent_id = self.hir().get_parent_item(hir_id);
diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
index 0e68e81d7ab..52e13dbc2dd 100644
--- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
+++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
@@ -38,8 +38,6 @@ LL |     Pin::new(x)
    |
    = note:      expected struct `std::boxed::Box<dyn std::future::Future<Output = i32> + std::marker::Send>`
            found type parameter `F`
-   = help: type parameters must be constrained to match other types
-   = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
 
 error[E0277]: `dyn std::future::Future<Output = i32> + std::marker::Send` cannot be unpinned