use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;
use rustc_hir::{
- Term, AsyncGeneratorKind, Block, Body, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound, HirId,
- IsAsync, ItemKind, LifetimeName, TraitRef, Ty, TyKind, TypeBindingKind,
+ AsyncGeneratorKind, Block, Body, Closure, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound,
+ HirId, IsAsync, ItemKind, LifetimeName, Term, TraitRef, Ty, TyKind, TypeBindingKind,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
diag.span_suggestion(
block.span,
"move the body of the async block to the enclosing function",
- body_snip.to_string(),
+ body_snip,
Applicability::MachineApplicable
);
}
if let Some(block_expr) = block.expr;
if let Some(args) = match_function_call(cx, block_expr, &FUTURE_FROM_GENERATOR);
if args.len() == 1;
- if let Expr{kind: ExprKind::Closure(_, _, body_id, ..), ..} = args[0];
- let closure_body = cx.tcx.hir().body(body_id);
+ if let Expr{kind: ExprKind::Closure(&Closure { body, .. }), ..} = args[0];
+ let closure_body = cx.tcx.hir().body(body);
if closure_body.generator_kind == Some(GeneratorKind::Async(AsyncGeneratorKind::Block));
then {
return Some(closure_body);