Skip to content

Commit ef4e5b9

Browse files
committed
Rename non_autolinks -> bare_urls
1 parent 6f89468 commit ef4e5b9

File tree

9 files changed

+56
-45
lines changed

9 files changed

+56
-45
lines changed

library/core/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ pub mod primitive;
298298
unused_imports,
299299
unsafe_op_in_unsafe_fn
300300
)]
301-
#[allow(rustdoc::non_autolinks)]
301+
#[cfg_attr(bootstrap, allow(rustdoc::non_autolinks))]
302+
#[cfg_attr(not(bootstrap), allow(rustdoc::bare_urls))]
302303
// FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
303304
// merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
304305
#[allow(clashing_extern_declarations)]

src/doc/rustdoc/src/lints.md

+8-15
Original file line numberDiff line numberDiff line change
@@ -294,40 +294,33 @@ warning: unclosed HTML tag `h1`
294294
warning: 2 warnings emitted
295295
```
296296

297-
## non_autolinks
297+
## bare_urls
298298

299-
This lint is **nightly-only** and **warns by default**. It detects links which
300-
could use the "automatic" link syntax. For example:
299+
This lint is **nightly-only** and **warns by default**. It detects URLs which are not links.
300+
For example:
301301

302302
```rust
303303
/// http://example.org
304-
/// [http://example.com](http://example.com)
305304
/// [http://example.net]
306-
///
307-
/// [http://example.com]: http://example.com
308305
pub fn foo() {}
309306
```
310307

311308
Which will give:
312309

313310
```text
314311
warning: this URL is not a hyperlink
315-
--> foo.rs:1:5
312+
--> links.rs:1:5
316313
|
317314
1 | /// http://example.org
318315
| ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.org>`
319316
|
320-
= note: `#[warn(rustdoc::non_autolinks)]` on by default
321-
322-
warning: unneeded long form for URL
323-
--> foo.rs:2:5
324-
|
325-
2 | /// [http://example.com](http://example.com)
326-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.com>`
317+
= note: `#[warn(rustdoc::bare_urls)]` on by default
327318
328319
warning: this URL is not a hyperlink
329-
--> foo.rs:3:6
320+
--> links.rs:3:6
330321
|
331322
3 | /// [http://example.net]
332323
| ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.net>`
324+
325+
warning: 2 warnings emitted
333326
```

src/librustdoc/lint.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,13 @@ declare_rustdoc_lint! {
148148
}
149149

150150
declare_rustdoc_lint! {
151-
/// The `non_autolinks` lint detects when a URL could be written using
152-
/// only angle brackets. This is a `rustdoc` only lint, see the
153-
/// documentation in the [rustdoc book].
151+
/// The `non_autolinks` lint detects when a URL is not a hyperlink.
152+
/// This is a `rustdoc` only lint, see the documentation in the [rustdoc book].
154153
///
155-
/// [rustdoc book]: ../../../rustdoc/lints.html#non_autolinks
156-
NON_AUTOLINKS,
154+
/// [rustdoc book]: ../../../rustdoc/lints.html#bare_urls
155+
BARE_URLS,
157156
Warn,
158-
"detects URLs that could be written using only angle brackets"
157+
"detects URLs that are not hyperlinks"
159158
}
160159

161160
crate static RUSTDOC_LINTS: Lazy<Vec<&'static Lint>> = Lazy::new(|| {
@@ -166,7 +165,7 @@ crate static RUSTDOC_LINTS: Lazy<Vec<&'static Lint>> = Lazy::new(|| {
166165
PRIVATE_DOC_TESTS,
167166
INVALID_CODEBLOCK_ATTRIBUTES,
168167
INVALID_HTML_TAGS,
169-
NON_AUTOLINKS,
168+
BARE_URLS,
170169
MISSING_CRATE_LEVEL_DOCS,
171170
]
172171
});
@@ -185,4 +184,6 @@ crate fn register_lints(_sess: &Session, lint_store: &mut LintStore) {
185184
}
186185
lint_store
187186
.register_renamed("intra_doc_link_resolution_failure", "rustdoc::broken_intra_doc_links");
187+
lint_store.register_renamed("non_autolinks", "rustdoc::bare_urls");
188+
lint_store.register_renamed("rustdoc::non_autolinks", "rustdoc::bare_urls");
188189
}

