about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/passes.rs
AgeCommit message (Collapse)AuthorLines
2025-07-26Auto merge of #139597 - Kobzol:lint-skip, r=BoxyUwUbors-3/+3
Do not run per-module late lints if they can be all skipped We run ~70 late lints for all dependencies even if they use `--cap-lints=allow`, which seems wasteful. It looks like these lints are super fast (unlike early lints), but still. r? `@ghost`
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-1/+1
It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings. This change does slow down compilation of programs that use `include_bytes!` on large files, because the contents of those files are now interned (hashed). This makes `include_bytes!` more similar to `include_str!`, though `include_bytes!` contents still aren't escaped, and hashing is still much cheaper than escaping.
2025-06-23Skip `late_lint_mod_inner` if all built-in lints can be skippedJakub Beránek-2/+2
2025-06-23Fix doc commentJakub Beránek-1/+1
2025-02-07fix empty after lint on impl/trait itemsJonathan Dönszelmann-0/+2
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-02-05Uniformly handle HIR literals in visitors and lintsOli Scherer-0/+1
2025-01-23Split hir `TyKind` and `ConstArgKind` in two and update `hir::Visitor`Boxy-1/+1
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+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-15Add hir::AttributeJonathan Dönszelmann-3/+3
2024-10-26Auto merge of #125116 - blyxyas:ignore-allowed-lints-final, r=cjgillotbors-2/+8
(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-24Pass Ident by reference in ast Visitormaxcabrajac-1/+1
2024-10-19Remove module passes filteringblyxyas-14/+3
2024-10-19Follow review comments (optimize the filtering)blyxyas-1/+12
2024-10-19Do not run lints that cannot emitblyxyas-2/+8
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-09-23add unqualified_local_imports lintRalf Jung-0/+4
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-2/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-03Reduce some `pub` exposure.Nicholas Nethercote-2/+2
2024-05-29Don't require `visit_body` to take a lifetime that must outlive the function ↵Oli Scherer-2/+2
call
2024-03-24Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`Alex Macleod-14/+4
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-1/+1
2023-09-28Remove `rustc_lint_defs::lint_array`DaniPopes-2/+2
2023-09-27Use absolute paths in rustc_lint::passes macrosAlex Macleod-79/+77
A cosmetic change, so the callsite doesn't have to import things
2023-08-31diagnostics: avoid wrong `unused_parens` on `x as (T) < y`Michael Howell-0/+1
2023-01-28Take a LocalDefId in hir::Visitor::visit_fn.Camille GILLOT-1/+2
2023-01-14fix issues in unused lintyukang-0/+3
2022-12-12Reinstate `{Early,Late}LintPassObjects`.Nicholas Nethercote-0/+10
I removed these in #105291, and subsequently learned they are necessary for performance. This commit reinstates them with the new and more descriptive names `RuntimeCombined{Early,Late}LintPass`, similar to the existing passes like `BuiltinCombinedEarlyLintPass`. It also adds some comments, particularly emphasising how we have ways to combine passes at both compile-time and runtime. And it moves some comments around.
2022-12-07Rename `$passes` as `$pass` in several macros.Nicholas Nethercote-14/+14
Because it makes more sense that way.
2022-12-07Add some useful comments.Nicholas Nethercote-0/+4
2022-12-07Remove `$hir` argument from `late_lint_methods!`.Nicholas Nethercote-38/+38
Because it's always `'tcx`.
2022-12-02Auto merge of #104863 - nnethercote:reduce-lint-macros, r=cjgillotbors-19/+6
Reduce macro usage for lints r? `@cjgillot`
2022-12-02Remove some unnecessary `Send` bounds.Nicholas Nethercote-3/+2
Required to get the parallel compiler building again.
2022-12-02Eliminate four unnecessary lint macros.Nicholas Nethercote-16/+4
The lint definitions use macros heavily. This commit merges some of them that are split unnecessarily. I find the reduced indirection makes it easier to imagine what the generated code will look like.
2022-12-01rustc_hir: Relax lifetime requirements on `Visitor::visit_path`Vadim Petrochenkov-1/+1
2022-09-12Remove unused argument from `check_mac_def`.Nicholas Nethercote-1/+1
2022-09-12Remove unused argument from `visit_poly_trait_ref`.Nicholas Nethercote-1/+1
2022-09-12Remove unused span argument from `check_mod` and `process_mod`.Nicholas Nethercote-1/+1
2022-09-06Allow lint passes to be bound by `TyCtxt`Jason Newcomb-1/+1
2022-08-29Remove `Sync` requirement from lint pass objects as they are created on demandJason Newcomb-3/+2
2022-08-11Simplify `rustc_ast::visit::Visitor::visit_poly_trait_ref`.Nicholas Nethercote-2/+1
It is passed an argument that is never used.
2022-07-29Remove some late `check_*` functions.Nicholas Nethercote-19/+1
They're not used by rustc or clippy.
2022-07-29Remove some early `check_*` functions.Nicholas Nethercote-19/+0
They're not used by rustc or clippy.
2021-09-30Do not pass hir::Crate to lints.Camille GILLOT-2/+2
2021-07-25Add inferred args to typeckkadmin-0/+1
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-2/+2
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-2/+0
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
2020-10-16Add check_generic_arg early passSantiago Pastorino-0/+2
2020-08-30mv compiler to compiler/mark-0/+285