File tree 5 files changed +60
-6
lines changed
5 files changed +60
-6
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ fn collect_doc_replacements(attrs: &[Attribute]) -> Vec<(Span, String)> {
32
32
. iter ( )
33
33
. filter_map ( |attr| {
34
34
if let AttrKind :: DocComment ( com_kind, sym) = attr. kind
35
+ && !attr. span . from_expansion ( )
35
36
&& com_kind == CommentKind :: Line
36
37
&& let comment = sym. as_str ( )
37
38
&& comment. ends_with ( " " )
Original file line number Diff line number Diff line change @@ -438,7 +438,7 @@ declare_clippy_lint! {
438
438
/// fn add(l: i32, r: i32) -> i32 {
439
439
/// l + r
440
440
/// }
441
- /// ``````
441
+ /// ```
442
442
///
443
443
/// Use instead:
444
444
/// ```no_run
@@ -450,7 +450,7 @@ declare_clippy_lint! {
450
450
/// ```
451
451
#[ clippy:: version = "1.80.0" ]
452
452
pub DOC_COMMENT_DOUBLE_SPACE_LINEBREAK ,
453
- restriction ,
453
+ pedantic ,
454
454
"double-space used for doc comment linebreak instead of `\\ `"
455
455
}
456
456
Original file line number Diff line number Diff line change @@ -18,8 +18,9 @@ fn single_line_split() {}
18
18
19
19
// note: cargo fmt can remove double spaces from normal and block comments
20
20
// Should not warn on normal comments
21
- // with double spaces at the end of a line
21
+ // with double spaces at the end of a line
22
22
23
+ #[doc = "This is a doc attribute, which should not be linted"]
23
24
fn normal_comment() {
24
25
/*
25
26
Should not warn on block comments
@@ -40,4 +41,21 @@ fn double_space_doc_comment() {}
40
41
/// as a line-break
41
42
fn back_slash_doc_comment() {}
42
43
44
+ /// 🌹 are 🟥\
45
+ /// 🌷 are 🟦\
46
+ /// 📎 is 😎\
47
+ /// and so are 🫵\
48
+ /// (hopefully no formatting weirdness linting this)
49
+ fn multi_byte_chars_tada() {}
50
+
51
+ macro_rules! macro_that_makes_function {
52
+ () => {
53
+ /// Shouldn't lint on this!
54
+ /// (hopefully)
55
+ fn my_macro_created_function() {}
56
+ }
57
+ }
58
+
59
+ macro_that_makes_function!();
60
+
43
61
fn main() {}
Original file line number Diff line number Diff line change @@ -18,8 +18,9 @@ fn single_line_split() {}
18
18
19
19
// note: cargo fmt can remove double spaces from normal and block comments
20
20
// Should not warn on normal comments
21
- // with double spaces at the end of a line
21
+ // with double spaces at the end of a line
22
22
23
+ #[ doc = "This is a doc attribute, which should not be linted" ]
23
24
fn normal_comment ( ) {
24
25
/*
25
26
Should not warn on block comments
@@ -40,4 +41,21 @@ fn double_space_doc_comment() {}
40
41
/// as a line-break
41
42
fn back_slash_doc_comment ( ) { }
42
43
44
+ /// 🌹 are 🟥
45
+ /// 🌷 are 🟦
46
+ /// 📎 is 😎
47
+ /// and so are 🫵
48
+ /// (hopefully no formatting weirdness linting this)
49
+ fn multi_byte_chars_tada ( ) { }
50
+
51
+ macro_rules! macro_that_makes_function {
52
+ ( ) => {
53
+ /// Shouldn't lint on this!
54
+ /// (hopefully)
55
+ fn my_macro_created_function( ) { }
56
+ }
57
+ }
58
+
59
+ macro_that_makes_function ! ( ) ;
60
+
43
61
fn main ( ) { }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ LL | //! Should warn on double space linebreaks
8
8
= help: to override `-D warnings` add `#[allow(clippy::doc_comment_double_space_linebreak)]`
9
9
10
10
error: doc comments should use a back-slash (\) instead of a double space to indicate a linebreak
11
- --> tests/ui/doc/doc_comment_double_space_linebreak.rs:34 :1
11
+ --> tests/ui/doc/doc_comment_double_space_linebreak.rs:35 :1
12
12
|
13
13
LL | / /// Should warn when doc comment uses double space
14
14
LL | | /// as a line-break, even when there are multiple
@@ -20,5 +20,22 @@ LL + /// Should warn when doc comment uses double space\
20
20
LL + /// as a line-break, even when there are multiple\
21
21
|
22
22
23
- error: aborting due to 2 previous errors
23
+ error: doc comments should use a back-slash (\) instead of a double space to indicate a linebreak
24
+ --> tests/ui/doc/doc_comment_double_space_linebreak.rs:44:1
25
+ |
26
+ LL | / /// 🌹 are 🟥
27
+ LL | | /// 🌷 are 🟦
28
+ LL | | /// 📎 is 😎
29
+ LL | | /// and so are 🫵
30
+ | |___________________^
31
+ |
32
+ help: replace this double space with a back-slash
33
+ |
34
+ LL ~ /// 🌹 are 🟥\
35
+ LL ~ /// 🌷 are 🟦\
36
+ LL ~ /// 📎 is 😎\
37
+ LL ~ /// and so are 🫵\
38
+ |
39
+
40
+ error: aborting due to 3 previous errors
24
41
You can’t perform that action at this time.
0 commit comments