1
1
use clippy_utils:: attrs:: is_doc_hidden;
2
- use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help, span_lint_and_then } ;
2
+ use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help} ;
3
3
use clippy_utils:: macros:: { is_panic, root_macro_call_first_node} ;
4
4
use clippy_utils:: ty:: is_type_diagnostic_item;
5
5
use clippy_utils:: visitors:: Visitable ;
@@ -10,10 +10,7 @@ use pulldown_cmark::Event::{
10
10
use pulldown_cmark:: Tag :: { CodeBlock , Heading , Item , Link , Paragraph } ;
11
11
use pulldown_cmark:: { BrokenLink , CodeBlockKind , CowStr , Options } ;
12
12
use rustc_ast:: ast:: Attribute ;
13
- use rustc_ast:: token:: CommentKind ;
14
- use rustc_ast:: { AttrKind , AttrStyle } ;
15
13
use rustc_data_structures:: fx:: FxHashSet ;
16
- use rustc_errors:: Applicability ;
17
14
use rustc_hir as hir;
18
15
use rustc_hir:: intravisit:: { self , Visitor } ;
19
16
use rustc_hir:: { AnonConst , Expr } ;
@@ -34,6 +31,7 @@ mod link_with_quotes;
34
31
mod markdown;
35
32
mod missing_headers;
36
33
mod needless_doctest_main;
34
+ mod suspicious_doc_comments;
37
35
38
36
declare_clippy_lint ! {
39
37
/// ### What it does
@@ -307,7 +305,6 @@ declare_clippy_lint! {
307
305
"suspicious usage of (outer) doc comments"
308
306
}
309
307
310
- #[ expect( clippy:: module_name_repetitions) ]
311
308
#[ derive( Clone ) ]
312
309
pub struct Doc {
313
310
valid_idents : FxHashSet < String > ,
@@ -450,7 +447,7 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
450
447
return None ;
451
448
}
452
449
453
- check_almost_inner_doc ( cx, attrs) ;
450
+ suspicious_doc_comments :: check ( cx, attrs) ;
454
451
455
452
let ( fragments, _) = attrs_to_doc_fragments ( attrs. iter ( ) . map ( |attr| ( attr, None ) ) , true ) ;
456
453
let mut doc = String :: new ( ) ;
@@ -480,43 +477,6 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
480
477
) )
481
478
}
482
479
483
- /// Looks for `///!` and `/**!` comments, which were probably meant to be `//!` and `/*!`
484
- fn check_almost_inner_doc ( cx : & LateContext < ' _ > , attrs : & [ Attribute ] ) {
485
- let replacements: Vec < _ > = attrs
486
- . iter ( )
487
- . filter_map ( |attr| {
488
- if let AttrKind :: DocComment ( com_kind, sym) = attr. kind
489
- && let AttrStyle :: Outer = attr. style
490
- && let Some ( com) = sym. as_str ( ) . strip_prefix ( '!' )
491
- {
492
- let sugg = match com_kind {
493
- CommentKind :: Line => format ! ( "//!{com}" ) ,
494
- CommentKind :: Block => format ! ( "/*!{com}*/" ) ,
495
- } ;
496
- Some ( ( attr. span , sugg) )
497
- } else {
498
- None
499
- }
500
- } )
501
- . collect ( ) ;
502
-
503
- if let Some ( ( & ( lo_span, _) , & ( hi_span, _) ) ) = replacements. first ( ) . zip ( replacements. last ( ) ) {
504
- span_lint_and_then (
505
- cx,
506
- SUSPICIOUS_DOC_COMMENTS ,
507
- lo_span. to ( hi_span) ,
508
- "this is an outer doc comment and does not apply to the parent module or crate" ,
509
- |diag| {
510
- diag. multipart_suggestion (
511
- "use an inner doc comment to document the parent module or crate" ,
512
- replacements,
513
- Applicability :: MaybeIncorrect ,
514
- ) ;
515
- } ,
516
- ) ;
517
- }
518
- }
519
-
520
480
const RUST_CODE : & [ & str ] = & [ "rust" , "no_run" , "should_panic" , "compile_fail" ] ;
521
481
522
482
/// Checks parsed documentation.
0 commit comments