Remove 'unnecessary long for for link' warning
This also makes the implementation slightly more efficient by only compiling the regex once. See https://github.com/rust-lang/rust/pull/81764#issuecomment-774122759 for why this was removed; essentially the benefit didn't seem great enough to deserve a lint.
This commit is contained in:
parent
fe1baa6498
commit
6f89468fc5
3 changed files with 44 additions and 80 deletions
|
|
@ -1,15 +1,5 @@
|
|||
#![deny(rustdoc::non_autolinks)]
|
||||
|
||||
/// [http://aa.com](http://aa.com)
|
||||
//~^ ERROR unneeded long form for URL
|
||||
/// [http://bb.com]
|
||||
//~^ ERROR unneeded long form for URL
|
||||
///
|
||||
/// [http://bb.com]: http://bb.com
|
||||
///
|
||||
/// [http://c.com][http://c.com]
|
||||
pub fn a() {}
|
||||
|
||||
/// https://somewhere.com
|
||||
//~^ ERROR this URL is not a hyperlink
|
||||
/// https://somewhere.com/a
|
||||
|
|
@ -54,6 +44,8 @@ pub fn c() {}
|
|||
///
|
||||
/// ```
|
||||
/// This link should not be linted: http://example.com
|
||||
///
|
||||
/// Nor this one: <http://example.com> or this one: [x](http://example.com)
|
||||
/// ```
|
||||
///
|
||||
/// [should_not.lint](should_not.lint)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: unneeded long form for URL
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:3:5
|
||||
|
|
||||
LL | /// [http://aa.com](http://aa.com)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://aa.com>`
|
||||
LL | /// https://somewhere.com
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com>`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/url-improvements.rs:1:9
|
||||
|
|
@ -10,113 +10,101 @@ note: the lint level is defined here
|
|||
LL | #![deny(rustdoc::non_autolinks)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unneeded long form for URL
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:5:5
|
||||
|
|
||||
LL | /// [http://bb.com]
|
||||
| ^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://bb.com>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:13:5
|
||||
|
|
||||
LL | /// https://somewhere.com
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:15:5
|
||||
|
|
||||
LL | /// https://somewhere.com/a
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:17:5
|
||||
--> $DIR/url-improvements.rs:7:5
|
||||
|
|
||||
LL | /// https://www.somewhere.com
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://www.somewhere.com>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:19:5
|
||||
--> $DIR/url-improvements.rs:9:5
|
||||
|
|
||||
LL | /// https://www.somewhere.com/a
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://www.somewhere.com/a>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:21:5
|
||||
--> $DIR/url-improvements.rs:11:5
|
||||
|
|
||||
LL | /// https://subdomain.example.com
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://subdomain.example.com>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:23:5
|
||||
--> $DIR/url-improvements.rs:13:5
|
||||
|
|
||||
LL | /// https://somewhere.com?
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com?>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:25:5
|
||||
--> $DIR/url-improvements.rs:15:5
|
||||
|
|
||||
LL | /// https://somewhere.com/a?
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a?>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:27:5
|
||||
--> $DIR/url-improvements.rs:17:5
|
||||
|
|
||||
LL | /// https://somewhere.com?hello=12
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com?hello=12>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:29:5
|
||||
--> $DIR/url-improvements.rs:19:5
|
||||
|
|
||||
LL | /// https://somewhere.com/a?hello=12
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a?hello=12>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:31:5
|
||||
--> $DIR/url-improvements.rs:21:5
|
||||
|
|
||||
LL | /// https://example.com?hello=12#xyz
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://example.com?hello=12#xyz>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:33:5
|
||||
--> $DIR/url-improvements.rs:23:5
|
||||
|
|
||||
LL | /// https://example.com/a?hello=12#xyz
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://example.com/a?hello=12#xyz>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:35:5
|
||||
--> $DIR/url-improvements.rs:25:5
|
||||
|
|
||||
LL | /// https://example.com#xyz
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://example.com#xyz>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:37:5
|
||||
--> $DIR/url-improvements.rs:27:5
|
||||
|
|
||||
LL | /// https://example.com/a#xyz
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://example.com/a#xyz>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:39:5
|
||||
--> $DIR/url-improvements.rs:29:5
|
||||
|
|
||||
LL | /// https://somewhere.com?hello=12&bye=11
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com?hello=12&bye=11>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:41:5
|
||||
--> $DIR/url-improvements.rs:31:5
|
||||
|
|
||||
LL | /// https://somewhere.com/a?hello=12&bye=11
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a?hello=12&bye=11>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:43:5
|
||||
--> $DIR/url-improvements.rs:33:5
|
||||
|
|
||||
LL | /// https://somewhere.com?hello=12&bye=11#xyz
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com?hello=12&bye=11#xyz>`
|
||||
|
||||
error: this URL is not a hyperlink
|
||||
--> $DIR/url-improvements.rs:45:10
|
||||
--> $DIR/url-improvements.rs:35:10
|
||||
|
|
||||
LL | /// hey! https://somewhere.com/a?hello=12&bye=11#xyz
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a?hello=12&bye=11#xyz>`
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue