@@ -418,7 +418,7 @@ impl EarlyLintPass for CollapsibleCalls {
418
418
if let ExprKind :: Block ( block, _) = & block. kind;
419
419
let stmts = & block. stmts;
420
420
if stmts. len( ) == 1 ;
421
- if let StmtKind :: Expr ( only_expr) = & stmts[ 0 ] . kind;
421
+ if let StmtKind :: Semi ( only_expr) = & stmts[ 0 ] . kind;
422
422
if let ExprKind :: MethodCall ( ref ps, ref span_call_args) = & only_expr. kind;
423
423
let and_then_args = get_and_then_args( cx, and_then_args) ;
424
424
then {
@@ -480,7 +480,6 @@ fn suggestion_args<'a>(cx: &EarlyContext<'_>, span_call_args: &Vec<P<AstExpr>>)
480
480
481
481
fn suggest_span_suggestion ( cx : & EarlyContext < ' _ > , expr : & AstExpr , and_then_args : AndThenArgs < ' _ > , suggestion_args : SuggestionArgs < ' _ > ) {
482
482
if and_then_args. span == suggestion_args. span {
483
- println ! ( "suggestion true" ) ;
484
483
span_lint_and_sugg (
485
484
cx,
486
485
COLLAPSIBLE_SPAN_LINT_CALLS ,
@@ -499,6 +498,16 @@ fn suggest_span_suggestion(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args:
499
498
) ,
500
499
Applicability :: MachineApplicable
501
500
) ;
501
+ } else {
502
+ span_lint_and_sugg (
503
+ cx,
504
+ COLLAPSIBLE_SPAN_LINT_CALLS ,
505
+ expr. span ,
506
+ "Lint activated" ,
507
+ "Lint helped" ,
508
+ "modify to" . to_string ( ) ,
509
+ Applicability :: MachineApplicable
510
+ )
502
511
}
503
512
}
504
513
@@ -562,11 +571,12 @@ fn suggest_span_note(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args: AndTh
562
571
"this call is collspible" ,
563
572
"collapse into" ,
564
573
format ! (
565
- "span_lint_and_note({},{}, {}, {}, {})" ,
574
+ "span_lint_and_note({}, {}, {}, {}, {}, {})" ,
566
575
and_then_args. cx,
567
576
and_then_args. lint,
568
577
and_then_args. span,
569
578
and_then_args. msg,
579
+ and_then_args. span,
570
580
note_args. note
571
581
) ,
572
582
Applicability :: MachineApplicable
@@ -575,5 +585,5 @@ fn suggest_span_note(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args: AndTh
575
585
}
576
586
577
587
fn snippet < ' a > ( cx : & EarlyContext < ' _ > , span : Span ) -> Cow < ' a , str > {
578
- other_snippet ( cx, span, "Should not be" )
588
+ other_snippet ( cx, span, "Should not be this snippet " )
579
589
}
0 commit comments