11use clippy_utils:: attrs:: is_doc_hidden;
2- use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help, span_lint_and_note, span_lint_and_sugg } ;
2+ use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help, span_lint_and_note, span_lint_and_then } ;
33use clippy_utils:: source:: { first_line_of_span, snippet_with_applicability} ;
44use clippy_utils:: ty:: { implements_trait, is_type_diagnostic_item} ;
55use clippy_utils:: { is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty} ;
@@ -10,7 +10,7 @@ use rustc_ast::token::CommentKind;
1010use rustc_data_structures:: fx:: FxHashSet ;
1111use rustc_data_structures:: sync:: Lrc ;
1212use rustc_errors:: emitter:: EmitterWriter ;
13- use rustc_errors:: { Applicability , Handler } ;
13+ use rustc_errors:: { Applicability , Handler , SuggestionStyle } ;
1414use rustc_hir as hir;
1515use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
1616use rustc_hir:: { AnonConst , Expr , ExprKind , QPath } ;
@@ -770,14 +770,23 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span) {
770770 if has_underscore ( word) || word. contains ( "::" ) || is_camel_case ( word) {
771771 let mut applicability = Applicability :: MachineApplicable ;
772772
773- span_lint_and_sugg (
773+ span_lint_and_then (
774774 cx,
775775 DOC_MARKDOWN ,
776776 span,
777777 "item in documentation is missing backticks" ,
778- "try" ,
779- format ! ( "`{}`" , snippet_with_applicability( cx, span, ".." , & mut applicability) ) ,
780- applicability,
778+ |diag| {
779+ let snippet = snippet_with_applicability ( cx, span, ".." , & mut applicability) ;
780+ diag. span_suggestion_with_style (
781+ span,
782+ "try" ,
783+ format ! ( "`{}`" , snippet) ,
784+ applicability,
785+ // always show the suggestion in a separate line, since the
786+ // inline presentation adds another pair of backticks
787+ SuggestionStyle :: ShowAlways ,
788+ ) ;
789+ } ,
781790 ) ;
782791 }
783792}
0 commit comments