Skip to content

Commit 7babc2a

Browse files
committed
fix wording, remove commented out code, add additonal testcase
1 parent e646eda commit 7babc2a

File tree

2 files changed

+10
-58
lines changed

2 files changed

+10
-58
lines changed

clippy_lints/src/doc/doc_comment_double_space_linebreak.rs

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ pub fn check(cx: &LateContext<'_>, collected_breaks: &[Span]) {
1414
cx,
1515
DOC_COMMENT_DOUBLE_SPACE_LINEBREAK,
1616
lo_span.to(hi_span),
17-
"doc comments should use a back-slash (\\) instead of a double space to indicate a linebreak",
17+
"doc comment uses two spaces for a hard line break",
1818
|diag| {
1919
diag.multipart_suggestion(
20-
"replace this double space with a back-slash",
20+
"replace this double space with a backslash",
2121
replacements,
2222
Applicability::MachineApplicable,
2323
);
@@ -38,59 +38,3 @@ fn collect_doc_replacements(cx: &LateContext<'_>, spans: &[Span]) -> Vec<(Span,
3838
})
3939
.collect()
4040
}
41-
42-
/*
43-
use clippy_utils::diagnostics::span_lint_and_then;
44-
use rustc_ast::token::CommentKind;
45-
use rustc_ast::{AttrKind, AttrStyle, Attribute};
46-
use rustc_errors::Applicability;
47-
use rustc_lint::LateContext;
48-
use rustc_span::Span;
49-
50-
use super::DOC_COMMENT_DOUBLE_SPACE_LINEBREAK;
51-
52-
pub fn check(cx: &LateContext<'_>, attrs: &[Attribute]) {
53-
let replacements: Vec<_> = collect_doc_replacements(attrs);
54-
55-
if let Some((&(lo_span, _), &(hi_span, _))) = replacements.first().zip(replacements.last()) {
56-
span_lint_and_then(
57-
cx,
58-
DOC_COMMENT_DOUBLE_SPACE_LINEBREAK,
59-
lo_span.to(hi_span),
60-
"doc comments should use a back-slash (\\) instead of a double space to indicate a linebreak",
61-
|diag| {
62-
diag.multipart_suggestion(
63-
"replace this double space with a back-slash",
64-
replacements,
65-
Applicability::MachineApplicable,
66-
);
67-
},
68-
);
69-
}
70-
}
71-
72-
fn collect_doc_replacements(attrs: &[Attribute]) -> Vec<(Span, String)> {
73-
attrs
74-
.iter()
75-
.filter_map(|attr| {
76-
if let AttrKind::DocComment(com_kind, sym) = attr.kind
77-
&& !attr.span.from_expansion()
78-
&& com_kind == CommentKind::Line
79-
&& let comment = sym.as_str()
80-
&& comment.ends_with(" ")
81-
{
82-
let pre = match attr.style {
83-
AttrStyle::Outer => "///",
84-
AttrStyle::Inner => "//!",
85-
};
86-
87-
let len = comment.len();
88-
let new_comment = format!("{pre}{}\\", &comment[..len - 2]);
89-
Some((attr.span, new_comment))
90-
} else {
91-
None
92-
}
93-
})
94-
.collect()
95-
}
96-
*/

tests/ui/doc/doc_comment_double_space_linebreak.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,12 @@ fn inline() {}
8383
/// https://example.com) in a URL.
8484
fn url() {}
8585

86+
/// here we mix
87+
/// double spaces\
88+
/// and also
89+
/// adding backslash\
90+
/// to some of them
91+
/// to see how that looks
92+
fn mixed() {}
93+
8694
fn main() {}

0 commit comments

Comments
 (0)