diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-10-31 13:46:28 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-11-05 10:22:08 +0100 |
| commit | 6be97e225099cc59dc63f6fc01af7c525d0334df (patch) | |
| tree | 576c7557953368f8460ee9467331d7091defb7d8 | |
| parent | 1fb404bebe9e7d228859a26b7e40340438d0c427 (diff) | |
| download | rust-6be97e225099cc59dc63f6fc01af7c525d0334df.tar.gz rust-6be97e225099cc59dc63f6fc01af7c525d0334df.zip | |
Improve lint even more
| -rw-r--r-- | src/librustdoc/passes/url_improvements.rs | 9 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/url-improvements.rs | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/librustdoc/passes/url_improvements.rs b/src/librustdoc/passes/url_improvements.rs index a5d555eb19d..f09c44b41c9 100644 --- a/src/librustdoc/passes/url_improvements.rs +++ b/src/librustdoc/passes/url_improvements.rs @@ -19,8 +19,8 @@ pub const CHECK_URL_IMPROVEMENTS: Pass = Pass { const URL_REGEX: &str = concat!( r"https?://", // url scheme r"([-a-zA-Z0-9@:%._\+~#=]{2,256}\.)+", // one or more subdomains - r"[a-zA-Z]{2,4}", // root domain - r"\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" // optional query or url fragments + r"[a-zA-Z]{2,63}", // root domain + r"\b([-a-zA-Z0-9@:%_\+.~#?&/=]*)" // optional query or url fragments ); struct UrlImprovementsLinter<'a, 'tcx> { @@ -101,8 +101,9 @@ impl<'a, 'tcx> DocFolder for UrlImprovementsLinter<'a, 'tcx> { while let Some((event, range)) = p.next() { match event { Event::End(Tag::Link(_, url, _)) => { - // NOTE: links cannot be nested, so we don't need to check `kind` - if url.as_ref() == title && !ignore { + // NOTE: links cannot be nested, so we don't need to + // check `kind` + if url.as_ref() == title && !ignore && self.regex.matches(url) { report_diag( self.cx, "unneeded long form for URL", diff --git a/src/test/rustdoc-ui/url-improvements.rs b/src/test/rustdoc-ui/url-improvements.rs index 81fd0ba7d51..b7b1c26cd6d 100644 --- a/src/test/rustdoc-ui/url-improvements.rs +++ b/src/test/rustdoc-ui/url-improvements.rs @@ -55,6 +55,8 @@ pub fn c() {} /// ``` /// This link should not be linted: http://example.com /// ``` +/// +/// [should_not.lint](should_not.lint) pub fn everything_is_fine_here() {} #[allow(url_improvements)] |
