fix clippy author and failing test
This commit is contained in:
parent
17c7d21650
commit
67cc4b0cad
2 changed files with 9 additions and 4 deletions
|
@ -7,7 +7,7 @@ use rustc_ast::LitIntType;
|
|||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{
|
||||
ArrayLen, BindingAnnotation, Closure, ExprKind, FnRetTy, HirId, Lit, PatKind, QPath, StmtKind, TyKind,
|
||||
ArrayLen, BindingAnnotation, Closure, ExprKind, FnRetTy, HirId, Lit, PatKind, QPath, StmtKind, TyKind, CaptureBy
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
@ -479,6 +479,11 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
movability,
|
||||
..
|
||||
}) => {
|
||||
let capture_clause = match capture_clause {
|
||||
CaptureBy::Value { .. } => "Value { .. }",
|
||||
CaptureBy::Ref => "Ref",
|
||||
};
|
||||
|
||||
let movability = OptionPat::new(movability.map(|m| format!("Movability::{m:?}")));
|
||||
|
||||
let ret_ty = match fn_decl.output {
|
||||
|
@ -487,7 +492,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
};
|
||||
|
||||
bind!(self, fn_decl, body_id);
|
||||
kind!("Closure(CaptureBy::{capture_clause:?}, {fn_decl}, {body_id}, _, {movability})");
|
||||
kind!("Closure(CaptureBy::{capture_clause}, {fn_decl}, {body_id}, _, {movability})");
|
||||
chain!(self, "let {ret_ty} = {fn_decl}.output");
|
||||
self.body(body_id);
|
||||
},
|
||||
|
|
|
@ -40,10 +40,10 @@ if let ExprKind::Block(block, None) = expr.kind
|
|||
{
|
||||
// report your lint here
|
||||
}
|
||||
if let ExprKind::Closure(CaptureBy::Value, fn_decl, body_id, _, None) = expr.kind
|
||||
if let ExprKind::Closure(CaptureBy::Value { .. }, fn_decl, body_id, _, None) = expr.kind
|
||||
&& let FnRetTy::DefaultReturn(_) = fn_decl.output
|
||||
&& expr1 = &cx.tcx.hir().body(body_id).value
|
||||
&& let ExprKind::Closure(CaptureBy::Value, fn_decl1, body_id1, _, Some(Movability::Static)) = expr1.kind
|
||||
&& let ExprKind::Closure(CaptureBy::Value { .. }, fn_decl1, body_id1, _, Some(Movability::Static)) = expr1.kind
|
||||
&& let FnRetTy::DefaultReturn(_) = fn_decl1.output
|
||||
&& expr2 = &cx.tcx.hir().body(body_id1).value
|
||||
&& let ExprKind::Block(block, None) = expr2.kind
|
||||
|
|
Loading…
Add table
Reference in a new issue