about summary refs log tree commit diff
path: root/src/tools/clippy/clippy_lints
AgeCommit message (Collapse)AuthorLines
2025-02-01Rename `tcx.ensure()` to `tcx.ensure_ok()`Zalathar-1/+1
2025-01-30introduce `ty::Value`Lukas Markeffsky-6/+4
Co-authored-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
2025-01-29Eliminate PatKind::PathOli Scherer-51/+114
2025-01-29Rollup merge of #136164 - celinval:chores-fnkind, r=oli-obkLeón Orell Valerian Liehr-2/+2
Refactor FnKind variant to hold &Fn Pulling the change suggested in #128045 to reduce the impact of changing `Fn` item. r? `@oli-obk`
2025-01-29Rollup merge of #135902 - compiler-errors:item-non-self-bound-in-new-solver, ↵León Orell Valerian Liehr-1/+1
r=lcnr Do not consider child bound assumptions for rigid alias r? lcnr See first commit for the important details. For second commit, I also stacked a somewhat opinionated name change, though I can separate that if needed. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/149
2025-01-28Refactor FnKind variant to hold &FnCelina G. Val-2/+2
2025-01-28Make item self/non-self bound naming less whackMichael Goulet-1/+1
2025-01-28Merge commit '51d49c1ae2785b24ef18a46ef233fc1d91844666' into ↵Philipp Krones-326/+1444
clippy-subtree-update
2025-01-27Rollup merge of #126604 - kadiwa4:uplift_double_negation, r=nnethercoteLeón Orell Valerian Liehr-41/+2
Uplift `clippy::double_neg` lint as `double_negations` Warns about cases like this: ```rust fn main() { let x = 1; let _b = --x; //~ WARN use of a double negation } ``` The intent is to keep people from thinking that `--x` is a prefix decrement operator. `++x`, `x++` and `x--` are invalid expressions and already have a helpful diagnostic. I didn't add a machine-applicable suggestion to the lint because it's not entirely clear what the programmer was trying to achieve with the `--x` operation. The code that triggers the lint should always be reviewed manually. Closes #82987
2025-01-26remove `clippy::double_neg`Kalle Wachsmuth-41/+2
2025-01-26Auto merge of #135753 - compiler-errors:from-ty-const, r=oli-obkbors-5/+2
Get rid of `mir::Const::from_ty_const` This function is strange, because it turns valtrees into `mir::Const::Value`, but the rest of the const variants stay as type system consts. All of the callsites except for one in `instsimplify` (array length simplification of `ptr_metadata` call) just go through the valtree arm of the function, so it's easier to just create a `mir::Const` directly for those. For the instsimplify case, if we have a type system const we should *keep* having a type system const, rather than turning it into a `mir::Const::Value`; it doesn't really matter in practice, though, bc `usize` has no padding, but it feels more principled.
2025-01-23make `hir::Ty/ConstArg` methods generic where applicableBoxy-2/+2
2025-01-23`visit_x_unambig`Boxy-11/+11
2025-01-23The clipper :3cBoxy-149/+145
2025-01-23Make `hir::TyKind::TraitObject` use tagged ptrBoxy-3/+3
2025-01-21Move supertrait_def_ids into the elaborate module like all other fnsMichael Goulet-1/+2
2025-01-20Get rid of mir::Const::from_ty_constMichael Goulet-5/+2
2025-01-15Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable, ↵Guillaume Gomez-1/+1
r=davidtwco deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead The `rustc_allowed_through_unstable_modules` attribute lets users call `std::mem::transmute` as `std::intrinsics::transmute`. The former is a reexport of the latter, and for a long time we didn't properly check stability for reexports, so making this a hard error now would be a breaking change for little gain. But at the same time, `std::intrinsics::transmute` is not the intended path for this function, so I think it is a good idea to show a deprecation warning when that path is used. This PR implements that, for all the functions in `std::intrinsics` that carry the attribute. I assume this will need ``@rust-lang/libs-api`` FCP.
2025-01-15allowed_through_unstable_modules: support showing a deprecation message when ↵Ralf Jung-1/+1
the unstable module name is used
2025-01-14Add hir::HeaderSafety to make follow up commits simplerOli Scherer-10/+10
2025-01-11migrate `clippy` to the `DenseBitSet` nameRémy Rakic-2/+2
2025-01-09Merge commit '19e305bb57a7595f2a8d81f521c0dd8bf854e739' into ↵Philipp Krones-218/+542
clippy-subtree-update
2025-01-08Rename PatKind::Lit to ExprOli Scherer-24/+24
2025-01-08Exhaustively handle expressions in patternsOli Scherer-50/+116
2025-01-07Rollup merge of #134989 - max-niederman:guard-patterns-hir, r=oli-obkMatthias Krüger-4/+16
Lower Guard Patterns to HIR. Implements lowering of [guard patterns](https://rust-lang.github.io/rfcs/3637-guard-patterns.html) (see the [tracking issue](#129967)) to HIR.
2025-01-04turn hir::ItemKind::Fn into a named-field variantRalf Jung-22/+46
2024-12-31cover guard patterns in clippy lintsMax Niederman-4/+16
2024-12-26Merge commit '609cd310be44677ae31d452a17b0f8207e1abfe1' into ↵Philipp Krones-402/+1188
clippy-subtree-update
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-1/+2
2024-12-19Auto merge of #133961 - lcnr:borrowck-cleanup, r=jackh726bors-1/+1
cleanup region handling: add `LateParamRegionKind` The second commit is to enable a split between `BoundRegionKind` and `LateParamRegionKind`, by avoiding `BoundRegionKind` where it isn't necessary. The third comment then adds `LateParamRegionKind` to avoid having the same late-param region for separate bound regions. This fixes #124021. r? `@compiler-errors`
2024-12-18introduce `LateParamRegionKind`lcnr-1/+1
2024-12-18Rollup merge of #134161 - nnethercote:overhaul-token-cursors, r=spastorino许杰友 Jieyou Xu (Joe)-4/+4
Overhaul token cursors Some nice cleanups here. r? `````@davidtwco`````
2024-12-18Rename `RefTokenTreeCursor`.Nicholas Nethercote-4/+4
Because `TokenStreamIter` is a much better name for a `TokenStream` iterator. Also rename the `TokenStream::trees` method as `TokenStream::iter`, and some local variables.
2024-12-18Simplify `RefTokenTreeCursor::look_ahead`.Nicholas Nethercote-1/+1
It's only ever used with a lookahead of 0, so this commit removes the lookahead and renames it `peek`.
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-7/+9
2024-12-15Add hir::AttributeJonathan Dönszelmann-41/+36
2024-12-15Rename `value` field to `expr` to simplify later commits' diffsOli Scherer-3/+3
2024-12-15Rollup merge of #134285 - oli-obk:push-vwrqsqlwnuxo, r=UrgauStuart Cook-17/+17
Add some convenience helper methods on `hir::Safety` Makes a lot of call sites simpler and should make any refactorings needed for https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 simpler, as fewer sites have to be touched in case we end up storing some information in the variants of `hir::Safety`
2024-12-15Auto merge of #134258 - bjorn3:no_public_specialization, r=petrochenkovbors-3/+0
Remove support for specializing ToString outside the standard library This is the only trait specializable outside of the standard library. Before stabilizing specialization we will probably want to remove support for this. It was originally made specializable to allow a more efficient ToString in libproc_macro back when this way the only way to get any data out of a TokenStream. We now support getting individual tokens, so proc macros no longer need to call it as often.
2024-12-14Add some convenience helper methods on `hir::Safety`Oli Scherer-17/+17
2024-12-14Stop handling specialization in clippy's to_string_trait_impl lintbjorn3-3/+0
ToString can no longer be specialized, so no need to account for it in to_string_trait_impl either.
2024-12-14Auto merge of #134185 - compiler-errors:impl-trait-in-bindings, r=oli-obkbors-0/+1
(Re-)Implement `impl_trait_in_bindings` This reimplements the `impl_trait_in_bindings` feature for local bindings. "`impl Trait` in bindings" serve as a form of *trait* ascription, where the type basically functions as an infer var but additionally registering the `impl Trait`'s trait bounds for the infer type. These trait bounds can be used to enforce that predicates hold, and can guide inference (e.g. for closure signature inference): ```rust let _: impl Fn(&u8) -> &u8 = |x| x; ``` They are implemented as an additional set of bounds that are registered when the type is lowered during typeck, and then these bounds are tied to a given `CanonicalUserTypeAscription` for borrowck. We enforce these `CanonicalUserTypeAscription` bounds during borrowck to make sure that the `impl Trait` types are sensitive to lifetimes: ```rust trait Static: 'static {} impl<T> Static for T where T: 'static {} let local = 1; let x: impl Static = &local; //~^ ERROR `local` does not live long enough ``` r? oli-obk cc #63065 --- Why can't we just use TAIT inference or something? Well, TAITs in bodies have the problem that they cannot reference lifetimes local to a body. For example: ```rust type TAIT = impl Display; let local = 0; let x: TAIT = &local; //~^ ERROR `local` does not live long enough ``` That's because TAITs requires us to do *opaque type inference* which is pretty strict, since we need to remap all of the lifetimes of the hidden type to universal regions. This is simply not possible here. --- I consider this part of the "impl trait everywhere" experiment. I'm not certain if this needs yet another lang team experiment.
2024-12-14(Re-)Implement impl_trait_in_bindingsMichael Goulet-0/+1
2024-12-14Rollup merge of #134265 - compiler-errors:ty_def_id, r=oli-obkMatthias Krüger-3/+1
Rename `ty_def_id` so people will stop using it by accident This function is just for cycle detection, but people keep using it because they think it's the right way of getting the def id from a `Ty` (and I can't blame them necessarily).
2024-12-13Auto merge of #134269 - matthiaskrgr:rollup-fkshwux, r=matthiaskrgrbors-3/+8
Rollup of 7 pull requests Successful merges: - #133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N]) - #133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them) - #133938 (`rustc_mir_dataflow` cleanups, including some renamings) - #134058 (interpret: reduce usage of TypingEnv::fully_monomorphized) - #134130 (Stop using driver queries in the public API) - #134140 (Add AST support for unsafe binders) - #134229 (Fix typos in docs on provenance) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-13Rename ty_def_id so people will stop using it by accidentMichael Goulet-3/+1
2024-12-13Rollup merge of #134140 - compiler-errors:unsafe-binders-ast, r=oli-obkMatthias Krüger-1/+6
Add AST support for unsafe binders I'm splitting up #130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later. r? `@oli-obk` cc `@BoxyUwU` and `@lcnr` who also may want to look at this, though this PR doesn't do too much yet
2024-12-13Rollup merge of #133937 - ↵Matthias Krüger-2/+2
estebank:silence-resolve-errors-from-mod-with-parse-errors, r=davidtwco Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them When we expand a `mod foo;` and parse `foo.rs`, we now track whether that file had an unrecovered parse error that reached the end of the file. If so, we keep that information around in the HIR and mark its `DefId` in the `Resolver`. When resolving a path like `foo::bar`, we do not emit any errors for "`bar` not found in `foo`", as we know that the parse error might have caused `bar` to not be parsed and accounted for. When this happens in an existing project, every path referencing `foo` would be an irrelevant compile error. Instead, we now skip emitting anything until `foo.rs` is fixed. Tellingly enough, we didn't have any test for errors caused by expansion of `mod`s with parse errors. Fix https://github.com/rust-lang/rust/issues/97734.
2024-12-13Auto merge of #134122 - oli-obk:push-zqnyznxtpnll, r=petrochenkovbors-1/+42
Move impl constness into impl trait header This PR is kind of the opposite of the rejected https://github.com/rust-lang/rust/pull/134114 Instead of moving more things into the `constness` query, we want to keep them where their corresponding hir nodes are lowered. So I gave this a spin for impls, which have an obvious place to be (the impl trait header). And surprisingly it's also a perf improvement (likely just slightly better query & cache usage). The issue was that removing anything from the `constness` query makes it just return `NotConst`, which is wrong. So I had to change it to `bug!` out if used wrongly, and only then remove the impl blocks from the `constness` query. I think this change is good in general, because it makes using `constness` more robust (as can be seen by how few sites that had to be changed, so it was almost solely used specifically for the purpose of asking for functions' constness). The main thing where this change was not great was in clippy, which was using the `constness` query as a general DefId -> constness map. I added a `DefKind` filter in front of that. If it becomes a more common pattern we can always move that helper into rustc.
2024-12-12Fix toolsMichael Goulet-1/+6