about summary refs log tree commit diff
path: root/src/tools/clippy/tests
AgeCommit message (Collapse)AuthorLines
2025-09-27Auto merge of #146636 - Mark-Simulacrum:bootstrap-bump, r=jieyouxubors-1/+0
Bump bootstrap compiler to 1.91 beta https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday
2025-09-26Apply cfg(bootstrap) replacementMark Rousskov-1/+0
2025-09-26Rollup merge of #145113 - petrochenkov:lessfinalize, r=lcnrMatthias Krüger-2/+2
resolve: Do not finalize shadowed bindings I.e. do not mark them as used, or non-speculatively loaded, or similar. Previously they were sometimes finalized during early resolution, causing issues like https://github.com/rust-lang/rust/pull/144793#issuecomment-3168108005.
2025-09-26Auto merge of #145882 - m-ou-se:format-args-extend-1-arg, r=petrochenkovbors-22/+38
Extended temporary argument to format_args!() in all cases Fixes https://github.com/rust-lang/rust/issues/145880 by removing the special case.
2025-09-25resolve: Do not finalize shadowed bindingsVadim Petrochenkov-2/+2
I.e. do not mark them as used, or non-speculative loaded, or similar. Previously they were sometimes finalized during early resolution, causing issues like https://github.com/rust-lang/rust/pull/144793#issuecomment-3168108005.
2025-09-18Merge commit '20ce69b9a63bcd2756cd906fe0964d1e901e042a' into ↵Philipp Krones-639/+2077
clippy-subtree-update
2025-09-11Revert "Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov"Jieyou Xu-10/+3
This reverts commit 1eeb8e8b151d1da7daa73837a25dc5f7a1a7fa28, reversing changes made to 324bf2b9fd8bf9661e7045c8a93f5ff0ec1a8ca5. Unfortunately the assert desugaring change is not backwards compatible, see RUST-145770. Code such as ```rust #[derive(Debug)] struct F { data: bool } impl std::ops::Not for F { type Output = bool; fn not(self) -> Self::Output { !self.data } } fn main() { let f = F { data: true }; assert!(f); } ``` would be broken by the assert desugaring change. We may need to land the change over an edition boundary, or limit the editions that the desugaring change impacts.
2025-09-05Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=petrochenkovbors-8/+4
fix: Filter suggestion parts that match existing code While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in rust-lang/rust#145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information. Before rust-lang/rust#145273 (`Diff` style) ![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46) After rust-lang/rust#145273 ("multi-line" style) ![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0) The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be. To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out. try-job: aarch64-apple
2025-09-04fix: Filter suggestion parts that match existing codeScott Schafer-8/+4
2025-09-04Merge commit 'e9b70454e4c9584be3b22ddabd26b741aeb06c10' into ↵Philipp Krones-642/+3048
clippy-subtree-update
2025-08-29Rollup merge of #145756 - okaneco:stabilize_char_boundary, r=scottmcmTrevor Gross-16/+14
str: Stabilize `round_char_boundary` feature Closes https://github.com/rust-lang/rust/issues/93743 FCP completed https://github.com/rust-lang/rust/issues/93743#issuecomment-3168382171
2025-08-26Bless clippy tests.Mara Bos-22/+38
2025-08-23Rollup merge of #145798 - compiler-errors:unnamed-lt-primary, r=lqdJacob Pratt-2/+2
Use unnamed lifetime spans as primary spans for `MISMATCHED_LIFETIME_SYNTAXES` Fixes https://github.com/rust-lang/rust/issues/145772 This PR changes the primary span(s) of the `MISMATCHED_LIFETIME_SYNTAXES` to point to the *unnamed* lifetime spans in both the inputs and *outputs* of the function signature. As reported in rust-lang/rust#145772, this should make it so that IDEs highlight the spans of the actionable part of this lint, rather than just the (possibly named) input spans like they do today. This could be tweaked further perhaps, for example for `fn foo(_: T<'_>) -> T`, we don't need to highlight the elided lifetime if the actionable part is to change only the return type to `T<'_>`, but I think it's improvement on what's here today, so I think that should be follow-up since I think the logic might get a bit hairy. cc ```@shepmaster```
2025-08-23Use unnamed lifetime spans as primary spans for MISMATCHED_LIFETIME_SYNTAXESMichael Goulet-2/+2
2025-08-24Adjust clippy lints for rustc `integer_to_ptr_transmutes` lintUrgau-56/+31
2025-08-22Stabilize `round_char_boundary` featureokaneco-16/+14
2025-08-22Merge commit '877967959ae8da9814df4f2614971f4d784bf53f' into ↵Philipp Krones-316/+998
clippy-subtree-update
2025-08-19bless tests with new lint messagesKarol Zwolak-1/+1
2025-08-15Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkovStuart Cook-3/+10
Change the desugaring of `assert!` for better error output In the desugaring of `assert!`, we now expand to a `match` expression instead of `if !cond {..}`. The span of incorrect conditions will point only at the expression, and not the whole `assert!` invocation. ``` error[E0308]: mismatched types --> $DIR/issue-14091.rs:2:13 | LL | assert!(1,1); | ^ expected `bool`, found integer ``` We no longer mention the expression needing to implement the `Not` trait. ``` error[E0308]: mismatched types --> $DIR/issue-14091-2.rs:15:13 | LL | assert!(x, x); | ^ expected `bool`, found `BytePos` ``` Now `assert!(val)` desugars to: ```rust match val { true => {}, _ => $crate::panic::panic_2021!(), } ``` Fix #122159.
2025-08-13Update clippy testsVadim Petrochenkov-2/+22
2025-08-13Rollup merge of #144870 - Kivooeo:file_prefix-stabilize, r=tgross35Jakub Beránek-1/+1
Stabilize `path_file_prefix` feature This stabilises `Path::file_prefix`, following the FCP in [tracking issue ](https://github.com/rust-lang/rust/issues/86319) (FCP ended almost a year ago, so if it's needed for proccess we could rerun it) Closes: https://github.com/rust-lang/rust/issues/86319
2025-08-12Change the desugaring of `assert!` for better error outputEsteban Küber-3/+10
In the desugaring of `assert!`, we now expand to a `match` expression instead of `if !cond {..}`. The span of incorrect conditions will point only at the expression, and not the whole `assert!` invocation. ``` error[E0308]: mismatched types --> $DIR/issue-14091.rs:2:13 | LL | assert!(1,1); | ^ expected `bool`, found integer ``` We no longer mention the expression needing to implement the `Not` trait. ``` error[E0308]: mismatched types --> $DIR/issue-14091-2.rs:15:13 | LL | assert!(x, x); | ^ expected `bool`, found `BytePos` ``` `assert!(val)` now desugars to: ```rust match val { true => {}, _ => $crate::panic::panic_2021!(), } ``` Fix #122159. We make some minor changes to some diagnostics to avoid span overlap on type mismatch or inverted "expected"/"found" on type errors. We remove some unnecessary parens from core, alloc and miri. address review comments
2025-08-12Rollup merge of #145273 - estebank:not-not, r=samueltardieuStuart Cook-46/+130
Account for new `assert!` desugaring in `!condition` suggestion `rustc` in https://github.com/rust-lang/rust/pull/122661 is going to change the desugaring of `assert!` to be ```rust match condition { true => {} _ => panic!(), } ``` which will make the edge-case of `condition` being `impl Not<Output = bool>` while not being `bool` itself no longer a straightforward suggestion, but `!!condition` will coerce the expression to be `bool`, so it can be machine applicable. Transposing https://github.com/rust-lang/rust-clippy/pull/15453/ to the rustc repo. r? `````@samueltardieu`````
2025-08-11Account for new `assert!` desugaring in `!condition` suggestionEsteban Küber-46/+130
`rustc` is going to change the desugaring of `assert!` to be ```rust match condition { true => {} _ => panic!(), } ``` which will make the edge-case of `condition` being `impl Not<Output = bool>` while not being `bool` itself no longer a straightforward suggestion, but `!!condition` will coerce the expression to be `bool`, so it can be machine applicable.
2025-08-11fix clippy testEsteban Küber-0/+2
2025-08-07Merge commit '334fb906aef13d20050987b13448f37391bb97a2' into ↵Philipp Krones-312/+1364
clippy-subtree-update
2025-08-04remove gateKivooeo-1/+1
2025-07-31Extend `is_case_difference` to handle digit-letter confusablesxizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-25Merge commit '1db89a1b1ca87f24bf22d0bad21d14b2d81b3e99' into ↵Philipp Krones-268/+2407
clippy-subtree-update
2025-07-24Rollup merge of #144014 - dianne:edition-guide-links, r=estebankLeón Orell Valerian Liehr-1/+1
don't link to the nightly version of the Edition Guide in stable lints As reported in rust-lang/rust#143557 for `rust_2024_incompatible_pat`, most future-Edition-incompatibility lints link to the nightly version of the Edition Guide; the lints were written before their respective Editions (and their guides) stabilized. But now that Rusts 2021 and 2024 are stable, these lints are emitted on stable versions of the compiler, where it makes more sense to present users with links that don't say "nightly" in them. This does not change the link for `rust_2024_incompatible_pat`. That's handled in rust-lang/rust#144006.
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-16future-incompat lints: don't link to the nightly edition-guide versiondianne-1/+1
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