1
Fork 0

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)) let (traits::ExprItemObligation(def_id, hir_id, idx) | traits::ExprBindingObligation(def_id, _, hir_id, idx))
= *error.obligation.cause.code().peel_derives() else { return; }; = *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) = let Some(unsubstituted_pred) =
self.tcx.predicates_of(def_id).instantiate_identity(self.tcx).predicates.into_iter().nth(idx) else { return; }; 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 --> $DIR/async.rs:7:29
| |
LL | async fn foo(x: u32) -> u32 { LL | async fn foo(x: u32) -> u32 {
| _____________________________- | _____________________________^
LL | | x LL | | x
LL | | } LL | | }
| | ^ | |_^ the trait `Generator<ResumeTy>` is not implemented for `[static generator@$DIR/async.rs:7:29: 9:2]`
| | |
| |_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
| |
note: required by a bound in `std::future::from_generator` note: required by a bound in `std::future::from_generator`
--> $SRC_DIR/core/src/future/mod.rs:LL:COL --> $SRC_DIR/core/src/future/mod.rs:LL:COL
@ -23,9 +20,7 @@ LL | async fn foo(x: u32) -> u32 {
| _____________________________^ | _____________________________^
LL | | x LL | | x
LL | | } LL | | }
| | ^ required by a bound introduced by this call | |_^
| |_|
|
| |
note: required by a bound in `std::future::from_generator` note: required by a bound in `std::future::from_generator`
--> $SRC_DIR/core/src/future/mod.rs:LL:COL --> $SRC_DIR/core/src/future/mod.rs:LL:COL