Skip mentioning lang item

This commit is contained in:
Michael Goulet 2022-08-16 23:28:20 +00:00
parent d05fea6ac4
commit c9cb19d26e
2 changed files with 12 additions and 8 deletions

View File

@ -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; };

View File

@ -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