about summary refs log tree commit diff
path: root/src/tools/clippy
AgeCommit message (Collapse)AuthorLines
2025-06-19Extract Translator structCameron Steffen-3/+2
2025-06-18Rollup merge of #141610 - BoxyUwU:stabilize_generic_arg_infer, ↵Jakub Beránek-11/+10
r=lcnr,traviscross Stabilize `feature(generic_arg_infer)` Fixes rust-lang/rust#85077 r? lcnr cc ````@rust-lang/project-const-generics````
2025-06-18Update/bless clippy tests.Mara Bos-52/+47
2025-06-18Auto merge of #138165 - jdonszelmann:inline, r=oli-obkbors-29/+28
Rewrite `inline` attribute parser to use new infrastructure and improve diagnostics for all parsed attributes r? `@oli-obk` This PR: - creates a new parser for inline attributes - creates consistent error messages and error codes between attribute parsers; inline and others - as such changes a few error messages for other attributes to be (in my eyes) much more consistent - tests ast-lowering lints introduced by rust-lang/rust#138164 since this is now useful for the first time - Coalesce some useless error codes Builds on top of rust-lang/rust#138164 Closes rust-lang/rust#137950
2025-06-17fix clippyJana Dönszelmann-4/+4
2025-06-17Rollup merge of #142371 - fee1-dead-contrib:push-xqlkumzurkus, r=petrochenkovJacob Pratt-3/+3
avoid `&mut P<T>` in `visit_expr` etc methods trying a different way than rust-lang/rust#141636 r? ghost
2025-06-17convert entire codebase to parsed inline attrsJana Dönszelmann-29/+28
2025-06-16clippy: `{Meta,Pointee,}Sized` in non-minicoreDavid Wood-2/+8
One clippy test is `no_core` and needs to have `MetaSized` and `PointeeSized` added to it.
2025-06-16clippy: add `MetaSized` conditionsDavid Wood-1/+8
Existing lints that had special-casing for `Sized` predicates ought to have these same special cases applied to `MetaSized` predicates.
2025-06-15Rollup merge of #134661 - dtolnay:prefixattr, r=fmeaseLeón Orell Valerian Liehr-11/+11
Reduce precedence of expressions that have an outer attr Previously, `-Zunpretty=expanded` would expand this program as follows: ```rust #![feature(stmt_expr_attributes)] macro_rules! repro { ($e:expr) => { #[allow(deprecated)] $e }; } #[derive(Default)] struct Thing { #[deprecated] field: i32, } fn main() { let thing = Thing::default(); let _ = repro!(thing).field; } ``` ```rs #![feature(prelude_import)] #![feature(stmt_expr_attributes)] #[prelude_import] use std::prelude::rust_2021::*; #[macro_use] extern crate std; struct Thing { #[deprecated] field: i32, } #[automatically_derived] impl ::core::default::Default for Thing { #[inline] fn default() -> Thing { Thing { field: ::core::default::Default::default() } } } fn main() { let thing = Thing::default(); let _ = #[allow(deprecated)] thing.field; } ``` This is not the correct expansion. The correct output would have `(#[allow(deprecated)] thing).field` with the attribute applying only to `thing`, not to `thing.field`.
2025-06-14Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errorsMatthias Krüger-11/+5
Unimplement unsized_locals Implements https://github.com/rust-lang/compiler-team/issues/630 Tracking issue here: https://github.com/rust-lang/rust/issues/111942 Note that this just removes the feature, not the implementation, and does not touch `unsized_fn_params`. This is because it is required to support `Box<dyn FnOnce()>: FnOnce()`. There may be more that should be removed (possibly in follow up prs) - the `forget_unsized` function and `forget` intrinsic. - the `unsized_locals` test directory; I've just fixed up the tests for now - various codegen support for unsized values and allocas cc ``@JakobDegen`` ``@oli-obk`` ``@Noratrieb`` ``@programmerjake`` ``@bjorn3`` ``@rustbot`` label F-unsized_locals Fixes rust-lang/rust#79409
2025-06-13Reduce precedence of expressions that have an outer attrDavid Tolnay-11/+11
2025-06-13TypeVisiting binders no longer requires TypeFolding its interiorMichael Goulet-2/+2
2025-06-13Auto merge of #142451 - flip1995:clippy-subtree-update, r=Manishearthbors-668/+4109
Clippy subtree update r? `@Manishearth` 1 day late. Got distracted yesterday evening and forgot about it.
2025-06-13Move COERCE_CONTAINER_TO_ANY to nursery, as it has FPsPhilipp Krones-1/+1
2025-06-13Merge commit '4ef75291b5dd6739212f1f61666d19d4e086690d' into ↵Philipp Krones-668/+4109
clippy-subtree-update
2025-06-13Unimplement unsized_localsmejrs-11/+5
2025-06-12intrinsics: rename min_align_of to align_ofRalf Jung-1/+0
2025-06-12avoid `&mut P<T>` in `visit_expr` etc methodsDeadbeef-3/+3
2025-06-11stabilize gaiBoxy-11/+10
2025-06-10Add jemalloc feature to ClippyJakub Beránek-0/+36
2025-06-06Rollup merge of #141603 - nnethercote:reduce-P, r=fee1-deadGuillaume Gomez-1/+1
Reduce `ast::ptr::P` to a typedef of `Box` As per the MCP at https://github.com/rust-lang/compiler-team/issues/878. r? `@fee1-dead`
2025-06-06Rollup merge of #142012 - oli-obk:no-optional-spans, r=fee1-deadMatthias Krüger-1/+1
Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of None Turns out many locations actually have a span available that we could use, so I used it
2025-06-05Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, ↵bors-45/+54
r=traviscross,jieyouxu Add a new `mismatched-lifetime-syntaxes` lint The lang-team [discussed this](https://hackmd.io/nf4ZUYd7Rp6rq-1svJZSaQ) and I attempted to [summarize](https://github.com/rust-lang/rust/pull/120808#issuecomment-2701863833) their decision. The summary-of-the-summary is: - Using two different kinds of syntax for elided lifetimes is confusing. In rare cases, it may even [lead to unsound code](https://github.com/rust-lang/rust/issues/48686)! Some examples: ```rust // Lint will warn about these fn(v: ContainsLifetime) -> ContainsLifetime<'_>; fn(&'static u8) -> &u8; ``` - Matching up references with no lifetime syntax, references with anonymous lifetime syntax, and paths with anonymous lifetime syntax is an exception to the simplest possible rule: ```rust // Lint will not warn about these fn(&u8) -> &'_ u8; fn(&'_ u8) -> &u8; fn(&u8) -> ContainsLifetime<'_>; ``` - Having a lint for consistent syntax of elided lifetimes will make the [future goal](https://github.com/rust-lang/rust/issues/91639) of warning-by-default for paths participating in elision much simpler. --- This new lint attempts to accomplish the goal of enforcing consistent syntax. In the process, it supersedes and replaces the existing `elided-named-lifetimes` lint, which means it starts out life as warn-by-default.
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-1/+1
2025-06-04Replace `elided_named_lifetimes` with `mismatched_lifetime_syntaxes`Jake Goulding-45/+54
2025-06-04Rollup merge of #141570 - chenyukang:yukang-fix-eq_unspanned, r=workingjubileeMatthias Krüger-1/+3
Fix incorrect eq_unspanned in TokenStream Fixes rust-lang/rust#141522 r? ``@workingjubilee`` should we remove this function? since it's used in several places, i'd prefer to keep it.
2025-06-03Rollup merge of #141698 - oli-obk:ctfe-err-flip, r=RalfJungMatthias Krüger-3/+3
Use the informative error as the main const eval error message r? `@RalfJung` I only did the minimal changes necessary to the const eval error machinery. I'd prefer not to mix test changes with refactorings 😆
2025-06-03Rollup merge of #141741 - nnethercote:overhaul-UsePath, r=petrochenkovMatthias Krüger-29/+32
Overhaul `UsePath` It currently uses `SmallVec<[Res; 3]>` which is really weird. Details in the individual commits. r? `@petrochenkov`
2025-06-03Overhaul `UsePath`.Nicholas Nethercote-26/+29
`UsePath` contains a `SmallVec<[Res; 3]>`. This holds up to three `Res` results, one per namespace (type, value, or macro). `lower_import_res` takes a `PerNS<Option<Res<NodeId>>>` result and lowers it into the `SmallVec`. This is pretty weird. The input `PerNS` makes it clear which `Res` belongs to which namespace, but the `SmallVec` throws that information away. And code that operates on the `SmallVec` tends to use iteration (or even just grabbing the first entry!) without knowing which namespace the `Res` belongs to. Even weirder! Also, `SmallVec` is an overly flexible type to use here, because it can contain any number of elements (even though it's optimized for 3 in this case). This commit changes `UsePath` so it also contains a `PerNS<Option<Res<HirId>>>`. This type preserves more information and is more self-documenting. The commit also changes a lot of the use sites to access the result for a particular namespace. E.g. if you're looking up a trait, it will be in the `Res` for the type namespace if it's present; it's silly to look in the `Res` for the value namespace or macro namespace. Overall I find the new code much easier to understand. However, some use sites still iterate. These now use `present_items` because that filters out the `None` results. Also, `redundant_pub_crate.rs` gets a bigger change. A `UseKind:ListStem` item gets no `Res` results, which means the old `all` call in `is_not_macro_export` would succeed (because `all` succeeds on an empty iterator) and the `ListStem` would be ignored. This is what we want, but was more by luck than design. The new code detects `ListStem` explicitly. The commit generalizes the name of that function accordingly. Finally, the commit also removes the `use_path` arena, because `PerNS<Option<Res>>` impls `Copy` (unlike `SmallVec`) and it can be allocated in the arena shared by all `Copy` types.
2025-06-02Clarify why we are talking about a failed const eval at a random placeOli Scherer-1/+1
2025-06-02Use the informative error as the main const eval error messageOli Scherer-3/+3
2025-06-02Auto merge of #141814 - flip1995:clippy-subtree-update, r=Manishearthbors-671/+1995
Clippy subtree update r? `@Manishearth`
2025-06-02Invert the sense of `is_not_macro_export`.Nicholas Nethercote-5/+5
I find it much easier to think about in the positive sense.
2025-06-01Rollup merge of #141072 - Rynibami:stabilize-const-result-flatten, r=jhprattJacob Pratt-12/+10
Stabilize feature `result_flattening` Stabilizes the `Result::flatten` method ## Implementations - [x] Implementation `Result::flatten`: https://github.com/rust-lang/rust/pull/70140 - [x] Implementation `const` `Result::flatten`: https://github.com/rust-lang/rust/pull/130692 - [x] Update stabilization attribute macros (this PR) ## Stabilization process - [x] Created this PR [suggested](https://github.com/rust-lang/rust/issues/70142#issuecomment-2885044548) by ``@RalfJung`` - [x] FCP (haven't found any, is it applicable here?) - [ ] Close issue rust-lang/rust#70142
2025-05-31Merge commit '57cbadd68ac473bc50453f6b1320a02b68115f12'Philipp Krones-671/+1995
2025-05-30Reorder fields in `hir::ItemKind` variants.Nicholas Nethercote-21/+21
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match the textual order in the source code. The interesting part of the change is in `compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical refactoring.
2025-05-29Auto merge of #141717 - jhpratt:rollup-neu8nzl, r=jhprattbors-101/+94
Rollup of 4 pull requests Successful merges: - rust-lang/rust#138285 (Stabilize `repr128`) - rust-lang/rust#139994 (add `CStr::display`) - rust-lang/rust#141571 (coretests: extend and simplify float tests) - rust-lang/rust#141656 (CI: Add cargo tests to aarch64-apple-darwin) Failed merges: - rust-lang/rust#141430 (remove `visit_clobber` and move `DummyAstNode` to `rustc_expand`) - rust-lang/rust#141636 (avoid some usages of `&mut P<T>` in AST visitors) r? `@ghost` `@rustbot` modify labels: rollup
2025-05-29Rollup merge of #141675 - nnethercote:ItemKind-field-order, r=fee1-deadJacob Pratt-6/+6
Reorder `ast::ItemKind::{Struct,Enum,Union}` fields. So they match the order of the parts in the source code, e.g.: ``` struct Foo<T, U> { t: T, u: U } <-><----> <------------> / | \ ident generics variant_data ``` r? `@fee1-dead`
2025-05-29Rollup merge of #141638 - oli-obk:builtin-index, r=lcnrJacob Pratt-8/+5
Use `builtin_index` instead of hand-rolling it Just using the dedicated method more
2025-05-28Stabilise `repr128`beetrees-101/+94
2025-05-28Use `builin_index` instead of hand-rolling itOli Scherer-8/+5
2025-05-28Reorder `ast::ItemKind::{Struct,Enum,Union}` fields.Nicholas Nethercote-6/+6
So they match the order of the parts in the source code, e.g.: ``` struct Foo<T, U> { t: T, u: U } <-><----> <------------> / | \ ident generics variant_data ```
2025-05-27Rename unpack to kindMichael Goulet-32/+32
2025-05-27Reduce `P<T>` to a typedef of `Box<T>`.Nicholas Nethercote-1/+1
Keep the `P` constructor function for now, to minimize immediate churn. All the `into_inner` calls are removed, which is nice.
2025-05-27Rollup merge of #141433 - compiler-errors:unsafe-binder-captures, r=oli-obk许杰友 Jieyou Xu (Joe)-0/+2
Properly analyze captures from unsafe binders We need to represent the unsafe binder unwrap as an adjustment in HIR. Pretty straightforward b/c we already represent it as a projection elem in MIR. Fixes #141418 Fixes #141417 r? oli-obk
2025-05-26remove eq_unspanned from TokenStreamyukang-1/+3
2025-05-23Rollup merge of #141376 - nnethercote:rename-kw-Empty, r=petrochenkovMatthias Krüger-4/+4
Rename `kw::Empty` as `sym::empty`. Because the empty string is not a keyword. r? `@petrochenkov`
2025-05-23Properly analyze captures from unsafe bindersMichael Goulet-0/+2
2025-05-22Rollup merge of #141130 - mejrs:use_self, r=compiler-errorsMatthias Krüger-1/+1
rustc_on_unimplemented cleanups Addresses some of the fixmes from https://github.com/rust-lang/rust/pull/139091 and https://github.com/rust-lang/rust/pull/140307. - switch from `_Self` to `Self` in library - properly validate that arguments in the `on` filter and the format strings are actually valid See https://github.com/rust-lang/rustc-dev-guide/pull/2357 for the relevant documentation.