about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/lint.rs
AgeCommit message (Collapse)AuthorLines
2025-08-19mention lint group in default level lint noteKarol Zwolak-2/+27
2025-06-03decouple "reporting in deps" from future incompatibility reasonWaffle Lapkin-3/+2
2025-04-03Remove `LintExpectationId` from `Level` variantsOli Scherer-23/+29
2025-04-03Make LevelAndSource a structOli Scherer-12/+16
2025-04-03Split ExpectationLintId off LevelOli Scherer-7/+9
2025-02-21Move methods from Map to TyCtxt, part 3.Nicholas Nethercote-1/+1
Continuing the work from #137162. Every method gains a `hir_` prefix.
2025-02-02Convert two `rustc_middle::lint` functions to `Span` methods.Nicholas Nethercote-37/+3
`rustc_middle` is a huge crate and it's always good to move stuff out of it. There are lots of similar methods already on `Span`, so these two functions, `in_external_macro` and `is_from_async_await`, fit right in. The diff is big because `in_external_macro` is used a lot by clippy lints.
2025-01-20make it possible to silence linker warnings with a crate-level attributejyn-3/+3
this was slightly complicated because codegen_ssa doesn't have access to a tcx.
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+2
`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-11-19lints_that_dont_need_to_run: never skip future-compat-reported lintsRalf Jung-6/+1
2024-11-14Mark `never_type_fallback_flowing_into_unsafe` as a semantic changeMaybe Lapkin-0/+5
...rather than a future error
2024-11-14Mention both release *and* edition breakage for never type lintsMaybe Lapkin-0/+6
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-08-31Rewrite lint_expectations in a single pass.Camille GILLOT-1/+2
2024-08-08Only suggest `#[allow]` for `--warn` and `--deny` lint level flagsAlex Macleod-3/+5
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-8/+2
[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_middle`.Nicholas Nethercote-0/+1
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-8/+2
* 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_macros` from `rustc_middle`.Nicholas Nethercote-0/+1
2024-03-17Guard decorate on when not to skip instead许杰友 Jieyou Xu (Joe)-7/+4
2024-03-17Invoke decorate when error level is beyond warning, including error许杰友 Jieyou Xu (Joe)-7/+16
2024-03-17Only invoke `decorate` if the diag can eventually be emitted许杰友 Jieyou Xu (Joe)-2/+10
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-3/+3
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-8/+7
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-19Prefer `DiagnosticBuilder` over `Diagnostic` in diagnostic modifiers.Nicholas Nethercote-4/+4
There are lots of functions that modify a diagnostic. This can be via a `&mut Diagnostic` or a `&mut DiagnosticBuilder`, because the latter type wraps the former and impls `DerefMut`. This commit converts all the `&mut Diagnostic` occurrences to `&mut DiagnosticBuilder`. This is a step towards greatly simplifying `Diagnostic`. Some of the relevant function are made generic, because they deal with both errors and warnings. No function bodies are changed, because all the modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`.
2024-02-13Do not point at `#[allow(_)]` as the reason for compat lint triggeringEsteban Küber-0/+5
Fix #121009.
2024-01-23Rename `struct_lint_level` as `lint_level`.Nicholas Nethercote-3/+3
2024-01-23Rename `TyCtxt::emit_spanned_lint` as `TyCtxt::emit_node_span_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `TyCtxt::emit_lint` as `TyCtxt::emit_node_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `TyCtxt::struct_lint_node` as `TyCtxt::node_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `LintContext::lookup` as `LintContext::opt_span_lint`.Nicholas Nethercote-1/+1
2024-01-14Rework how diagnostic lints are stored.Nicholas Nethercote-5/+2
`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not.
2024-01-11Change how `force-warn` lint diagnostics are recorded.Nicholas Nethercote-8/+6
`is_force_warn` is only possible for diagnostics with `Level::Warning`, but it is currently stored in `Diagnostic::code`, which every diagnostic has. This commit: - removes the boolean `DiagnosticId::Lint::is_force_warn` field; - adds a `ForceWarning` variant to `Level`. Benefits: - The common `Level::Warning` case now has no arguments, replacing lots of `Warning(None)` occurrences. - `rustc_session::lint::Level` and `rustc_errors::Level` are more similar, both having `ForceWarning` and `Warning`.
2024-01-08Use chaining for `DiagnosticBuilder` construction and `emit`.Nicholas Nethercote-1/+0
To avoid the use of a mutable local variable, and because it reads more nicely.
2024-01-04Remove `is_lint` field from `Level::Error`.Nicholas Nethercote-1/+1
Because it's redundant w.r.t. `Diagnostic::is_lint`, which is present for every diagnostic level. `struct_lint_level_impl` was the only place that set the `Error` field to `true`, and it's also the only place that calls `Diagnostic::is_lint()` to set the `is_lint` field.
2024-01-03Rename some `Diagnostic` setters.Nicholas Nethercote-3/+3
`Diagnostic` has 40 methods that return `&mut Self` and could be considered setters. Four of them have a `set_` prefix. This doesn't seem necessary for a type that implements the builder pattern. This commit removes the `set_` prefixes on those four methods.
2023-12-31rustc_lint: Make `LintLevelsProvider::current_specs()` return `&FxIndexMap`Martin Nordholts-2/+2
So that lint iteration order becomes predicitable. Discovered with `rustc::potential_query_instability`.
2023-12-23Streamline `struct_lint_level`.Nicholas Nethercote-23/+13
We can just get the error level in the `match` and then use `DiagnosticBuilder::new`. This then means a number of `DiagCtxt` functions are no longer needed, because this was the one place that used them. Note: the commit changes the treatment of spans for `Expect`, which was different to all the other cases, but this has no apparent effect.
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-2/+2
2023-12-18Rename `HandlerInner` as `DiagCtxtInner`.Nicholas Nethercote-1/+1
2023-12-15Fix commentsMichael Goulet-22/+3
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-9/+2
2023-11-04Remove support for compiler plugins.Nicholas Nethercote-2/+1
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes #29597.
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-3/+2
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-09-22give FutureIncompatibilityReason variants more explicit namesRalf Jung-3/+6
2023-09-04Add help to allow lint for the implied by suggestionUrgau-0/+3
2023-08-02fix RedundantLocals clippy caused by async and awaityukang-0/+9
2023-08-02Fix #107113, avoid suggest for macro attributesyukang-1/+5