Skip to content

Commit 823bcb4

Browse files
Record asyncness span in HIR
1 parent 12815e9 commit 823bcb4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

clippy_lints/src/redundant_closure_call.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_hir::intravisit::{Visitor as HirVisitor, Visitor};
1010
use rustc_lint::{LateContext, LateLintPass};
1111
use rustc_middle::hir::nested_filter;
1212
use rustc_middle::lint::in_external_macro;
13+
use rustc_middle::ty;
1314
use rustc_session::{declare_lint_pass, declare_tool_lint};
1415

1516
declare_clippy_lint! {
@@ -84,7 +85,7 @@ fn find_innermost_closure<'tcx>(
8485
cx: &LateContext<'tcx>,
8586
mut expr: &'tcx hir::Expr<'tcx>,
8687
mut steps: usize,
87-
) -> Option<(&'tcx hir::Expr<'tcx>, &'tcx hir::FnDecl<'tcx>, hir::IsAsync)> {
88+
) -> Option<(&'tcx hir::Expr<'tcx>, &'tcx hir::FnDecl<'tcx>, ty::Asyncness)> {
8889
let mut data = None;
8990

9091
while let hir::ExprKind::Closure(closure) = expr.kind
@@ -98,9 +99,9 @@ fn find_innermost_closure<'tcx>(
9899
{
99100
expr = body.value;
100101
data = Some((body.value, closure.fn_decl, if is_async_closure(body) {
101-
hir::IsAsync::Async
102+
ty::Asyncness::Yes
102103
} else {
103-
hir::IsAsync::NotAsync
104+
ty::Asyncness::No
104105
}));
105106
steps -= 1;
106107
}

clippy_utils/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
9090
use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk};
9191
use rustc_hir::{
9292
self as hir, def, Arm, ArrayLen, BindingAnnotation, Block, BlockCheckMode, Body, Closure, Destination, Expr,
93-
ExprField, ExprKind, FnDecl, FnRetTy, GenericArgs, HirId, Impl, ImplItem, ImplItemKind, ImplItemRef, IsAsync, Item,
93+
ExprField, ExprKind, FnDecl, FnRetTy, GenericArgs, HirId, Impl, ImplItem, ImplItemKind, ImplItemRef, Item,
9494
ItemKind, LangItem, Local, MatchSource, Mutability, Node, OwnerId, Param, Pat, PatKind, Path, PathSegment, PrimTy,
9595
QPath, Stmt, StmtKind, TraitItem, TraitItemKind, TraitItemRef, TraitRef, TyKind, UnOp,
9696
};
@@ -1958,8 +1958,8 @@ pub fn if_sequence<'tcx>(mut expr: &'tcx Expr<'tcx>) -> (Vec<&'tcx Expr<'tcx>>,
19581958
/// Checks if the given function kind is an async function.
19591959
pub fn is_async_fn(kind: FnKind<'_>) -> bool {
19601960
match kind {
1961-
FnKind::ItemFn(_, _, header) => header.asyncness == IsAsync::Async,
1962-
FnKind::Method(_, sig) => sig.header.asyncness == IsAsync::Async,
1961+
FnKind::ItemFn(_, _, header) => header.asyncness .is_async(),
1962+
FnKind::Method(_, sig) => sig.header.asyncness.is_async(),
19631963
FnKind::Closure => false,
19641964
}
19651965
}

0 commit comments

Comments
 (0)