about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/unused.rs
AgeCommit message (Collapse)AuthorLines
2025-09-18Rollup merge of #146664 - fmease:clean-up-dyn, r=jdonszelmannStuart Cook-1/+1
Clean up `ty::Dynamic` 1. As a follow-up to PR rust-lang/rust#143036, remove `DynKind` entirely. 2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait` * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types * `lint` contained dyn-Trait-specific diagnostics+lints only
2025-09-17Remove `DynKind`León Orell Valerian Liehr-1/+1
2025-09-16Keep space if expr follows identifier when lint unused parensMu001999-0/+8
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-2/+2
2025-07-29Create two methods to fix `find_oldest_ancestor_in_same_ctxt`xizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-28/+25
Some `let chains` clean-up Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one r? compiler
2025-07-28use let chains in hir, lint, mirKivooeo-28/+25
2025-07-24Replace unwrap_or with explicit matchBen Schulz-3/+6
2025-07-24Fix unused_parens false positiveBen Schulz-1/+6
2025-07-10Remove uncessary parens in closure body with unused lintyukang-1/+9
2025-07-06compiler: rename {ast,hir}::BareFn* to FnPtr*Jubilee Young-1/+1
Fix some comments and related types and locals where it is obvious, e.g. - bare_fn -> fn_ptr - LifetimeBinderKind::BareFnType -> LifetimeBinderKind::FnPtrType Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-07-02Rollup merge of #142237 - benschulz:unused-parens-fn, r=fee1-deadMatthias Krüger-10/+118
Detect more cases of unused_parens around types With this change, more unused parentheses around bounds and types nested within bounds are detected.
2025-07-01Detect more cases of unused_parens around typesBenjamin Schulz-10/+118
2025-06-25Fix suggestion spans inside macros for the `unused_must_use` lintUrgau-4/+6
2025-06-22Port `#[must_use]` to new attribute parsing infrastructureJonathan Brouwer-3/+6
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-05-25Fix `unused_braces` lint suggestion when encountering attributesUrgau-16/+19
2025-04-30stop check paren if has different ctxbohan-0/+16
2025-03-28Add `{ast,hir,thir}::PatKind::Missing` variants.Nicholas Nethercote-1/+2
"Missing" patterns are possible in bare fn types (`fn f(u32)`) and similar places. Currently these are represented in the AST with `ast::PatKind::Ident` with no `by_ref`, no `mut`, an empty ident, and no sub-pattern. This flows through to `{hir,thir}::PatKind::Binding` for HIR and THIR. This is a bit nasty. It's very non-obvious, and easy to forget to check for the exceptional empty identifier case. This commit adds a new variant, `PatKind::Missing`, to do it properly. The process I followed: - Add a `Missing` variant to `{ast,hir,thir}::PatKind`. - Chang `parse_param_general` to produce `ast::PatKind::Missing` instead of `ast::PatKind::Missing`. - Look through `kw::Empty` occurrences to find functions where an existing empty ident check needs replacing with a `PatKind::Missing` check: `print_param`, `check_trait_item`, `is_named_param`. - Add a `PatKind::Missing => unreachable!(),` arm to every exhaustive match identified by the compiler. - Find which arms are actually reachable by running the test suite, changing them to something appropriate, usually by looking at what would happen to a `PatKind::Ident`/`PatKind::Binding` with no ref, no `mut`, an empty ident, and no subpattern. Quite a few of the `unreachable!()` arms were never reached. This makes sense because `PatKind::Missing` can't happen in every pattern, only in places like bare fn tys and trait fn decls. I also tried an alternative approach: modifying `ast::Param::pat` to hold an `Option<P<Pat>>` instead of a `P<Pat>`, but that quickly turned into a very large and painful change. Adding `PatKind::Missing` is much easier.
2025-02-15Remove unnecessary check code in unused_delimsyukang-24/+0
2025-02-08Rustfmtbjorn3-44/+54
2025-01-28Make item self/non-self bound naming less whackMichael Goulet-19/+16
2025-01-08Rename PatKind::Lit to ExprOli Scherer-1/+1
2024-12-23Use `#[derive(Default)]` instead of manually implementing itEsteban Küber-6/+1
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-08Rollup merge of #133424 - Nadrieril:guard-patterns-parsing, r=fee1-deadMatthias Krüger-1/+1
Parse guard patterns This implements the parsing of [RFC3637 Guard Patterns](https://rust-lang.github.io/rfcs/3637-guard-patterns.html) (see also [tracking issue](https://github.com/rust-lang/rust/issues/129967)). This PR is extracted from https://github.com/rust-lang/rust/pull/129996 with minor modifications. cc `@max-niederman`
2024-11-28Replace `Symbol::intern` calls with preinterned symbolsclubby789-1/+1
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-3/+3
2024-11-24add guard pattern AST nodeMax Niederman-1/+1
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-2/+2
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-11-14Adding `BreakValue` to UnusedDelimsCtx to make `UnusedParens` and ↵surechen-1/+8
`UnusedBraces` checking `break`
2024-11-12For expr `return (_ = 42);` unused_paren lint should not be triggeredsurechen-0/+2
fixes #131989
2024-10-29Remove region from adjustmentsMichael Goulet-1/+1
2024-10-26Auto merge of #125116 - blyxyas:ignore-allowed-lints-final, r=cjgillotbors-2/+2
(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-19Get rid of const eval_* and try_eval_* helpersMichael Goulet-1/+1
2024-10-19Follow review comments (optimize the filtering)blyxyas-1/+1
2024-10-19Do not run lints that cannot emitblyxyas-2/+2
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-12Make unused_parens's suggestion considering expr's attributessurechen-1/+9
For the expr with attributes, like `let _ = (#[inline] || println!("Hello!"));`, the suggestion's span should contains the attributes, or the suggestion will remove them. fixes #129833
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-58/+48
2024-09-06Make `Ty::boxed_ty` return an `Option`Pavel Grigorenko-3/+2
2024-09-02chore: Fix typos in 'compiler' (batch 1)Alexander Cyon-1/+1
2024-08-27Add `warn(unreachable_pub)` to `rustc_lint`.Nicholas Nethercote-2/+2
2024-08-11Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errorsMatthias Krüger-6/+4
Use more slice patterns inside the compiler Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'. r? ghost
2024-08-07unused_parens: do not lint against parens around &rawRalf Jung-0/+7
2024-08-07Use more slice patterns inside the compilerLeón Orell Valerian Liehr-6/+4
2024-07-29Reformat `use` declarations.Nicholas Nethercote-15/+15
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-07iter_identity is a better nameMichael Goulet-3/+1
2024-06-17Rework precise capturing syntaxMichael Goulet-1/+1
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-2/+2
2024-06-03Fix up comments.Nicholas Nethercote-3/+6
Wrap overly long ones, etc.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_lint`.Nicholas Nethercote-0/+1