about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/context.rs
AgeCommit message (Collapse)AuthorLines
2025-07-02Add `track_caller` attributes to trace origin of Clippy lintsSamuel Tardieu-0/+2
This allows the use of `-Z track-diagnostics` to see the origin of Clippy lints emission, as is already the case for lints coming from rustc.
2025-06-24Rollup merge of #142645 - Urgau:usage-non_upper_case_globals, r=fmeaseMatthias Krüger-0/+14
Also emit suggestions for usages in the `non_upper_case_globals` lint This PR adds suggestions for all the usages of the renamed item in the warning of the `non_upper_case_globals` lint. Fixes https://github.com/rust-lang/rust/issues/124061
2025-06-22Rollup merge of #142593 - blyxyas:improve-docs-itty-bitty-change, ↵Guillaume Gomez-0/+9
r=compiler-errors Add a warning to LateContext::get_def_path Preventing anyone from doing the same error as https://github.com/rust-lang/rust-clippy/pull/15043 fixed
2025-06-21All HIR attributes are outerDavid Tolnay-3/+4
2025-06-21Add `emit_span_lint_lazy` to lazily create `LintDiagnostic` structsUrgau-0/+14
2025-06-17Add a warning to LateContext::get_def_pathblyxyas-0/+9
2025-06-13Reduce precedence of expressions that have an outer attrDavid Tolnay-0/+15
2025-04-26Avoid re-interning in `LateContext::get_def_path`DaniPopes-1/+4
The def path printer in `get_def_path` essentially calls `Symbol::intern(&symbol.to_string())` for simple symbols in a path. This accounts for ~30% of the runtime of get_def_path. We can avoid this by simply appending the symbol directly when available.
2025-04-17Rollup merge of #139650 - Alexendoo:group-alias, r=davidtwcoMatthias Krüger-58/+39
Fix `register_group_alias` for tools In clippy we're looking at renaming `clippy::all` and registering an alias for it but currently that doesn't work for tools The `lint_ids` of the alias are now populated at the time of registration to make it easier to handle
2025-04-14Move `has_self` field to `hir::AssocKind::Fn`.Nicholas Nethercote-6/+1
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field, which is misplaced, because it's only relevant for associated fns, not for associated consts or types. This commit moves it (and renames it) to the `AssocKind::Fn` variant, where it belongs. This requires introducing a new C-style enum, `AssocTag`, which is like `AssocKind` but without the fields. This is because `AssocKind` values are passed to various functions like `find_by_ident_and_kind` to indicate what kind of associated item should be searched for, and having to specify `has_self` isn't relevant there. New methods: - Predicates `AssocItem::is_fn` and `AssocItem::is_method`. - `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`. Removed `find_by_name_and_kinds`, which is unused. `AssocItem::descr` can now distinguish between methods and associated functions, which slightly improves some error messages.
2025-04-14Use `Symbol` in `LateContext::get_associated_type`.Nicholas Nethercote-2/+7
To avoid unnecessary interning.
2025-04-10Fix `register_group_alias` for toolsAlex Macleod-58/+39
2025-04-10Rename some `name` variables as `ident`.Nicholas Nethercote-1/+1
It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`. This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk.
2025-04-03Remove `LintExpectationId` from `Level` variantsOli Scherer-8/+7
2025-04-03Make LevelAndSource a structOli Scherer-2/+2
2025-03-11Fix false-positive in `expr_or_init` and in the `invalid_from_utf8` lintUrgau-2/+14
2025-03-06Account for UseCloned on expr_use_visitorSantiago Pastorino-0/+4
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-3/+1
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-2/+2
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-02-08Rustfmtbjorn3-10/+16
2025-01-29Remove `LateContext::match_def_path()`Samuel Tardieu-25/+1
This function was only kept for Clippy use. The last use in Clippy was removed in c9315bc3953fcf15154df21f788f2f7a5e8d6e7d.
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-15Access `TyCtxt` from early diagnostic decorationUrgau-35/+1
2024-12-02remove `Ty::is_copy_modulo_regions`lcnr-0/+4
2024-11-23no more Reveal :(lcnr-2/+0
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-5/+9
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-10-29TypingMode :thinking:lcnr-1/+11
2024-10-28Rollup merge of #132249 - workingjubilee:add-rustc-abi, r=compiler-errorsJubilee-2/+1
compiler: Add rustc_abi dependence to the compiler Depend on rustc_abi in compiler crates that use it indirectly but have not yet taken on that dependency, and are not *significantly* entangled in my other PRs. This leaves an "excise rustc_target" step after the dust settles.
2024-10-27compiler: Depend on rustc_abi in rustc_lintJubilee Young-2/+1
2024-10-27Clean up some comments on lint implementationEric Huss-17/+3
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-19/+13
2024-08-07Make `Span` optional in `BufferedEarlyLint`Urgau-2/+16
2024-07-29Reformat `use` declarations.Nicholas Nethercote-10/+11
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-03Tweak `CheckLintNameResult::Tool`.Nicholas Nethercote-18/+21
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-1/+2
Wrap overly long ones, etc.
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-21/+14
[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-1/+1
2024-05-23Delay the construction of early lint diag structsLeón Orell Valerian Liehr-1/+3
Fixes a slew of perf regressions.
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-20/+11
* 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-05-21Make early lints translatableXiretza-13/+8
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-2/+1
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
2024-05-10Lift `TraitRef` into `rustc_type_ir`Michael Goulet-1/+1
2024-04-30Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-deadMatthias Krüger-0/+1
Remove many `#[macro_use] extern crate foo` items This requires the addition of more `use` items, which often make the code more verbose. But they also make the code easier to read, because `#[macro_use]` obscures where macros are defined. r? `@fee1-dead`
2024-04-29[Refactor] Rename Lint and LintGroup\'s is_loaded to is_externally_loadedblyxyas-8/+10
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+1
2024-04-17has_typeck_results doesnt need to be a queryMichael Goulet-1/+1
2024-03-22Rename `hir::Node::Local` into `hir::Node::LetStmt`Guillaume Gomez-2/+2
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-2/+2
2024-03-11Rename `DecorateLint` as `LintDiagnostic`.Nicholas Nethercote-5/+5
To match `derive(LintDiagnostic)`.
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-3/+4
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`.