about summary refs log tree commit diff
path: root/src/tools/clippy/tests
AgeCommit message (Collapse)AuthorLines
2025-07-22Rollup merge of #144027 - RalfJung:clippy, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-39/+62
clippy: make tests work in stage 1 This finally fixes https://github.com/rust-lang/rust/issues/78717 :) Similar to what Miri already does, the clippy test step needs to carefully consider which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using `cargo-miri` for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but https://github.com/rust-lang/cargo/issues/4423 makes this quite hard to do. See the long comment in `src/tools/clippy/tests/compile-test.rs` for details. Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense. Cc ```@flip1995``` ```@Kobzol```
2025-07-20clippy: make tests work in stage 1Ralf Jung-39/+62
2025-07-17Auto merge of #143879 - fee1-dead-contrib:push-lrlpoouyqqry, r=fmeasebors-16/+10
parse `const trait Trait` r? oli-obk or anyone from project-const-traits cc `@rust-lang/project-const-traits`
2025-07-17parse `const trait Trait`Deadbeef-16/+10
2025-07-17Rollup merge of #143914 - shepmaster:mismatched-lifetime-syntaxes-rewording, ↵Matthias Krüger-6/+7
r=traviscross,jieyouxu Reword mismatched-lifetime-syntaxes text based on feedback Key changes include: - Removal of the word "syntax" from the lint message. More accurately, it could have been something like "syntax group" or "syntax category", but avoiding it completely is easier. - The primary lint message now reflects exactly which mismatch is occurring, instead of trying to be general. A new `help` line is general across the mismatch kinds. - Suggestions have been reduced to be more minimal, no longer also changing non-idiomatic but unrelated aspects. - Suggestion text no longer mentions changes when those changes don't occur in that specific suggestion. r? ``@jieyouxu``
2025-07-14Auto merge of #143745 - flip1995:clippy-subtree-update, r=Manishearthbors-128/+1810
Clippy subtree update r? `@Manishearth` Cargo.lock update due to `ui_test` bump and restructure.
2025-07-14Reword mismatched-lifetime-syntaxes text based on feedbackJake Goulding-6/+7
Key changes include: - Removal of the word "syntax" from the lint message. More accurately, it could have been something like "syntax group" or "syntax category", but avoiding it completely is easier. - The primary lint message now reflects exactly which mismatch is occurring, instead of trying to be general. A new `help` line is general across the mismatch kinds. - Suggestions have been reduced to be more minimal, no longer also changing non-idiomatic but unrelated aspects. - Suggestion text no longer mentions changes when those changes don't occur in that specific suggestion.
2025-07-13Auto merge of #143357 - cjgillot:no-assoc-item-kind, r=compiler-errorsbors-43/+36
Retire hir::*ItemRef. This information was kept for various places that iterate on HIR to know about trait-items and impl-items. This PR replaces them by uses of the `associated_items` query that contain pretty much the same information. This shortens many spans to just `def_span`, which can be easier to read.
2025-07-13Retire hir::*ItemRef.Camille GILLOT-35/+28
2025-07-13Remove hir::AssocItemKind.Camille GILLOT-8/+8
2025-07-13Rollup merge of #143825 - RalfJung:clippy-test-filter, r=llogiqMatthias Krüger-1/+10
clippy: fix test filtering when TESTNAME is empty Fixes https://github.com/rust-lang/rust/issues/143824. Turns out bootstrap was just fine, the TESTNAME logic in clippy was wrong... I still made this a rustc PR as that's where I did all the debugging. The bootstrap change is not really related, but it's comment-only so not worth a separate PR... adding the `test_args` is also part of what `prepare_cargo_test` would usually do so let's group the code properly.
2025-07-13Auto merge of #143213 - dianne:lower-cond-tweaks, r=cjgillotbors-4/+2
de-duplicate condition scoping logic between AST→HIR lowering and `ScopeTree` construction There was some overlap between `rustc_ast_lowering::LoweringContext::lower_cond` and `rustc_hir_analysis::check::region::resolve_expr`, so I've removed the former and migrated its logic to the latter, with some simplifications. Consequences: - For `while` and `if` expressions' `let`-chains, this changes the `HirId`s for the `&&`s to properly correspond to their AST nodes. This is how guards were handled already. - This makes match guards share previously-duplicated logic with `if`/`while` expressions. This will also be used by guard pattern[^1] guards. - Aside from legacy syntax extensions (e.g. some builtin macros) that directly feed AST to the compiler, it's currently impossible to put attributes directly on `&&` operators in `let` chains[^2]. Nonetheless, attributes on `&&` operators in `let` chains in `if`/`while` expression conditions are no longer silently ignored and will be lowered. - This no longer wraps conditions in `DropTemps`, so the HIR and THIR will be slightly smaller. - `DesugaringKind::CondTemporary` is now gone. It's no longer applied to any spans, and all uses of it were dead since they were made to account for `if` and `while` being desugared to `match` on a boolean scrutinee. - Should be a marginal perf improvement beyond that due to leveraging [`ScopeTree` construction](https://github.com/rust-lang/rust/blob/5e749eb66f93ee998145399fbdde337e57cd72ef/compiler/rustc_hir_analysis/src/check/region.rs#L312-L355)'s clever handling of `&&` and `||`: - This removes some unnecessary terminating scopes that were placed around top-level `&&` and `||` operators in conditions. When lowered to MIR, logical operator chains don't create intermediate boolean temporaries, so there's no temporary to drop. The linked snippet handles wrapping the operands in terminating scopes as necessary, in case they create temporaries. - The linked snippet takes care of letting `let` temporaries live and terminating other operands, so we don't need separate traversals of `&&` chains for that. [^1]: rust-lang/rust#129967 [^2]: Case-by-case, here's my justification: `#[attr] e1 && e2` applies the attribute to `e1`. In `#[attr] (e1 && e2)` , the attribute is on the parentheses in the AST, plus it'd fail to parse if `e1` or `e2` contains a `let`. In `#[attr] expands_to_let_chain!()`, the attribute would already be ignored (rust-lang/rust#63221) and it'd fail to parse anyway; even if the expansion site is a condition, the expansion wouldn't be parsed with `Restrictions::ALLOW_LET`. If it *was* allowed, the notion of a "reparse context" from https://github.com/rust-lang/rust/issues/61733#issuecomment-509626449 would be necessary in order to make `let`-chains left-associative; multiple places in the compiler assume they are.
2025-07-12clippy: fix test filtering when TESTNAME is emptyRalf Jung-1/+10
2025-07-10Merge commit 'cdbbf3afda0b1bf51568b368f629b1d828507f98' into ↵Philipp Krones-128/+1810
clippy-subtree-update
2025-07-05clippy: conditions are no longer wrapped in `DropTemps`dianne-4/+2
2025-07-03refactor: Make -Ztrack-diagnostics emit like a noteScott Schafer-3/+5
2025-07-02Add `track_caller` attributes to trace origin of Clippy lintsSamuel Tardieu-0/+51
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-07-01Update clippy source code to make use of `TyCtxt::def_descr` instead of ↵Guillaume Gomez-4/+4
`ItemKind::descr`
2025-06-27Auto merge of #143116 - matthiaskrgr:rollup-zy9ez06, r=matthiaskrgrbors-8/+8
Rollup of 9 pull requests Successful merges: - rust-lang/rust#139858 (New const traits syntax) - rust-lang/rust#140809 (Reduce special casing for the panic runtime) - rust-lang/rust#142730 (suggest declaring modules when file found but module not defined) - rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver) - rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell) - rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology) - rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv) - rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`) - rust-lang/rust#143106 (gce: don't ICE on non-local const) Failed merges: - rust-lang/rust#143036 (Remove support for `dyn*` from the compiler) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-27Merge commit 'c5dbd1de07e0407b9687619a868384d6de06253f' into ↵Philipp Krones-135/+1638
clippy-subtree-update
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-8/+8
2025-06-19Auto merge of #140748 - m-ou-se:super-format-args3, r=jdonszelmannbors-52/+47
Allow storing `format_args!()` in variable Fixes https://github.com/rust-lang/rust/issues/92698 Tracking issue for super let: https://github.com/rust-lang/rust/issues/139076 Tracking issue for format_args: https://github.com/rust-lang/rust/issues/99012 This change allows: ```rust let name = "world"; let f = format_args!("hello {name}!"); // New: Store format_args!() for later! println!("{f}"); ``` This will need an FCP. This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging https://github.com/rust-lang/rust/pull/139114.) (This is a second version of https://github.com/rust-lang/rust/pull/139135)
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-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-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-13Merge commit '4ef75291b5dd6739212f1f61666d19d4e086690d' into ↵Philipp Krones-256/+2911
clippy-subtree-update
2025-06-13Unimplement unsized_localsmejrs-11/+5
2025-06-11stabilize gaiBoxy-11/+10
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-04Replace `elided_named_lifetimes` with `mismatched_lifetime_syntaxes`Jake Goulding-45/+54
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-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-202/+1274
Clippy subtree update r? `@Manishearth`
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-202/+1274
2025-05-28Stabilise `repr128`beetrees-101/+94
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.
2025-05-21Merge commit 'cadf98bb7d783e2ea3572446c3f80d3592ec5f86' into ↵Philipp Krones-2621/+3023
clippy-subtree-update
2025-05-17do away with `_Self` and `TraitName` and check generic params for ↵mejrs-1/+1
rustc_on_unimplemented
2025-05-16Updated feature flag and output of `clippy/tests/ui/map_flatten*`Ryan van Polen-12/+10
2025-05-15Merge commit '0450db33a5d8587f7c1d4b6d233dac963605766b' into ↵Philipp Krones-1555/+2043
clippy-subtree-update
2025-05-06Rollup merge of #139773 - thaliaarchi:vec-into-iter-last, r=workingjubileeStuart Cook-7/+46
Implement `Iterator::last` for `vec::IntoIter` Avoid iterating everything when we have random access to the last element.
2025-05-06Auto merge of #131160 - ↵bors-30/+30
ismailarilik:handle-potential-query-instability-lint-for-rustc-middle, r=oli-obk Handle `rustc_middle` cases of `rustc::potential_query_instability` lint This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_middle/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/lib.rs#L29) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors. A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447 r? `@compiler-errors`
2025-05-05Handle rustc_middle cases of rustc::potential_query_instability lintismailarilik-30/+30
2025-05-02Implement Iterator::last for vec::IntoIterThalia Archibald-7/+46
2025-05-01Merge commit '03a5b6b976ac121f4233775c49a4bce026065b47' into ↵Philipp Krones-195/+1243
clippy-subtree-update
2025-04-26Fix error message for static references or mutable referencesyuk1ty-1/+1
2025-04-24Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etcbendn-66/+79