@@ -198,8 +198,8 @@ declare_clippy_lint! {
198198 /// );
199199 /// span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg);
200200 /// 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);
203203 /// ```
204204 pub COLLAPSIBLE_SPAN_LINT_CALLS ,
205205 internal,
@@ -486,15 +486,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CollapsibleCalls {
486486 } ,
487487 "span_note" if sle. eq_expr( & and_then_args[ 2 ] , & span_call_args[ 1 ] ) => {
488488 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 ) ;
490490 } ,
491491 "help" => {
492492 let help_snippet = snippet( cx, span_call_args[ 1 ] . span, r#""...""# ) ;
493493 suggest_help( cx, expr, & and_then_snippets, help_snippet. borrow( ) , false ) ;
494494 }
495495 "note" => {
496496 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 ) ;
498498 }
499499 _ => ( ) ,
500500 }
@@ -606,7 +606,19 @@ fn suggest_help(
606606 ) ;
607607}
608608
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+
610622 span_lint_and_sugg (
611623 cx,
612624 COLLAPSIBLE_SPAN_LINT_CALLS ,
@@ -619,7 +631,7 @@ fn suggest_note(cx: &LateContext<'_, '_>, expr: &Expr<'_>, and_then_snippets: &A
619631 and_then_snippets. lint,
620632 and_then_snippets. span,
621633 and_then_snippets. msg,
622- and_then_snippets . span ,
634+ note_span ,
623635 note
624636 ) ,
625637 Applicability :: MachineApplicable ,
0 commit comments