From 60caf51b0de940705e7679a26343f6dcbe470a54 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 17 Oct 2020 16:38:49 +0200 Subject: [PATCH] Rename automatic_links to url_improvements --- compiler/rustc_lint/src/lib.rs | 6 +++--- compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- library/core/src/lib.rs | 2 +- src/doc/rustdoc/src/lints.md | 2 +- src/librustdoc/core.rs | 4 ++-- src/librustdoc/passes/mod.rs | 8 ++++---- ...automatic_links.rs => url_improvements.rs} | 20 +++++++++---------- ...automatic-links.rs => url-improvements.rs} | 4 ++-- ...c-links.stderr => url-improvements.stderr} | 4 ++-- 9 files changed, 29 insertions(+), 29 deletions(-) rename src/librustdoc/passes/{automatic_links.rs => url_improvements.rs} (86%) rename src/test/rustdoc-ui/{automatic-links.rs => url-improvements.rs} (96%) rename src/test/rustdoc-ui/{automatic-links.stderr => url-improvements.stderr} (98%) diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 0da3ece167e..ad353bb28c9 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -67,9 +67,9 @@ use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::{ - AUTOMATIC_LINKS, BARE_TRAIT_OBJECTS, BROKEN_INTRA_DOC_LINKS, ELIDED_LIFETIMES_IN_PATHS, + BARE_TRAIT_OBJECTS, BROKEN_INTRA_DOC_LINKS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, INVALID_CODEBLOCK_ATTRIBUTES, INVALID_HTML_TAGS, - MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, + MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, URL_IMPROVEMENTS, }; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; @@ -313,7 +313,7 @@ macro_rules! register_passes { add_lint_group!( "rustdoc", - AUTOMATIC_LINKS, + URL_IMPROVEMENTS, BROKEN_INTRA_DOC_LINKS, PRIVATE_INTRA_DOC_LINKS, INVALID_CODEBLOCK_ATTRIBUTES, diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index b6e6307a40f..c74680c172f 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1891,12 +1891,12 @@ } declare_lint! { - /// The `automatic_links` lint detects when a URL could be written using + /// The `url_improvements` lint detects when a URL could be written using /// only angle brackets. This is a `rustdoc` only lint, see the /// documentation in the [rustdoc book]. /// - /// [rustdoc book]: ../../../rustdoc/lints.html#automatic_links - pub AUTOMATIC_LINKS, + /// [rustdoc book]: ../../../rustdoc/lints.html#url_improvements + pub URL_IMPROVEMENTS, Warn, "detects URLs that could be written using only angle brackets" } @@ -2806,7 +2806,7 @@ MISSING_DOC_CODE_EXAMPLES, INVALID_HTML_TAGS, PRIVATE_DOC_TESTS, - AUTOMATIC_LINKS, + URL_IMPROVEMENTS, WHERE_CLAUSES_OBJECT_SAFETY, PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, MACRO_USE_EXTERN_CRATE, diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 09dbde2c121..8596d52ceae 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -287,7 +287,7 @@ unused_imports, unsafe_op_in_unsafe_fn )] -#[cfg_attr(not(bootstrap), allow(automatic_links))] +#[cfg_attr(not(bootstrap), allow(url_improvements))] // FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is // merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet. #[allow(clashing_extern_declarations)] diff --git a/src/doc/rustdoc/src/lints.md b/src/doc/rustdoc/src/lints.md index 68ea828bfc1..7db9c93852d 100644 --- a/src/doc/rustdoc/src/lints.md +++ b/src/doc/rustdoc/src/lints.md @@ -286,7 +286,7 @@ warning: unclosed HTML tag `h1` warning: 2 warnings emitted ``` -## automatic_links +## url_improvements This lint is **nightly-only** and **warns by default**. It detects links which could use the "automatic" link syntax. For example: diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index f834be84d4c..85d73a30e4b 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -330,13 +330,12 @@ pub fn run_core( let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; let invalid_html_tags = rustc_lint::builtin::INVALID_HTML_TAGS.name; let renamed_and_removed_lints = rustc_lint::builtin::RENAMED_AND_REMOVED_LINTS.name; - let automatic_links = rustc_lint::builtin::AUTOMATIC_LINKS.name; + let url_improvements = rustc_lint::builtin::URL_IMPROVEMENTS.name; let unknown_lints = rustc_lint::builtin::UNKNOWN_LINTS.name; // In addition to those specific lints, we also need to allow those given through // command line, otherwise they'll get ignored and we don't want that. let lints_to_show = vec![ - automatic_links.to_owned(), intra_link_resolution_failure_name.to_owned(), missing_docs.to_owned(), missing_doc_example.to_owned(), @@ -346,6 +345,7 @@ pub fn run_core( invalid_html_tags.to_owned(), renamed_and_removed_lints.to_owned(), unknown_lints.to_owned(), + url_improvements.to_owned(), ]; let (lint_opts, lint_caps) = init_lints(lints_to_show, lint_opts, |lint| { diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index 48dc52c9550..fa8bd24efa9 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -11,8 +11,8 @@ mod stripper; pub use stripper::*; -mod automatic_links; -pub use self::automatic_links::CHECK_AUTOMATIC_LINKS; +mod url_improvements; +pub use self::url_improvements::CHECK_URL_IMPROVEMENTS; mod collapse_docs; pub use self::collapse_docs::COLLAPSE_DOCS; @@ -93,7 +93,7 @@ pub enum Condition { COLLECT_TRAIT_IMPLS, CALCULATE_DOC_COVERAGE, CHECK_INVALID_HTML_TAGS, - CHECK_AUTOMATIC_LINKS, + CHECK_URL_IMPROVEMENTS, ]; /// The list of passes run by default. @@ -109,7 +109,7 @@ pub enum Condition { ConditionalPass::always(CHECK_CODE_BLOCK_SYNTAX), ConditionalPass::always(CHECK_INVALID_HTML_TAGS), ConditionalPass::always(PROPAGATE_DOC_CFG), - ConditionalPass::always(CHECK_AUTOMATIC_LINKS), + ConditionalPass::always(CHECK_URL_IMPROVEMENTS), ]; /// The list of default passes run when `--doc-coverage` is passed to rustdoc. diff --git a/src/librustdoc/passes/automatic_links.rs b/src/librustdoc/passes/url_improvements.rs similarity index 86% rename from src/librustdoc/passes/automatic_links.rs rename to src/librustdoc/passes/url_improvements.rs index 816d2fd15ee..d191a89948a 100644 --- a/src/librustdoc/passes/automatic_links.rs +++ b/src/librustdoc/passes/url_improvements.rs @@ -10,9 +10,9 @@ use rustc_feature::UnstableFeatures; use rustc_session::lint; -pub const CHECK_AUTOMATIC_LINKS: Pass = Pass { - name: "check-automatic-links", - run: check_automatic_links, +pub const CHECK_URL_IMPROVEMENTS: Pass = Pass { + name: "check-url-improvements", + run: check_url_improvements, description: "detects URLS that could be written using angle brackets", }; @@ -23,14 +23,14 @@ r"\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" // optional query or url fragments ); -struct AutomaticLinksLinter<'a, 'tcx> { +struct UrlImprovementsLinter<'a, 'tcx> { cx: &'a DocContext<'tcx>, regex: Regex, } -impl<'a, 'tcx> AutomaticLinksLinter<'a, 'tcx> { +impl<'a, 'tcx> UrlImprovementsLinter<'a, 'tcx> { fn new(cx: &'a DocContext<'tcx>) -> Self { - AutomaticLinksLinter { cx, regex: Regex::new(URL_REGEX).expect("failed to build regex") } + UrlImprovementsLinter { cx, regex: Regex::new(URL_REGEX).expect("failed to build regex") } } fn find_raw_urls( @@ -53,17 +53,17 @@ fn find_raw_urls( } } -pub fn check_automatic_links(krate: Crate, cx: &DocContext<'_>) -> Crate { +pub fn check_url_improvements(krate: Crate, cx: &DocContext<'_>) -> Crate { if !UnstableFeatures::from_environment().is_nightly_build() { krate } else { - let mut coll = AutomaticLinksLinter::new(cx); + let mut coll = UrlImprovementsLinter::new(cx); coll.fold_crate(krate) } } -impl<'a, 'tcx> DocFolder for AutomaticLinksLinter<'a, 'tcx> { +impl<'a, 'tcx> DocFolder for UrlImprovementsLinter<'a, 'tcx> { fn fold_item(&mut self, item: Item) -> Option { let hir_id = match self.cx.as_local_hir_id(item.def_id) { Some(hir_id) => hir_id, @@ -78,7 +78,7 @@ fn fold_item(&mut self, item: Item) -> Option { let sp = super::source_span_for_markdown_range(cx, &dox, &range, &item.attrs) .or_else(|| span_of_attrs(&item.attrs)) .unwrap_or(item.source.span()); - cx.tcx.struct_span_lint_hir(lint::builtin::AUTOMATIC_LINKS, hir_id, sp, |lint| { + cx.tcx.struct_span_lint_hir(lint::builtin::URL_IMPROVEMENTS, hir_id, sp, |lint| { lint.build(msg) .span_suggestion( sp, diff --git a/src/test/rustdoc-ui/automatic-links.rs b/src/test/rustdoc-ui/url-improvements.rs similarity index 96% rename from src/test/rustdoc-ui/automatic-links.rs rename to src/test/rustdoc-ui/url-improvements.rs index 27eb4e4a646..761ec31feca 100644 --- a/src/test/rustdoc-ui/automatic-links.rs +++ b/src/test/rustdoc-ui/url-improvements.rs @@ -1,4 +1,4 @@ -#![deny(automatic_links)] +#![deny(url_improvements)] /// [http://a.com](http://a.com) //~^ ERROR unneeded long form for URL @@ -53,7 +53,7 @@ pub fn c() {} /// [b]: http://b.com pub fn everything_is_fine_here() {} -#[allow(automatic_links)] +#[allow(url_improvements)] pub mod foo { /// https://somewhere.com/a?hello=12&bye=11#xyz pub fn bar() {} diff --git a/src/test/rustdoc-ui/automatic-links.stderr b/src/test/rustdoc-ui/url-improvements.stderr similarity index 98% rename from src/test/rustdoc-ui/automatic-links.stderr rename to src/test/rustdoc-ui/url-improvements.stderr index 00e210aaaa2..7ef287dfd11 100644 --- a/src/test/rustdoc-ui/automatic-links.stderr +++ b/src/test/rustdoc-ui/url-improvements.stderr @@ -7,8 +7,8 @@ LL | /// [http://a.com](http://a.com) note: the lint level is defined here --> $DIR/automatic-links.rs:1:9 | -LL | #![deny(automatic_links)] - | ^^^^^^^^^^^^^^^ +LL | #![deny(url_improvements)] + | ^^^^^^^^^^^^^^^^ error: unneeded long form for URL --> $DIR/automatic-links.rs:5:5 -- 2.44.0