about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_typeck/src/check/fn_ctxt/checks.rs9
-rw-r--r--src/test/ui/chalkify/bugs/async.stderr11
2 files changed, 12 insertions, 8 deletions
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
index 550c3395d3c..5a2a68d0604 100644
--- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
+++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
@@ -1622,6 +1622,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     ) {
         let (traits::ExprItemObligation(def_id, hir_id, idx) | traits::ExprBindingObligation(def_id, _, hir_id, idx))
             = *error.obligation.cause.code().peel_derives() else { return; };
+
+        // Skip over mentioning async lang item
+        if Some(def_id) == self.tcx.lang_items().from_generator_fn()
+            && error.obligation.cause.span.desugaring_kind()
+                == Some(rustc_span::DesugaringKind::Async)
+        {
+            return;
+        }
+
         let Some(unsubstituted_pred) =
             self.tcx.predicates_of(def_id).instantiate_identity(self.tcx).predicates.into_iter().nth(idx) else { return; };
 
diff --git a/src/test/ui/chalkify/bugs/async.stderr b/src/test/ui/chalkify/bugs/async.stderr
index 91b4f7879e4..f53ed53f73c 100644
--- a/src/test/ui/chalkify/bugs/async.stderr
+++ b/src/test/ui/chalkify/bugs/async.stderr
@@ -2,13 +2,10 @@ error[E0277]: the trait bound `[static generator@$DIR/async.rs:7:29: 9:2]: Gener
   --> $DIR/async.rs:7:29
    |
 LL |   async fn foo(x: u32) -> u32 {
-   |  _____________________________-
+   |  _____________________________^
 LL | |     x
 LL | | }
-   | | ^
-   | | |
-   | |_the trait `Generator<ResumeTy>` is not implemented for `[static generator@$DIR/async.rs:7:29: 9:2]`
-   |   required by a bound introduced by this call
+   | |_^ the trait `Generator<ResumeTy>` is not implemented for `[static generator@$DIR/async.rs:7:29: 9:2]`
    |
 note: required by a bound in `std::future::from_generator`
   --> $SRC_DIR/core/src/future/mod.rs:LL:COL
@@ -23,9 +20,7 @@ LL |   async fn foo(x: u32) -> u32 {
    |  _____________________________^
 LL | |     x
 LL | | }
-   | | ^ required by a bound introduced by this call
-   | |_|
-   | 
+   | |_^
    |
 note: required by a bound in `std::future::from_generator`
   --> $SRC_DIR/core/src/future/mod.rs:LL:COL