-/// This function returns true if the given expression is the `else` or `if else` part of an if
-/// statement
-pub fn parent_node_is_if_expr(expr: &Expr<'_>, cx: &LateContext<'_>) -> bool {
- let map = cx.tcx.hir();
- let parent_id = map.get_parent_node(expr.hir_id);
- let parent_node = map.get(parent_id);
- matches!(
- parent_node,
- Node::Expr(Expr {
- kind: ExprKind::If(_, _, _),
+/// Checks if the given function kind is an async function.
+pub fn is_async_fn(kind: FnKind<'_>) -> bool {
+ matches!(kind, FnKind::ItemFn(_, _, header, _) if header.asyncness == IsAsync::Async)
+}
+
+/// Peels away all the compiler generated code surrounding the body of an async function,
+pub fn get_async_fn_body(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Option<&'tcx Expr<'tcx>> {
+ if let ExprKind::Call(
+ _,
+ &[Expr {
+ kind: ExprKind::Closure(_, _, body, _, _),