Skip to content

Commit c9cb19d

Browse files
Skip mentioning lang item
1 parent d05fea6 commit c9cb19d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16221622
) {
16231623
let (traits::ExprItemObligation(def_id, hir_id, idx) | traits::ExprBindingObligation(def_id, _, hir_id, idx))
16241624
= *error.obligation.cause.code().peel_derives() else { return; };
1625+
1626+
// Skip over mentioning async lang item
1627+
if Some(def_id) == self.tcx.lang_items().from_generator_fn()
1628+
&& error.obligation.cause.span.desugaring_kind()
1629+
== Some(rustc_span::DesugaringKind::Async)
1630+
{
1631+
return;
1632+
}
1633+
16251634
let Some(unsubstituted_pred) =
16261635
self.tcx.predicates_of(def_id).instantiate_identity(self.tcx).predicates.into_iter().nth(idx) else { return; };
16271636

src/test/ui/chalkify/bugs/async.stderr

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ error[E0277]: the trait bound `[static generator@$DIR/async.rs:7:29: 9:2]: Gener
22
--> $DIR/async.rs:7:29
33
|
44
LL | async fn foo(x: u32) -> u32 {
5-
| _____________________________-
5+
| _____________________________^
66
LL | | x
77
LL | | }
8-
| | ^
9-
| | |
10-
| |_the trait `Generator<ResumeTy>` is not implemented for `[static generator@$DIR/async.rs:7:29: 9:2]`
11-
| required by a bound introduced by this call
8+
| |_^ the trait `Generator<ResumeTy>` is not implemented for `[static generator@$DIR/async.rs:7:29: 9:2]`
129
|
1310
note: required by a bound in `std::future::from_generator`
1411
--> $SRC_DIR/core/src/future/mod.rs:LL:COL
@@ -23,9 +20,7 @@ LL | async fn foo(x: u32) -> u32 {
2320
| _____________________________^
2421
LL | | x
2522
LL | | }
26-
| | ^ required by a bound introduced by this call
27-
| |_|
28-
|
23+
| |_^
2924
|
3025
note: required by a bound in `std::future::from_generator`
3126
--> $SRC_DIR/core/src/future/mod.rs:LL:COL

0 commit comments

Comments
 (0)