summary refs log tree commit diff
path: root/src/tools/clippy/clippy_lints
AgeCommit message (Collapse)AuthorLines
2025-02-13Auto merge of #136593 - lukas-code:ty-value-perf, r=oli-obkbors-3/+4
valtree performance tuning Summary: This PR makes type checking of code with many type-level constants faster. After https://github.com/rust-lang/rust/pull/136180 was merged, we observed a small perf regression (https://github.com/rust-lang/rust/pull/136318#issuecomment-2635562821). This happened because that PR introduced additional copies in the fast reject code path for consts, which is very hot for certain crates: https://github.com/rust-lang/rust/blob/6c1d960d88dd3755548b3818630acb63fa98187e/compiler/rustc_type_ir/src/fast_reject.rs#L486-L487 This PR improves the performance again by properly interning the valtrees so that copying and comparing them becomes faster. This will become especially useful with `feature(adt_const_params)`, so the fast reject code doesn't have to do a deep compare of the valtrees. Note that we can't just compare the interned consts themselves in the fast reject, because sometimes `'static` lifetimes in the type are be replaced with inference variables (due to canonicalization) on one side but not the other. A less invasive alternative that I considered is simply avoiding copies introduced by https://github.com/rust-lang/rust/pull/136180 and comparing the valtrees it in-place (see commit: https://github.com/rust-lang/rust/commit/9e91e50ac5920f0b9b4a3b1e0880c85336ba5c64 / perf results: https://github.com/rust-lang/rust/pull/136593#issuecomment-2642303245), however that was still measurably slower than interning. There are some minor regressions in secondary benchmarks: These happen due to changes in memory allocations and seem acceptable to me. The crates that make heavy use of valtrees show no significant changes in memory usage.
2025-02-13intern valtreesLukas Markeffsky-3/+4
2025-02-10Convert two missed placesBastian Kersting-2/+2
2025-02-10Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptrBastian Kersting-7/+7
The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424.
2025-02-08Rollup merge of #136706 - workingjubilee:finish-up-rustc-abi-updates, ↵Jubilee-34/+36
r=compiler-errors compiler: mostly-finish `rustc_abi` updates This almost-finishes all the updates in the compiler to use `rustc_abi` and removes some of the reexports of `rustc_abi` items in `rustc_target` that were previously available. r? ```@compiler-errors```
2025-02-07clippy: directly use rustc_abi instead of reexportsJubilee Young-34/+36
2025-02-07fix typoJana Dönszelmann-1/+1
2025-02-07fix empty after lint on impl/trait itemsJonathan Dönszelmann-37/+76
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-02-07Update UI testsGuillaume Gomez-1/+1
2025-02-07Convert `EMPTY_LINE_AFTER_OUTER_ATTR` and `EMPTY_LINE_AFTER_OUTER_ATTR` lint ↵Guillaume Gomez-427/+458
into early lints
2025-02-06Rollup merge of #136645 - flip1995:clippy-subtree-update, r=ManishearthMatthias Krüger-213/+924
Clippy subtree update r? `@Manishearth`
2025-02-06Auto merge of #136641 - matthiaskrgr:rollup-lajwje5, r=matthiaskrgrbors-21/+17
Rollup of 7 pull requests Successful merges: - #136073 (Always compute coroutine layout for eagerly emitting recursive layout errors) - #136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - #136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - #136315 (Use short ty string for binop and unop errors) - #136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - #136435 (Simplify some code for lowering THIR patterns) - #136630 (Change two std process tests to not output to std{out,err}, and fix test suite stat reset in bootstrap CI test rendering) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-gnu-debug
2025-02-06Merge commit '3e3715c31236bff56f1c63a1de2c7bbdfcfb0923' into ↵Philipp Krones-213/+924
clippy-subtree-update
2025-02-05Uniformly handle HIR literals in visitors and lintsOli Scherer-21/+17
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-14/+13
2025-02-02Rollup merge of #136422 - nnethercote:convert-lint-functions, r=NoratriebMatthias Krüger-216/+125
Convert two `rustc_middle::lint` functions to `Span` methods. `rustc_middle` is a huge crate and it's always good to move stuff out of it. There are lots of similar methods already on `Span`, so these two functions, `in_external_macro` and `is_from_async_await`, fit right in. The diff is big because `in_external_macro` is used a lot by clippy lints. r? ``@Noratrieb``
2025-02-02Convert two `rustc_middle::lint` functions to `Span` methods.Nicholas Nethercote-216/+125
`rustc_middle` is a huge crate and it's always good to move stuff out of it. There are lots of similar methods already on `Span`, so these two functions, `in_external_macro` and `is_from_async_await`, fit right in. The diff is big because `in_external_macro` is used a lot by clippy lints.
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.