1
1
use 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 } ;
3
3
use clippy_utils:: source:: { first_line_of_span, snippet_with_applicability} ;
4
4
use clippy_utils:: ty:: { implements_trait, is_type_diagnostic_item} ;
5
5
use 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;
10
10
use rustc_data_structures:: fx:: FxHashSet ;
11
11
use rustc_data_structures:: sync:: Lrc ;
12
12
use rustc_errors:: emitter:: EmitterWriter ;
13
- use rustc_errors:: { Applicability , Handler } ;
13
+ use rustc_errors:: { Applicability , Handler , SuggestionStyle } ;
14
14
use rustc_hir as hir;
15
15
use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
16
16
use rustc_hir:: { AnonConst , Expr , ExprKind , QPath } ;
@@ -770,14 +770,23 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span) {
770
770
if has_underscore ( word) || word. contains ( "::" ) || is_camel_case ( word) {
771
771
let mut applicability = Applicability :: MachineApplicable ;
772
772
773
- span_lint_and_sugg (
773
+ span_lint_and_then (
774
774
cx,
775
775
DOC_MARKDOWN ,
776
776
span,
777
777
"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
+ } ,
781
790
) ;
782
791
}
783
792
}
0 commit comments