1
Fork 0

banish hir::GenericBound::LangItemTrait

This commit is contained in:
Michael Goulet 2023-11-23 04:55:03 +00:00
parent ad00641b74
commit fc010de26b
12 changed files with 68 additions and 135 deletions

View file

@ -4783,8 +4783,14 @@ pub fn suggest_desugaring_async_fn_to_impl_future_in_trait<'tcx>(
};
let future = tcx.hir_node_by_def_id(opaque_def_id).expect_item().expect_opaque_ty();
let Some(hir::GenericBound::LangItemTrait(_, _, _, generics)) = future.bounds.get(0) else {
// `async fn` should always lower to a lang item bound... but don't ICE.
let [hir::GenericBound::Trait(trait_ref, _)] = future.bounds else {
// `async fn` should always lower to a single bound... but don't ICE.
return None;
};
let Some(hir::PathSegment { args: Some(generics), .. }) =
trait_ref.trait_ref.path.segments.last()
else {
// desugaring to a single path segment for `Future<...>`.
return None;
};
let Some(hir::TypeBindingKind::Equality { term: hir::Term::Ty(future_output_ty) }) =