@@ -198,8 +198,8 @@ declare_clippy_lint! {
198
198
/// );
199
199
/// span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg);
200
200
/// span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg);
201
- /// span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, expr.span, note_msg);
202
- /// span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, expr.span , note_msg);
201
+ /// span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some( expr.span) , note_msg);
202
+ /// span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, None , note_msg);
203
203
/// ```
204
204
pub COLLAPSIBLE_SPAN_LINT_CALLS ,
205
205
internal,
@@ -486,15 +486,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CollapsibleCalls {
486
486
} ,
487
487
"span_note" if sle. eq_expr( & and_then_args[ 2 ] , & span_call_args[ 1 ] ) => {
488
488
let note_snippet = snippet( cx, span_call_args[ 2 ] . span, r#""...""# ) ;
489
- suggest_note( cx, expr, & and_then_snippets, note_snippet. borrow( ) ) ;
489
+ suggest_note( cx, expr, & and_then_snippets, note_snippet. borrow( ) , true ) ;
490
490
} ,
491
491
"help" => {
492
492
let help_snippet = snippet( cx, span_call_args[ 1 ] . span, r#""...""# ) ;
493
493
suggest_help( cx, expr, & and_then_snippets, help_snippet. borrow( ) , false ) ;
494
494
}
495
495
"note" => {
496
496
let note_snippet = snippet( cx, span_call_args[ 1 ] . span, r#""...""# ) ;
497
- suggest_note( cx, expr, & and_then_snippets, note_snippet. borrow( ) ) ;
497
+ suggest_note( cx, expr, & and_then_snippets, note_snippet. borrow( ) , false ) ;
498
498
}
499
499
_ => ( ) ,
500
500
}
@@ -606,7 +606,19 @@ fn suggest_help(
606
606
) ;
607
607
}
608
608
609
- fn suggest_note ( cx : & LateContext < ' _ , ' _ > , expr : & Expr < ' _ > , and_then_snippets : & AndThenSnippets < ' _ > , note : & str ) {
609
+ fn suggest_note (
610
+ cx : & LateContext < ' _ , ' _ > ,
611
+ expr : & Expr < ' _ > ,
612
+ and_then_snippets : & AndThenSnippets < ' _ > ,
613
+ note : & str ,
614
+ with_span : bool ,
615
+ ) {
616
+ let note_span = if with_span {
617
+ format ! ( "Some({})" , and_then_snippets. span)
618
+ } else {
619
+ "None" . to_string ( )
620
+ } ;
621
+
610
622
span_lint_and_sugg (
611
623
cx,
612
624
COLLAPSIBLE_SPAN_LINT_CALLS ,
@@ -619,7 +631,7 @@ fn suggest_note(cx: &LateContext<'_, '_>, expr: &Expr<'_>, and_then_snippets: &A
619
631
and_then_snippets. lint,
620
632
and_then_snippets. span,
621
633
and_then_snippets. msg,
622
- and_then_snippets . span ,
634
+ note_span ,
623
635
note
624
636
) ,
625
637
Applicability :: MachineApplicable ,
0 commit comments