src/librustdoc/passes/non_autolinks.rs renamed to src/librustdoc/passes/bare_urls.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use rustc_errors::Applicability;
1010
use std::lazy::SyncLazy;
1111
use std::mem;
1212

13-
crate const CHECK_NON_AUTOLINKS: Pass = Pass {
14-
name: "check-non-autolinks",
15-
run: check_non_autolinks,
16-
description: "detects URLs that could be linkified",
13+
crate const CHECK_BARE_URLS: Pass = Pass {
14+
name: "check-bare-urls",
15+
run: check_bare_urls,
16+
description: "detects URLs that are not hyperlinks",
1717
};
1818

1919
const URL_REGEX: SyncLazy<Regex> = SyncLazy::new(|| {
@@ -26,11 +26,11 @@ const URL_REGEX: SyncLazy<Regex> = SyncLazy::new(|| {
2626
.expect("failed to build regex")
2727
});
2828

29-
struct NonAutolinksLinter<'a, 'tcx> {
29+
struct BareUrlsLinter<'a, 'tcx> {
3030
cx: &'a mut DocContext<'tcx>,
3131
}
3232

33-
impl<'a, 'tcx> NonAutolinksLinter<'a, 'tcx> {
33+
impl<'a, 'tcx> BareUrlsLinter<'a, 'tcx> {
3434
fn find_raw_urls(
3535
&self,
3636
text: &str,
@@ -52,11 +52,11 @@ impl<'a, 'tcx> NonAutolinksLinter<'a, 'tcx> {
5252
}
5353
}
5454

55-
crate fn check_non_autolinks(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
56-
NonAutolinksLinter { cx }.fold_crate(krate)
55+
crate fn check_bare_urls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
56+
BareUrlsLinter { cx }.fold_crate(krate)
5757
}
5858

59-
impl<'a, 'tcx> DocFolder for NonAutolinksLinter<'a, 'tcx> {
59+
impl<'a, 'tcx> DocFolder for BareUrlsLinter<'a, 'tcx> {
6060
fn fold_item(&mut self, item: Item) -> Option<Item> {
6161
let hir_id = match DocContext::as_local_hir_id(self.cx.tcx, item.def_id) {
6262
Some(hir_id) => hir_id,
@@ -71,7 +71,7 @@ impl<'a, 'tcx> DocFolder for NonAutolinksLinter<'a, 'tcx> {
7171
let sp = super::source_span_for_markdown_range(cx.tcx, &dox, &range, &item.attrs)
7272
.or_else(|| span_of_attrs(&item.attrs))
7373
.unwrap_or(item.span.inner());
74-
cx.tcx.struct_span_lint_hir(crate::lint::NON_AUTOLINKS, hir_id, sp, |lint| {
74+
cx.tcx.struct_span_lint_hir(crate::lint::BARE_URLS, hir_id, sp, |lint| {
7575
lint.build(msg)
7676
.span_suggestion(
7777
sp,

src/librustdoc/passes/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use crate::core::DocContext;
1212
mod stripper;
1313
crate use stripper::*;
1414

15-
mod non_autolinks;
16-
crate use self::non_autolinks::CHECK_NON_AUTOLINKS;
15+
mod bare_urls;
16+
crate use self::bare_urls::CHECK_BARE_URLS;
1717

1818
mod strip_hidden;
1919
crate use self::strip_hidden::STRIP_HIDDEN;
@@ -90,7 +90,7 @@ crate const PASSES: &[Pass] = &[
9090
COLLECT_TRAIT_IMPLS,
9191
CALCULATE_DOC_COVERAGE,
9292
CHECK_INVALID_HTML_TAGS,
93-
CHECK_NON_AUTOLINKS,
93+
CHECK_BARE_URLS,
9494
];
9595

9696
/// The list of passes run by default.
@@ -105,7 +105,7 @@ crate const DEFAULT_PASSES: &[ConditionalPass] = &[
105105
ConditionalPass::always(CHECK_CODE_BLOCK_SYNTAX),
106106
ConditionalPass::always(CHECK_INVALID_HTML_TAGS),
107107
ConditionalPass::always(PROPAGATE_DOC_CFG),
108-
ConditionalPass::always(CHECK_NON_AUTOLINKS),
108+
ConditionalPass::always(CHECK_BARE_URLS),
109109
];
110110

111111
/// The list of default passes run when `--doc-coverage` is passed to rustdoc.

src/test/rustdoc-ui/unknown-renamed-lints.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
//~^ ERROR unknown lint: `rustdoc::x`
99
#![deny(intra_doc_link_resolution_failure)]
1010
//~^ ERROR renamed to `rustdoc::broken_intra_doc_links`
11-
1211
#![deny(non_autolinks)]
12+
//~^ ERROR renamed to `rustdoc::bare_urls`
13+
#![deny(rustdoc::non_autolinks)]
14+
//~^ ERROR renamed to `rustdoc::bare_urls`
15+
16+
#![deny(private_doc_tests)]
1317
// FIXME: the old names for rustdoc lints should warn by default once `rustdoc::` makes it to the
1418
// stable channel.
1519

src/test/rustdoc-ui/unknown-renamed-lints.stderr

+15-3
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,31 @@ note: the lint level is defined here
2828
LL | #![deny(renamed_and_removed_lints)]
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3030

31+
error: lint `non_autolinks` has been renamed to `rustdoc::bare_urls`
32+
--> $DIR/unknown-renamed-lints.rs:11:9
33+
|
34+
LL | #![deny(non_autolinks)]
35+
| ^^^^^^^^^^^^^ help: use the new name: `rustdoc::bare_urls`
36+
37+
error: lint `rustdoc::non_autolinks` has been renamed to `rustdoc::bare_urls`
38+
--> $DIR/unknown-renamed-lints.rs:13:9
39+
|
40+
LL | #![deny(rustdoc::non_autolinks)]
41+
| ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::bare_urls`
42+
3143
error: lint `rustdoc` has been removed: use `rustdoc::all` instead
32-
--> $DIR/unknown-renamed-lints.rs:16:9
44+
--> $DIR/unknown-renamed-lints.rs:20:9
3345
|
3446
LL | #![deny(rustdoc)]
3547
| ^^^^^^^
3648

3749
error: unknown lint: `rustdoc::intra_doc_link_resolution_failure`
38-
--> $DIR/unknown-renamed-lints.rs:20:9
50+
--> $DIR/unknown-renamed-lints.rs:24:9
3951
|
4052
LL | #![deny(rustdoc::intra_doc_link_resolution_failure)]
4153
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4254

4355
error: Compilation failed, aborting rustdoc
4456

45-
error: aborting due to 6 previous errors
57+
error: aborting due to 8 previous errors
4658

src/test/rustdoc-ui/url-improvements.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(rustdoc::non_autolinks)]
1+
#![deny(rustdoc::bare_urls)]
22

33
/// https://somewhere.com
44
//~^ ERROR this URL is not a hyperlink
@@ -51,7 +51,7 @@ pub fn c() {}
5151
/// [should_not.lint](should_not.lint)
5252
pub fn everything_is_fine_here() {}
5353

54-
#[allow(rustdoc::non_autolinks)]
54+
#[allow(rustdoc::bare_urls)]
5555
pub mod foo {
5656
/// https://somewhere.com/a?hello=12&bye=11#xyz
5757
pub fn bar() {}

src/test/rustdoc-ui/url-improvements.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | /// https://somewhere.com
77
note: the lint level is defined here
88
--> $DIR/url-improvements.rs:1:9
99
|
10-
LL | #![deny(rustdoc::non_autolinks)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(rustdoc::bare_urls)]
11+
| ^^^^^^^^^^^^^^^^^^
1212

1313
error: this URL is not a hyperlink
1414
--> $DIR/url-improvements.rs:5:5

0 commit comments

Comments
 (0)