Skip to content

Commit 233f832

Browse files
committed
Replace complicated hir access with tcx.coroutine_kind
1 parent 4762f92 commit 233f832

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,10 +1836,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
18361836
if should_suggest_fixes
18371837
&& !matches!(terr, TypeError::RegionsInsufficientlyPolymorphic(..))
18381838
{
1839-
let hir = self.tcx.hir_node_by_def_id(cause.body_id);
18401839
self.suggest_tuple_pattern(cause, &exp_found, diag);
18411840
self.suggest_accessing_field_where_appropriate(cause, &exp_found, diag);
1842-
self.suggest_await_on_expect_found(cause, span, hir, &exp_found, diag);
1841+
self.suggest_await_on_expect_found(cause, span, &exp_found, diag);
18431842
self.suggest_function_pointers(cause, span, &exp_found, diag);
18441843
self.suggest_turning_stmt_into_expr(cause, &exp_found, diag);
18451844
}

compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
159159
&self,
160160
cause: &ObligationCause<'tcx>,
161161
exp_span: Span,
162-
hir: hir::Node<'_>,
163162
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
164163
diag: &mut Diag<'_>,
165164
) {
@@ -169,17 +168,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
169168
);
170169

171170
let is_async_block = matches!(
172-
hir,
173-
rustc_hir::Node::Expr(rustc_hir::Expr {
174-
kind: rustc_hir::ExprKind::Closure(rustc_hir::Closure {
175-
kind: rustc_hir::ClosureKind::Coroutine(rustc_hir::CoroutineKind::Desugared(
176-
rustc_hir::CoroutineDesugaring::Async,
177-
_
178-
)),
179-
..
180-
}),
181-
..
182-
})
171+
self.tcx.coroutine_kind(cause.body_id),
172+
Some(rustc_hir::CoroutineKind::Desugared(rustc_hir::CoroutineDesugaring::Async, _)),
183173
);
184174
if !is_async_block {
185175
return;

0 commit comments

Comments
 (0)