Skip to content

Commit f92b931

Browse files
committed
Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27
Add non_autolinks lint Part of #77501. r? `@jyn514`
2 parents 9d78d1d + 99200f7 commit f92b931

File tree

34 files changed

+425
-37
lines changed

34 files changed

+425
-37
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,6 +4297,7 @@ dependencies = [
42974297
"itertools 0.9.0",
42984298
"minifier",
42994299
"pulldown-cmark 0.8.0",
4300+
"regex",
43004301
"rustc-rayon",
43014302
"serde",
43024303
"serde_json",

compiler/rustc_codegen_cranelift/src/discriminant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Handling of enum discriminants
22
//!
3-
//! Adapted from https://github.com/rust-lang/rust/blob/d760df5aea483aae041c9a241e7acacf48f75035/src/librustc_codegen_ssa/mir/place.rs
3+
//! Adapted from <https://github.com/rust-lang/rust/blob/d760df5aea483aae041c9a241e7acacf48f75035/src/librustc_codegen_ssa/mir/place.rs>
44
55
use rustc_target::abi::{Int, TagEncoding, Variants};
66

compiler/rustc_lint/src/lib.rs

Lines changed: 2 additions & 1 deletion
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,
72+
MISSING_DOC_CODE_EXAMPLES, NON_AUTOLINKS, PRIVATE_DOC_TESTS,
7373
};
7474
use rustc_span::symbol::{Ident, Symbol};
7575
use rustc_span::Span;
@@ -313,6 +313,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
313313

314314
add_lint_group!(
315315
"rustdoc",
316+
NON_AUTOLINKS,
316317
BROKEN_INTRA_DOC_LINKS,
317318
PRIVATE_INTRA_DOC_LINKS,
318319
INVALID_CODEBLOCK_ATTRIBUTES,

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,17 @@ declare_lint! {
18901890
"detects invalid HTML tags in doc comments"
18911891
}
18921892

1893+
declare_lint! {
1894+
/// The `non_autolinks` lint detects when a URL could be written using
1895+
/// only angle brackets. This is a `rustdoc` only lint, see the
1896+
/// documentation in the [rustdoc book].
1897+
///
1898+
/// [rustdoc book]: ../../../rustdoc/lints.html#non_autolinks
1899+
pub NON_AUTOLINKS,
1900+
Warn,
1901+
"detects URLs that could be written using only angle brackets"
1902+
}
1903+
18931904
declare_lint! {
18941905
/// The `where_clauses_object_safety` lint detects for [object safety] of
18951906
/// [where clauses].
@@ -2795,6 +2806,7 @@ declare_lint_pass! {
27952806
MISSING_DOC_CODE_EXAMPLES,
27962807
INVALID_HTML_TAGS,
27972808
PRIVATE_DOC_TESTS,
2809+
NON_AUTOLINKS,
27982810
WHERE_CLAUSES_OBJECT_SAFETY,
27992811
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
28002812
MACRO_USE_EXTERN_CRATE,

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ pub struct Lint {
9999
/// The name is written with underscores, e.g., "unused_imports".
100100
/// On the command line, underscores become dashes.
101101
///
102-
/// See https://rustc-dev-guide.rust-lang.org/diagnostics.html#lint-naming
102+
/// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html#lint-naming>
103103
/// for naming guidelines.
104104
pub name: &'static str,
105105

106106
/// Default level for the lint.
107107
///
108-
/// See https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-levels
108+
/// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-levels>
109109
/// for guidelines on choosing a default level.
110110
pub default_level: Level,
111111

@@ -330,8 +330,8 @@ impl LintBuffer {
330330

331331
/// Declares a static item of type `&'static Lint`.
332332
///
333-
/// See https://rustc-dev-guide.rust-lang.org/diagnostics.html for documentation
334-
/// and guidelines on writing lints.
333+
/// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html> for
334+
/// documentation and guidelines on writing lints.
335335
///
336336
/// The macro call should start with a doc comment explaining the lint
337337
/// which will be embedded in the rustc user documentation book. It should

compiler/rustc_middle/src/mir/coverage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ rustc_index::newtype_index! {
1717
impl ExpressionOperandId {
1818
/// An expression operand for a "zero counter", as described in the following references:
1919
///
20-
/// * https://github.com/rust-lang/llvm-project/blob/llvmorg-8.0.0/llvm/docs/CoverageMappingFormat.rst#counter
21-
/// * https://github.com/rust-lang/llvm-project/blob/llvmorg-8.0.0/llvm/docs/CoverageMappingFormat.rst#tag
22-
/// * https://github.com/rust-lang/llvm-project/blob/llvmorg-8.0.0/llvm/docs/CoverageMappingFormat.rst#counter-expressions
20+
/// * <https://github.com/rust-lang/llvm-project/blob/llvmorg-8.0.0/llvm/docs/CoverageMappingFormat.rst#counter>
21+
/// * <https://github.com/rust-lang/llvm-project/blob/llvmorg-8.0.0/llvm/docs/CoverageMappingFormat.rst#tag>
22+
/// * <https://github.com/rust-lang/llvm-project/blob/llvmorg-8.0.0/llvm/docs/CoverageMappingFormat.rst#counter-expressions>
2323
///
2424
/// This operand can be used to count two or more separate code regions with a single counter,
2525
/// if they run sequentially with no branches, by injecting the `Counter` in a `BasicBlock` for

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub struct CodegenUnit<'tcx> {
228228

229229
/// Specifies the linkage type for a `MonoItem`.
230230
///
231-
/// See https://llvm.org/docs/LangRef.html#linkage-types for more details about these variants.
231+
/// See <https://llvm.org/docs/LangRef.html#linkage-types> for more details about these variants.
232232
#[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)]
233233
pub enum Linkage {
234234
External,

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ pub struct TypeckResults<'tcx> {
368368
/// leads to a `vec![&&Option<i32>, &Option<i32>]`. Empty vectors are not stored.
369369
///
370370
/// See:
371-
/// https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md#definitions
371+
/// <https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md#definitions>
372372
pat_adjustments: ItemLocalMap<Vec<Ty<'tcx>>>,
373373

374374
/// Borrows

compiler/rustc_mir/src/borrow_check/region_infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
13641364
/// terms that the "longer free region" `'a` outlived the "shorter free region" `'b`.
13651365
///
13661366
/// More details can be found in this blog post by Niko:
1367-
/// http://smallcultfollowing.com/babysteps/blog/2019/01/17/polonius-and-region-errors/
1367+
/// <http://smallcultfollowing.com/babysteps/blog/2019/01/17/polonius-and-region-errors/>
13681368
///
13691369
/// In the canonical example
13701370
///

compiler/rustc_mir/src/transform/dest_prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! inside a single block to shuffle a value around unnecessarily.
99
//!
1010
//! LLVM by itself is not good enough at eliminating these redundant copies (eg. see
11-
//! https://github.com/rust-lang/rust/issues/32966), so this leaves some performance on the table
11+
//! <https://github.com/rust-lang/rust/issues/32966>), so this leaves some performance on the table
1212
//! that we can regain by implementing an optimization for removing these assign statements in rustc
1313
//! itself. When this optimization runs fast enough, it can also speed up the constant evaluation
1414
//! and code generation phases of rustc due to the reduced number of statements and locals.

0 commit comments

Comments
 (0)