mirror of https://github.com/rust-lang/rust.git
Have a separate message for raw URLs in doc
This commit is contained in:
parent
b10610cdeb
commit
aca6c1e065
|
@ -5,6 +5,7 @@ use syntax::ast;
|
|||
use syntax::codemap::{BytePos, Span};
|
||||
use syntax_pos::Pos;
|
||||
use utils::span_lint;
|
||||
use url::Url;
|
||||
|
||||
/// **What it does:** Checks for the presence of `_`, `::` or camel-case words
|
||||
/// outside ticks in documentation.
|
||||
|
@ -280,6 +281,18 @@ fn check_word(cx: &EarlyContext, word: &str, span: Span) {
|
|||
s != "_" && !s.contains("\\_") && s.contains('_')
|
||||
}
|
||||
|
||||
if let Ok(url) = Url::parse(word) {
|
||||
// try to get around the fact that `foo::bar` parses as a valid URL
|
||||
if !url.cannot_be_a_base() {
|
||||
span_lint(cx,
|
||||
DOC_MARKDOWN,
|
||||
span,
|
||||
"you should put bare URLs between `<`/`>` or make a proper Markdown link");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if has_underscore(word) || word.contains("::") || is_camel_case(word) {
|
||||
span_lint(
|
||||
cx,
|
||||
|
|
|
@ -162,5 +162,8 @@ fn issue_1920() {}
|
|||
|
||||
/// Ok: <http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels>
|
||||
///
|
||||
/// Not ok: http://www.unicode.org
|
||||
/// Not ok: https://www.unicode.org
|
||||
/// Not ok: http://www.unicode.org/
|
||||
/// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
|
||||
fn issue_1832() {}
|
||||
|
|
|
@ -156,11 +156,29 @@ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the doc
|
|||
138 | /// be_sure_we_got_to_the_end_of_it
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: you should put `http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels` between ticks in the documentation
|
||||
error: you should put bare URLs between `<`/`>` or make a proper Markdown link
|
||||
--> $DIR/doc.rs:165:13
|
||||
|
|
||||
165 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
|
||||
165 | /// Not ok: http://www.unicode.org
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: you should put bare URLs between `<`/`>` or make a proper Markdown link
|
||||
--> $DIR/doc.rs:166:13
|
||||
|
|
||||
166 | /// Not ok: https://www.unicode.org
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: you should put bare URLs between `<`/`>` or make a proper Markdown link
|
||||
--> $DIR/doc.rs:167:13
|
||||
|
|
||||
167 | /// Not ok: http://www.unicode.org/
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: you should put bare URLs between `<`/`>` or make a proper Markdown link
|
||||
--> $DIR/doc.rs:168:13
|
||||
|
|
||||
168 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 27 previous errors
|
||||
error: aborting due to 30 previous errors
|
||||
|
||||
|
|
Loading…
Reference in New Issue