about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/levels.rs
AgeCommit message (Collapse)AuthorLines
2025-07-23Make lints work with `allow_internal_unstable`Jules Bertholet-0/+1
2025-07-12Port `#[automatically_derived]` to the new attribute parsing infrastructureJonathan Brouwer-1/+1
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-25Add runtime check to avoid overwrite arg easily in diag and store and ↵xizheyin-2/+3
restore snapshot when set subdiag arg Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-03decouple "reporting in deps" from future incompatibility reasonWaffle Lapkin-1/+1
2025-04-10Fix `register_group_alias` for toolsAlex Macleod-2/+2
2025-04-04Do not visit whole crate to compute `lints_that_dont_need_to_run`.Camille GILLOT-90/+27
2025-04-03Remove `LintExpectationId` from `Level` variantsOli Scherer-47/+43
2025-04-03Make LevelAndSource a structOli Scherer-26/+33
2025-03-31Expose `LintLevelsBuilder` with crate root builderUrgau-0/+13
2025-03-14Rollup merge of #138434 - compiler-errors:lint-level-pat-field, r=jieyouxuJacob Pratt-0/+5
Visit `PatField` when collecting lint levels Fixes #138428 Side-note, I vaguely skimmed over the other nodes we could be visiting here and it doesn't *seem* to me that we're missing anything, though I may be mistaken given recent(?) support for attrs in where clauses(??). Can be fixed in a follow-up PR.
2025-03-13Visit PatField when collecting lint levelsMichael Goulet-0/+5
2025-03-12Rename `hir_attrs` query as `hir_attr_map`.Nicholas Nethercote-1/+1
To make room for the moving of `Map::attrs` to `TyCtxt::hir_attrs` in the next commit. (It makes sense to rename the query, because it has many fewer uses than the method.)
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-1/+1
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-4/+4
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2024-12-18Rollup merge of #134481 - estebank:unstable-lint-span, r=compiler-errorsJacob Pratt-1/+1
Point at lint name instead of whole attr for gated lints ``` warning: unknown lint: `test_unstable_lint` --> $DIR/warn-unknown-unstable-lint-inline.rs:4:10 | LL | #![allow(test_unstable_lint, another_unstable_lint)] | ^^^^^^^^^^^^^^^^^^ | = note: the `test_unstable_lint` lint is unstable = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date note: the lint level is defined here --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9 | LL | #![warn(unknown_lints)] | ^^^^^^^^^^^^^ warning: unknown lint: `test_unstable_lint` --> $DIR/warn-unknown-unstable-lint-inline.rs:4:29 | LL | #![allow(test_unstable_lint, another_unstable_lint)] | ^^^^^^^^^^^^^^^^^^^^^ | = note: the `another_unstable_lint` lint is unstable = help: add `#![feature(another_unstable_lint)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date ``` This is particularly relevant when there are multiple lints in the same `warn` attribute. Pointing at the smaller span makes it clearer which one the warning is complaining about.
2024-12-18Point at lint name instead of whole attr for gated lintsEsteban Küber-1/+1
``` warning: unknown lint: `test_unstable_lint` --> $DIR/warn-unknown-unstable-lint-inline.rs:4:10 | LL | #![allow(test_unstable_lint, another_unstable_lint)] | ^^^^^^^^^^^^^^^^^^ | = note: the `test_unstable_lint` lint is unstable = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date note: the lint level is defined here --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9 | LL | #![warn(unknown_lints)] | ^^^^^^^^^^^^^ warning: unknown lint: `test_unstable_lint` --> $DIR/warn-unknown-unstable-lint-inline.rs:4:29 | LL | #![allow(test_unstable_lint, another_unstable_lint)] | ^^^^^^^^^^^^^^^^^^^^^ | = note: the `test_unstable_lint` lint is unstable = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date note: the lint level is defined here --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9 | LL | #![warn(unknown_lints)] | ^^^^^^^^^^^^^ ``` This is particularly relevant when there are multiple lints in the same `warn` attribute. Pointing at the smaller span makes it clearer which one the warning is complaining about.
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-16split attributesJonathan Dönszelmann-1/+1
2024-12-15Add hir::AttributeJonathan Dönszelmann-5/+10
2024-11-19lints_that_dont_need_to_run: never skip future-compat-reported lintsRalf Jung-10/+12
2024-10-26Auto merge of #125116 - blyxyas:ignore-allowed-lints-final, r=cjgillotbors-3/+112
(Big performance change) Do not run lints that cannot emit Before this change, adding a lint was a difficult matter because it always had some overhead involved. This was because all lints would run, no matter their default level, or if the user had `#![allow]`ed them. This PR changes that. This change would improve both the Rust lint infrastructure and Clippy, but Clippy will see the most benefit, as it has about 900 registered lints (and growing!) So yeah, with this little patch we filter all lints pre-linting, and remove any lint that is either: - Manually `#![allow]`ed in the whole crate, - Allowed in the command line, or - Not manually enabled with `#[warn]` or similar, and its default level is `Allow` As some lints **need** to run, this PR also adds **loadbearing lints**. On a lint declaration, you can use the ``@eval_always` = true` marker to label it as loadbearing. A loadbearing lint will never be filtered (it will always run) Fixes #106983
2024-10-22terminology: #[feature] *enables* a feature (instead of "declaring" or ↵Ralf Jung-1/+1
"activating" it)
2024-10-19Apply review comments + use `shallow_lint_levels_on`blyxyas-5/+15
2024-10-19Remove module passes filteringblyxyas-90/+36
2024-10-19Follow review comments (optimize the filtering)blyxyas-83/+119
2024-10-19Change lints_to_emit to lints_that_actually_runblyxyas-18/+22
2024-10-19Do not run lints that cannot emitblyxyas-4/+117
Before this change, adding a lint was a difficult matter because it always had some overhead involved. This was because all lints would run, no matter their default level, or if the user had #![allow]ed them. This PR changes that
2024-10-18Allow `#[deny(..)]` inside `#[forbid(..)]` as a no-op with a warningNoratrieb-1/+4
Forbid cannot be overriden. When someome tries to do this anyways, it results in a hard error. That makes sense. Except it doesn't, because macros. Macros may reasonably use `#[deny]` in their expansion to assert that their expanded code follows the lint. This is doesn't work when the output gets expanded into a `forbid()` context. This is pretty silly, since both the macros and the code agree on the lint! Therefore, we allow `#[deny(..)]`ing a lint that's already forbidden, keeping the level at forbid.
2024-10-06Rename NestedMetaItem to MetaItemInnercodemountains-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-6/+6
2024-09-14Fix lint levels not getting overridden by attrs on `Stmt` nodesGurinder Singh-5/+3
2024-08-31Simplify lint source computation.Camille GILLOT-105/+83
2024-08-31Remove attr_id from stable lint ids.Camille GILLOT-12/+6
2024-08-31Rewrite lint_expectations in a single pass.Camille GILLOT-144/+6
2024-08-31Use AttrId key for unstable<->stable expectation map.Camille GILLOT-5/+4
2024-08-27Add `warn(unreachable_pub)` to `rustc_lint`.Nicholas Nethercote-1/+1
2024-08-21Use bool in favor of Option<()> for diagnosticsMichael Goulet-1/+1
2024-08-10rustc_lint: remove some redundant `#[allow(rustc::untranslatable_diagnostic)]`Pavel Grigorenko-2/+0
2024-07-29Reformat `use` declarations.Nicholas Nethercote-25/+17
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-25RFC 2383: Stabilize `lint_reasons` :tada:xFrednet-10/+0
2024-06-03Tweak `CheckLintNameResult::Tool`.Nicholas Nethercote-35/+25
It has a clumsy type, with repeated `&'a [LintId]`, and sometimes requires an empty string that isn't used in the `Err`+`None` case. This commit splits it into two variants.
2024-06-03Fix up comments.Nicholas Nethercote-9/+13
Wrap overly long ones, etc.
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-25/+17
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_lint`.Nicholas Nethercote-0/+1
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-25/+17
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+1
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-2/+2
2024-03-19The AssocOpaqueTy HIR node is not actually needed to differentiate from ↵Oli Scherer-1/+1
other hir nodes that were fed
2024-03-18Provide structured suggestion for `#![feature(foo)]`Esteban Küber-0/+1
``` error: `S2<'_>` is forbidden as the type of a const generic parameter --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); | ^^ | = note: the only supported types are integers, `bool` and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | ``` Fix #55941.
2024-03-14Auto merge of #120943 - petrochenkov:somehir3, r=oli-obkbors-0/+1
Create some minimal HIR for associated opaque types `LocalDefId`s for opaque types in traits and impls are created after AST -> HIR lowering, so they don't have corresponding HIR and return their various properties through fed queries. In this PR I also feed some core HIR-related queries for these `LocalDefId`s (which happen to be HIR owners). As a result all `LocalDefId`s now have corresponding `HirId`s and HIR nodes, and "optional" methods like `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id` can be removed. Follow up to https://github.com/rust-lang/rust/pull/120206.