Skip to content

Commit 2aeaf1e

Browse files
maxcnunesmaxclaus
authored andcommitted
Drop some checker because rustdoc already warn about them
1 parent 9f97845 commit 2aeaf1e

File tree

3 files changed

+6
-57
lines changed

3 files changed

+6
-57
lines changed

clippy_lints/src/doc/broken_link.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ pub fn check(cx: &LateContext<'_>, attrs: &[Attribute]) {
99
for broken_link in BrokenLinkLoader::collect_spans_broken_link(attrs) {
1010
let reason_msg = match broken_link.reason {
1111
BrokenLinkReason::MultipleLines => "broken across multiple lines",
12-
BrokenLinkReason::MissingCloseParenthesis => "missing close parenthesis",
13-
BrokenLinkReason::WhiteSpace => "whitespace within url",
1412
};
1513

1614
span_lint(
@@ -23,10 +21,13 @@ pub fn check(cx: &LateContext<'_>, attrs: &[Attribute]) {
2321
}
2422

2523
/// The reason why a link is considered broken.
24+
// NOTE: We don't check these other cases because
25+
// rustdoc itself will check and warn about it:
26+
// - When a link url is broken across multiple lines in the URL path part
27+
// - When a link tag is missing the close parenthesis character at the end.
28+
// - When a link has whitespace within the url link.
2629
enum BrokenLinkReason {
2730
MultipleLines,
28-
MissingCloseParenthesis,
29-
WhiteSpace,
3031
}
3132

3233
/// Broken link data.
@@ -98,21 +99,8 @@ impl BrokenLinkLoader {
9899
&& let AttrStyle::Outer = attr.style
99100
{
100101
self.scan_line(sym.as_str(), attr.span);
101-
} else {
102-
if idx > 0 && self.active && self.processing_link_url {
103-
let prev_attr = &attrs[idx - 1];
104-
let prev_end_line = prev_attr.span.hi().0;
105-
self.record_broken_link(prev_end_line, BrokenLinkReason::MissingCloseParenthesis);
106-
}
107-
self.reset_lookup();
108102
}
109103
}
110-
111-
if self.active && self.processing_link_url {
112-
let last_end_line = attrs.last().unwrap().span.hi().0;
113-
self.record_broken_link(last_end_line, BrokenLinkReason::MissingCloseParenthesis);
114-
self.reset_lookup();
115-
}
116104
}
117105

118106
fn scan_line(&mut self, line: &str, attr_span: Span) {
@@ -169,13 +157,6 @@ impl BrokenLinkLoader {
169157
continue;
170158
}
171159

172-
if self.reading_link_url && c.is_whitespace() {
173-
let pos_end = u32::try_from(pos).unwrap();
174-
self.record_broken_link(pos_end, BrokenLinkReason::WhiteSpace);
175-
self.reset_lookup();
176-
continue;
177-
}
178-
179160
if !c.is_whitespace() {
180161
self.reading_link_url = true;
181162
}

tests/ui/doc_broken_link.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,6 @@ pub fn doc_invalid_link_broken_url_scheme_part() {}
4949
//~^^ ERROR: possible broken doc link: broken across multiple lines
5050
pub fn doc_invalid_link_broken_url_host_part() {}
5151

52-
// NOTE: We don't test doc links where the url is broken accross
53-
// multiple lines in the path part because that is something
54-
// rustdoc itself will check and warn about it.
55-
pub fn doc_invalid_link_broken_url_path_part() {}
56-
57-
/// Test invalid link, url missing close parenthesis.
58-
/// [doc invalid link broken url missing close parenthesis](
59-
/// https://test.fake/doc_invalid_link_missing_close_parenthesis
60-
//~^^ ERROR: possible broken doc link: missing close parenthesis
61-
pub fn doc_invalid_link_missing_close_parenthesis() {}
62-
63-
/// Test invalid link, url whitespace within url.
64-
/// [doc invalid link broken url whitespace within url](
65-
/// https://test.fake/doc_invalid_link_url whitespace_within_url)
66-
//~^^ ERROR: possible broken doc link: whitespace within url
67-
pub fn doc_invalid_link_url_whitespace_within_url() {}
68-
6952
/// This might be considered a link false positive
7053
/// and should be ignored by this lint rule:
7154
/// Example of referencing some code with brackets [FakeType].

tests/ui/doc_broken_link.stderr

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,5 @@ LL | /// [doc invalid link broken url host part](https://test
1717
LL | | /// .fake/doc_invalid_link_broken_url_host_part)
1818
| |________________________________________________^
1919

20-
error: possible broken doc link: missing close parenthesis
21-
--> tests/ui/doc_broken_link.rs:58:5
22-
|
23-
LL | /// [doc invalid link broken url missing close parenthesis](
24-
| _____^
25-
LL | | /// https://test.fake/doc_invalid_link_missing_close_parenthesis
26-
| |________________________________________________________________^
27-
28-
error: possible broken doc link: whitespace within url
29-
--> /Users/maxnunes/Development/forks/rust-clippy/tests/clippy.toml:1:40
30-
|
31-
LL | # default config for tests, overrides clippy.toml at the project root
32-
| ________________________________________^
33-
... |
34-
35-
error: aborting due to 4 previous errors
20+
error: aborting due to 2 previous errors
3621

0 commit comments

Comments
 (0)