diff options
| author | bors <bors@rust-lang.org> | 2025-06-29 07:22:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-06-29 07:22:39 +0000 |
| commit | 5ca574e85b67cec0a6fc3fddfe398cbe676c9c69 (patch) | |
| tree | c7d3e5ee81cf83ba8226119a5097b80f093d2cdd /src | |
| parent | dddd7ab96229ea5f2ca96afcb5984a9831393a13 (diff) | |
| parent | a262c001f6fd131e2eca2d45627fa5bb7754fd6c (diff) | |
| download | rust-5ca574e85b67cec0a6fc3fddfe398cbe676c9c69.tar.gz rust-5ca574e85b67cec0a6fc3fddfe398cbe676c9c69.zip | |
Auto merge of #143173 - matthiaskrgr:rollup-ieu5k05, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142021 (Doc: clarify priority of lint level sources) - rust-lang/rust#142367 (Add regression test for rust-lang/rust#137857 to ensure that we generate intra doc links for extern crate items.) - rust-lang/rust#142641 (Generate symbols.o for proc-macros too) - rust-lang/rust#142889 (Clarify doc comment on unix OpenOptions) - rust-lang/rust#143063 (explain `ImportData::imported_module`) - rust-lang/rust#143088 (Improve documentation of `TagEncoding`) - rust-lang/rust#143135 (fix typos on some doc comments) - rust-lang/rust#143138 (Port `#[link_name]` to the new attribute parsing infrastructure) - rust-lang/rust#143155 (`librustdoc` house-keeping 🧹) - rust-lang/rust#143169 (Remove unused feature gates) - rust-lang/rust#143171 (Fix the span of trait bound modifier `[const]`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/rustc/src/lints/levels.md | 103 | ||||
| -rw-r--r-- | src/librustdoc/Cargo.toml | 8 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 12 |
3 files changed, 110 insertions, 13 deletions
diff --git a/src/doc/rustc/src/lints/levels.md b/src/doc/rustc/src/lints/levels.md index 18e827bd3c9..5b002b435a5 100644 --- a/src/doc/rustc/src/lints/levels.md +++ b/src/doc/rustc/src/lints/levels.md @@ -330,4 +330,105 @@ $ This feature is used heavily by Cargo; it will pass `--cap-lints allow` when compiling your dependencies, so that if they have any warnings, they do not -pollute the output of your build. +pollute the output of your build. However, note that `--cap-lints allow` does **not** override lints marked as `force-warn`. + +## Priority of lint level sources + +Rust allows setting lint levels (`allow`, `warn`, `deny`, `forbid`, `force-warn`) through various sources: + +- **Attributes**: `#[allow(...)]`, `#![deny(...)]`, etc. +- **Command-line options**: `--cap-lints`, `--force-warn`, `-A`, `-W`, `-D`, `-F` + +Here’s how these different lint controls interact: + +1. [`--force-warn`](#force-warn) forces a lint to warning level, and takes precedence over attributes and all other CLI flags. + + ```rust,compile_fail + #[forbid(unused_variables)] + fn main() { + let x = 42; + } + ``` + + Compiled with: + + ```bash + $ rustc --force-warn unused_variables lib.rs + warning: unused variable: `x` + --> lib.rs:3:9 + | + 3 | let x = 42; + | ^ help: if this is intentional, prefix it with an underscore: `_x` + | + = note: requested on the command line with `--force-warn unused-variables` + + warning: 1 warning emitted + ``` + +2. [`--cap-lints`](#capping-lints) sets the maximum level of a lint, and takes precedence over attributes as well as the `-D`, `-W`, and `-F` CLI flags. + + ```rust,compile_fail + #[deny(unused_variables)] + fn main() { + let x = 42; + } + ``` + + Compiled with: + + ```bash + $ rustc --cap-lints=warn lib.rs + warning: unused variable: `x` + --> test1.rs:3:9 + | + 3 | let x = 42; + | ^ help: if this is intentional, prefix it with an underscore: `_x` + | + note: the lint level is defined here + --> test1.rs:1:8 + | + 1 | #[deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + + warning: 1 warning emitted + ``` + +3. [CLI level flags](#via-compiler-flag) take precedence over attributes. + + The order of the flags matter; flags on the right take precedence over earlier flags. + + ```rust + fn main() { + let x = 42; + } + ``` + + Compiled with: + + ```bash + $ rustc -A unused_variables -D unused_variables lib.rs + error: unused variable: `x` + --> test1.rs:2:9 + | + 2 | let x = 42; + | ^ help: if this is intentional, prefix it with an underscore: `_x` + | + = note: requested on the command line with `-D unused-variables` + + error: aborting due to 1 previous error + ``` + +4. Within the source, [attributes](#via-an-attribute) at a lower-level in the syntax tree take precedence over attributes at a higher level, or from a previous attribute on the same entity as listed in left-to-right source order. + + ```rust + #![deny(unused_variables)] + + #[allow(unused_variables)] + fn main() { + let x = 42; // Allow wins + } + ``` + + - The exception is once a lint is set to "forbid", it is an error to try to change its level except for `deny`, which is allowed inside a forbid context, but is ignored. + +In terms of priority, [lint groups](groups.md) are treated as-if they are expanded to a list of all of the lints they contain. The exception is the `warnings` group which ignores attribute and CLI order and applies to all lints that would otherwise warn within the entity. diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index bba8e630bcc..fdde8309cf9 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -8,23 +8,25 @@ build = "build.rs" path = "lib.rs" [dependencies] +# tidy-alphabetical-start arrayvec = { version = "0.7", default-features = false } askama = { version = "0.14", default-features = false, features = ["alloc", "config", "derive"] } base64 = "0.21.7" -itertools = "0.12" indexmap = "2" +itertools = "0.12" minifier = { version = "0.3.5", default-features = false } pulldown-cmark-escape = { version = "0.11.0", features = ["simd"] } regex = "1" rustdoc-json-types = { path = "../rustdoc-json-types" } -serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" smallvec = "1.8.1" tempfile = "3" +threadpool = "1.8.1" tracing = "0.1" tracing-tree = "0.3.0" -threadpool = "1.8.1" unicode-segmentation = "1.9" +# tidy-alphabetical-end [dependencies.tracing-subscriber] version = "0.3.3" diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 025c135aff2..a3cdc4f687f 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -1,8 +1,8 @@ +// tidy-alphabetical-start #![doc( html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/" )] -#![feature(rustc_private)] #![feature(ascii_char)] #![feature(ascii_char_variants)] #![feature(assert_matches)] @@ -11,18 +11,12 @@ #![feature(file_buffered)] #![feature(format_args_nl)] #![feature(if_let_guard)] -#![feature(impl_trait_in_assoc_type)] #![feature(iter_intersperse)] -#![feature(never_type)] #![feature(round_char_boundary)] +#![feature(rustc_private)] #![feature(test)] -#![feature(type_alias_impl_trait)] -#![feature(type_ascription)] -#![recursion_limit = "256"] #![warn(rustc::internal)] -#![allow(clippy::collapsible_if, clippy::collapsible_else_if)] -#![allow(rustc::diagnostic_outside_of_impl)] -#![allow(rustc::untranslatable_diagnostic)] +// tidy-alphabetical-end extern crate thin_vec; |
