@@ -3,7 +3,7 @@ use clippy_utils::source::snippet_with_applicability;
3
3
use clippy_utils:: { fn_def_id, match_def_path} ;
4
4
use rustc_errors:: Applicability ;
5
5
use rustc_hir:: def:: Res ;
6
- use rustc_hir:: * ;
6
+ use rustc_hir:: { Block , Closure , Expr , ExprKind , FnDecl , HirId , Node , Pat , Path , QPath , Ty } ;
7
7
use rustc_lint:: { LateContext , LateLintPass } ;
8
8
use rustc_session:: declare_lint_pass;
9
9
use rustc_span:: Span ;
@@ -19,12 +19,12 @@ declare_clippy_lint! {
19
19
///
20
20
/// ### Example
21
21
/// ```no_run
22
- /// let x = Some("foo".to_string());
23
- /// let _y = x.clone().and_then(|v| v.starts_with('f').then_some(v));
22
+ /// let x = Some("foo".to_string());
23
+ /// let _y = x.clone().and_then(|v| v.starts_with('f').then_some(v));
24
24
/// ```
25
25
/// Use instead:
26
26
/// ```no_run
27
- /// let x = Some("foo".to_string());
27
+ /// let x = Some("foo".to_string());
28
28
/// let _y = x.clone().filter(|v| v.starts_with('f'));
29
29
/// ```
30
30
#[ clippy:: version = "1.81.0" ]
@@ -40,9 +40,7 @@ declare_lint_pass!(AndThenThenSome => [AND_THEN_THEN_SOME]);
40
40
impl < ' tcx > LateLintPass < ' tcx > for AndThenThenSome {
41
41
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
42
42
match expr. kind {
43
- ExprKind :: MethodCall ( _, selfarg, [ arg] , _) |
44
- ExprKind :: Call ( _, [ selfarg, arg] )
45
- => {
43
+ ExprKind :: MethodCall ( _, selfarg, [ arg] , _) | ExprKind :: Call ( _, [ selfarg, arg] ) => {
46
44
// TODO: check if type of reciever is diagnostic item Option?
47
45
if is_and_then ( cx, expr) {
48
46
if let Some ( ( closure_args, predicate) ) = then_some_closure_arg ( cx, arg) {
@@ -91,8 +89,7 @@ fn peel_closure_body<'tcx>(
91
89
} ,
92
90
_,
93
91
) => peel_closure_body ( cx, wrapped_expr, closure_arg_id) ,
94
- ExprKind :: MethodCall ( _, pred, [ arg] , _) |
95
- ExprKind :: Call ( _, [ pred, arg] ) => {
92
+ ExprKind :: MethodCall ( _, pred, [ arg] , _) | ExprKind :: Call ( _, [ pred, arg] ) => {
96
93
if is_then_some ( cx, expr) && is_local_defined_at ( cx, arg, closure_arg_id) {
97
94
Some ( pred)
98
95
} else {
0 commit comments