Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 9d11450

Browse files
Rename lint to non_autolinks
1 parent 6be97e2 commit 9d11450

File tree

9 files changed

+38
-37
lines changed

9 files changed

+38
-37
lines changed

compiler/rustc_lint/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ use rustc_middle::ty::TyCtxt;
6969
use rustc_session::lint::builtin::{
7070
BARE_TRAIT_OBJECTS, BROKEN_INTRA_DOC_LINKS, ELIDED_LIFETIMES_IN_PATHS,
7171
EXPLICIT_OUTLIVES_REQUIREMENTS, INVALID_CODEBLOCK_ATTRIBUTES, INVALID_HTML_TAGS,
72-
MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, URL_IMPROVEMENTS,
72+
MISSING_DOC_CODE_EXAMPLES, NON_AUTOLINKS, PRIVATE_DOC_TESTS,
7373
};
7474
use rustc_span::symbol::{Ident, Symbol};
7575
use rustc_span::Span;
@@ -313,7 +313,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
313313

314314
add_lint_group!(
315315
"rustdoc",
316-
URL_IMPROVEMENTS,
316+
NON_AUTOLINKS,
317317
BROKEN_INTRA_DOC_LINKS,
318318
PRIVATE_INTRA_DOC_LINKS,
319319
INVALID_CODEBLOCK_ATTRIBUTES,

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,12 +1891,12 @@ declare_lint! {
18911891
}
18921892

18931893
declare_lint! {
1894-
/// The `url_improvements` lint detects when a URL could be written using
1894+
/// The `non_autolinks` lint detects when a URL could be written using
18951895
/// only angle brackets. This is a `rustdoc` only lint, see the
18961896
/// documentation in the [rustdoc book].
18971897
///
1898-
/// [rustdoc book]: ../../../rustdoc/lints.html#url_improvements
1899-
pub URL_IMPROVEMENTS,
1898+
/// [rustdoc book]: ../../../rustdoc/lints.html#non_autolinks
1899+
pub NON_AUTOLINKS,
19001900
Warn,
19011901
"detects URLs that could be written using only angle brackets"
19021902
}
@@ -2806,7 +2806,7 @@ declare_lint_pass! {
28062806
MISSING_DOC_CODE_EXAMPLES,
28072807
INVALID_HTML_TAGS,
28082808
PRIVATE_DOC_TESTS,
2809-
URL_IMPROVEMENTS,
2809+
NON_AUTOLINKS,
28102810
WHERE_CLAUSES_OBJECT_SAFETY,
28112811
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
28122812
MACRO_USE_EXTERN_CRATE,

library/core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub mod primitive;
287287
unused_imports,
288288
unsafe_op_in_unsafe_fn
289289
)]
290-
#[cfg_attr(not(bootstrap), allow(url_improvements))]
290+
#[cfg_attr(not(bootstrap), allow(non_autolinks))]
291291
// FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
292292
// merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
293293
#[allow(clashing_extern_declarations)]

src/doc/rustdoc/src/lints.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ warning: unclosed HTML tag `h1`
286286
warning: 2 warnings emitted
287287
```
288288

289-
## url_improvements
289+
## non_autolinks
290290

291291
This lint is **nightly-only** and **warns by default**. It detects links which
292292
could use the "automatic" link syntax. For example:
@@ -309,7 +309,7 @@ warning: this URL is not a hyperlink
309309
1 | /// http://example.org
310310
| ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.org>`
311311
|
312-
= note: `#[warn(url_improvements)]` on by default
312+
= note: `#[warn(non_autolinks)]` on by default
313313
314314
warning: unneeded long form for URL
315315
--> foo.rs:2:5

