about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/late.rs
AgeCommit message (Collapse)AuthorLines
2025-07-26Auto merge of #139597 - Kobzol:lint-skip, r=BoxyUwUbors-1/+10
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-1/+10
2025-03-12Move methods from `Map` to `TyCtxt`, part 4.Nicholas Nethercote-1/+1
Continuing the work from #137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
2025-03-07Move `visit_id` calls.Nicholas Nethercote-1/+1
In `walk_item`, we call `visit_id` on every item kind. For most of them we do it directly in `walk_item`. But for `ItemKind::Mod`, `ItemKind::Enum`, and `ItemKind::Use` we instead do it in the `walk_*` function called (via the `visit_*` function) from `walk_item`. I can see no reason for this inconsistency, so this commit makes those three cases like all the other cases, moving the `visit_id` calls into `walk_item`. This also avoids the need for a few `HirId` arguments.
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-3/+3
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-2/+2
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`.
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-05Uniformly handle HIR literals in visitors and lintsOli Scherer-0/+4
2025-02-01Rename `tcx.ensure()` to `tcx.ensure_ok()`Zalathar-1/+1
2025-01-23Split hir `TyKind` and `ConstArgKind` in two and update `hir::Visitor`Boxy-7/+2
2024-11-05Do not filter empty passes & Make CTFE Clippy into lintless passblyxyas-0/+3
2024-10-27Clean up some comments on lint implementationEric Huss-14/+3
2024-10-19Apply review comments + use `shallow_lint_levels_on`blyxyas-1/+1
2024-10-19Remove module passes filteringblyxyas-35/+12
2024-10-19Follow review comments (optimize the filtering)blyxyas-27/+37
2024-10-19Change lints_to_emit to lints_that_actually_runblyxyas-3/+3
2024-10-19Do not run lints that cannot emitblyxyas-5/+40
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-07Remove an unnecessary `&Lrc<_>` local variable.Nicholas Nethercote-3/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-08-27Add `warn(unreachable_pub)` to `rustc_lint`.Nicholas Nethercote-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-29Don't require `visit_body` to take a lifetime that must outlive the function ↵Oli Scherer-1/+1
call
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_lint`.Nicholas Nethercote-1/+1
2024-04-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-4/+5
Because they're a bit redundant.
2024-03-24Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`Alex Macleod-7/+2
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-1/+1
2024-03-13Create some minimal HIR for associated opaque typesVadim Petrochenkov-1/+1
2024-02-09tidyblyxyas-4/+1
2024-02-09Avoid a collection and iteration on empty passesblyxyas-6/+6
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-1/+1
cleanup
2023-11-22rustc_session: implement latent TODOTamir Duberstein-2/+3
2023-11-22rustc_lint: remove superfluous assertionTamir Duberstein-1/+0
`Option::unwrap` is called on the next line.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-6/+6
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-17Move `lint_store` from `GlobalCtxt` to `Session`.Nicholas Nethercote-7/+13
This was made possible by the removal of plugin support, which simplified lint store creation. This simplifies the places in rustc and rustdoc that call `describe_lints`, which are early on. The lint store is now built before those places, so they don't have to create their own lint store for temporary use, they can just use the main one.
2023-11-17Remove dead lint code.Nicholas Nethercote-2/+0
2023-09-14Auto merge of #115825 - cjgillot:expr-field-lint, r=compiler-errorsbors-0/+4
Visit ExprField for lint levels. Fixes https://github.com/rust-lang/rust/issues/115823
2023-09-13Visit ExprField for lint levels.Camille GILLOT-0/+4
2023-09-10Call `LateLintPass::check_attribute` from `with_lint_attrs`Alex Macleod-13/+12
2023-08-14Use `{Local}ModDefId` in many queriesNilstrieb-3/+3
2023-08-04Make MissingDoc a module lint.Camille GILLOT-20/+22
2023-06-15Add an `ensure_sufficient_stack` to `LateContextAndPass::visit_expr`Scott McMurray-4/+7
This is apparently where it's busting stack, and the comments for `ensure_sufficient_stack` say that > E.g. almost any call to visit_expr or equivalent can benefit from this.
2023-05-19Consider lint check attributes on match arms in late lintsRyo Yoshida-2/+4
Additionally add analogous test for early lints.
2023-05-06introduce `DynSend` and `DynSync` auto traitSparrowLii-2/+2
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-7/+6
2023-01-28Take a LocalDefId in hir::Visitor::visit_fn.Camille GILLOT-1/+1
2023-01-03fix dupe word typosRageking8-1/+1
2022-12-12Speed up the "builtin lints only" case.Nicholas Nethercote-4/+33
This commit partly undoes #104863, which combined the builtin lints pass with other lints. This caused a slowdown, because often there are no other lints, and it's faster to do a pass with a single lint directly than it is to do a combined pass with a `passes` vector containing a single lint.
2022-12-12Reinstate `{Early,Late}LintPassObjects`.Nicholas Nethercote-12/+44
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-05Remove `{Early,Late}LintPassObjects`.Nicholas Nethercote-35/+9
`EarlyContextAndPass` wraps a single early lint pass. We aggregate multiple passes into that single pass by using `EarlyLintPassObjects`. This commit removes `EarlyLintPassObjects` by changing `EarlyContextAndPass` into `EarlyContextAndPasses`. I.e. it just removes a level of indirection. This makes the code simpler and slightly faster. The commit does likewise for late lints.