src/librustdoc/core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ pub fn run_core(
330330
let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
331331
let invalid_html_tags = rustc_lint::builtin::INVALID_HTML_TAGS.name;
332332
let renamed_and_removed_lints = rustc_lint::builtin::RENAMED_AND_REMOVED_LINTS.name;
333-
let url_improvements = rustc_lint::builtin::URL_IMPROVEMENTS.name;
333+
let non_autolinks = rustc_lint::builtin::NON_AUTOLINKS.name;
334334
let unknown_lints = rustc_lint::builtin::UNKNOWN_LINTS.name;
335335

336336
// In addition to those specific lints, we also need to allow those given through
@@ -345,7 +345,7 @@ pub fn run_core(
345345
invalid_html_tags.to_owned(),
346346
renamed_and_removed_lints.to_owned(),
347347
unknown_lints.to_owned(),
348-
url_improvements.to_owned(),
348+
non_autolinks.to_owned(),
349349
];
350350

351351
let (lint_opts, lint_caps) = init_lints(lints_to_show, lint_opts, |lint| {

src/librustdoc/passes/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::core::DocContext;
1111
mod stripper;
1212
pub use stripper::*;
1313

14-
mod url_improvements;
15-
pub use self::url_improvements::CHECK_URL_IMPROVEMENTS;
14+
mod non_autolinks;
15+
pub use self::non_autolinks::CHECK_NON_AUTOLINKS;
1616

1717
mod collapse_docs;
1818
pub use self::collapse_docs::COLLAPSE_DOCS;
@@ -93,7 +93,7 @@ pub const PASSES: &[Pass] = &[
9393
COLLECT_TRAIT_IMPLS,
9494
CALCULATE_DOC_COVERAGE,
9595
CHECK_INVALID_HTML_TAGS,
96-
CHECK_URL_IMPROVEMENTS,
96+
CHECK_NON_AUTOLINKS,
9797
];
9898

9999
/// The list of passes run by default.
@@ -109,7 +109,7 @@ pub const DEFAULT_PASSES: &[ConditionalPass] = &[
109109
ConditionalPass::always(CHECK_CODE_BLOCK_SYNTAX),
110110
ConditionalPass::always(CHECK_INVALID_HTML_TAGS),
111111
ConditionalPass::always(PROPAGATE_DOC_CFG),
112-
ConditionalPass::always(CHECK_URL_IMPROVEMENTS),
112+
ConditionalPass::always(CHECK_NON_AUTOLINKS),
113113
];
114114

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

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use rustc_errors::Applicability;
1010
use rustc_feature::UnstableFeatures;
1111
use rustc_session::lint;
1212

13-
pub const CHECK_URL_IMPROVEMENTS: Pass = Pass {
14-
name: "check-url-improvements",
15-
run: check_url_improvements,
13+
pub const CHECK_NON_AUTOLINKS: Pass = Pass {
14+
name: "check-non-autolinks",
15+
run: check_non_autolinks,
1616
description: "detects URLS that could be written using angle brackets",
1717
};
1818

@@ -23,14 +23,14 @@ const URL_REGEX: &str = concat!(
2323
r"\b([-a-zA-Z0-9@:%_\+.~#?&/=]*)" // optional query or url fragments
2424
);
2525

26-
struct UrlImprovementsLinter<'a, 'tcx> {
26+
struct NonAutolinksLinter<'a, 'tcx> {
2727
cx: &'a DocContext<'tcx>,
2828
regex: Regex,
2929
}
3030

31-
impl<'a, 'tcx> UrlImprovementsLinter<'a, 'tcx> {
31+
impl<'a, 'tcx> NonAutolinksLinter<'a, 'tcx> {
3232
fn new(cx: &'a DocContext<'tcx>) -> Self {
33-
UrlImprovementsLinter { cx, regex: Regex::new(URL_REGEX).expect("failed to build regex") }
33+
Self { cx, regex: Regex::new(URL_REGEX).expect("failed to build regex") }
3434
}
3535

3636
fn find_raw_urls(
@@ -53,17 +53,17 @@ impl<'a, 'tcx> UrlImprovementsLinter<'a, 'tcx> {
5353
}
5454
}
5555

56-
pub fn check_url_improvements(krate: Crate, cx: &DocContext<'_>) -> Crate {
56+
pub fn check_non_autolinks(krate: Crate, cx: &DocContext<'_>) -> Crate {
5757
if !UnstableFeatures::from_environment().is_nightly_build() {
5858
krate
5959
} else {
60-
let mut coll = UrlImprovementsLinter::new(cx);
60+
let mut coll = NonAutolinksLinter::new(cx);
6161

6262
coll.fold_crate(krate)
6363
}
6464
}
6565

66-
impl<'a, 'tcx> DocFolder for UrlImprovementsLinter<'a, 'tcx> {
66+
impl<'a, 'tcx> DocFolder for NonAutolinksLinter<'a, 'tcx> {
6767
fn fold_item(&mut self, item: Item) -> Option<Item> {
6868
let hir_id = match self.cx.as_local_hir_id(item.def_id) {
6969
Some(hir_id) => hir_id,
@@ -78,7 +78,7 @@ impl<'a, 'tcx> DocFolder for UrlImprovementsLinter<'a, 'tcx> {
7878
let sp = super::source_span_for_markdown_range(cx, &dox, &range, &item.attrs)
7979
.or_else(|| span_of_attrs(&item.attrs))
8080
.unwrap_or(item.source.span());
81-
cx.tcx.struct_span_lint_hir(lint::builtin::URL_IMPROVEMENTS, hir_id, sp, |lint| {
81+
cx.tcx.struct_span_lint_hir(lint::builtin::NON_AUTOLINKS, hir_id, sp, |lint| {
8282
lint.build(msg)
8383
.span_suggestion(
8484
sp,
@@ -103,7 +103,8 @@ impl<'a, 'tcx> DocFolder for UrlImprovementsLinter<'a, 'tcx> {
103103
Event::End(Tag::Link(_, url, _)) => {
104104
// NOTE: links cannot be nested, so we don't need to
105105
// check `kind`
106-
if url.as_ref() == title && !ignore && self.regex.matches(url) {
106+
if url.as_ref() == title && !ignore && self.regex.is_match(&url)
107+
{
107108
report_diag(
108109
self.cx,
109110
"unneeded long form for URL",

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#![deny(url_improvements)]
1+
#![deny(non_autolinks)]
22

3-
/// [http://a.com](http://a.com)
3+
/// [http://aa.com](http://aa.com)
44
//~^ ERROR unneeded long form for URL
5-
/// [http://b.com]
5+
/// [http://bb.com]
66
//~^ ERROR unneeded long form for URL
77
///
8-
/// [http://b.com]: http://b.com
8+
/// [http://bb.com]: http://bb.com
99
///
1010
/// [http://c.com][http://c.com]
1111
pub fn a() {}
@@ -59,7 +59,7 @@ pub fn c() {}
5959
/// [should_not.lint](should_not.lint)
6060
pub fn everything_is_fine_here() {}
6161

62-
#[allow(url_improvements)]
62+
#[allow(non_autolinks)]
6363
pub mod foo {
6464
/// https://somewhere.com/a?hello=12&bye=11#xyz
6565
pub fn bar() {}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
error: unneeded long form for URL
22
--> $DIR/url-improvements.rs:3:5
33
|
4-
LL | /// [http://a.com](http://a.com)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://a.com>`
4+
LL | /// [http://aa.com](http://aa.com)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://aa.com>`
66
|
77
note: the lint level is defined here
88
--> $DIR/url-improvements.rs:1:9
99
|
10-
LL | #![deny(url_improvements)]
11-
| ^^^^^^^^^^^^^^^^
10+
LL | #![deny(non_autolinks)]
11+
| ^^^^^^^^^^^^^
1212

1313
error: unneeded long form for URL
1414
--> $DIR/url-improvements.rs:5:5
1515
|
16-
LL | /// [http://b.com]
17-
| ^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://b.com>`
16+
LL | /// [http://bb.com]
17+
| ^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://bb.com>`
1818

1919
error: this URL is not a hyperlink
2020
--> $DIR/url-improvements.rs:13:5

0 commit comments

Comments
 (0)