summary refs log tree commit diff
path: root/src/tools/clippy/clippy_utils
AgeCommit message (Collapse)AuthorLines
2025-02-06Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-1/+1
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca. (cherry picked from commit ca1c17c88d1f625763859396ba7a50f36ac45cc0)
2024-12-26Merge commit '609cd310be44677ae31d452a17b0f8207e1abfe1' into ↵Philipp Krones-72/+41
clippy-subtree-update
2024-12-24Auto merge of #134625 - compiler-errors:unsafe-binders-ty, r=oli-obkbors-1/+3
Begin to implement type system layer of unsafe binders Mostly TODOs, but there's a lot of match arms that are basically just noops so I wanted to split these out before I put up the MIR lowering/projection part of this logic. r? oli-obk Tracking: - https://github.com/rust-lang/rust/issues/130516
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-1/+3
2024-12-22Update clippyScott McMurray-1/+1
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-6/+6
2024-12-16split attributesJonathan Dönszelmann-1/+1
2024-12-15Add hir::AttributeJonathan Dönszelmann-54/+54
2024-12-15Rename `value` field to `expr` to simplify later commits' diffsOli Scherer-2/+2
2024-12-15Rollup merge of #134285 - oli-obk:push-vwrqsqlwnuxo, r=UrgauStuart Cook-8/+8
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-14Add some convenience helper methods on `hir::Safety`Oli Scherer-8/+8
2024-12-14(Re-)Implement impl_trait_in_bindingsMichael Goulet-1/+2
2024-12-13Rollup merge of #134140 - compiler-errors:unsafe-binders-ast, r=oli-obkMatthias Krüger-3/+22
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-1/+1
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-12Fix toolsMichael Goulet-3/+22
2024-12-10Remove more traces of anonymous ADTsMichael Goulet-3/+1
2024-12-10Keep track of parse errors in `mod`s and don't emit resolve errors for paths ↵Esteban Küber-1/+1
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. 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 `mod` expansion. Fix #97734.
2024-12-09Introduce `default_field_values` featureEsteban Küber-7/+12
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. Support default fields in enum struct variant Allow default values in an enum struct variant definition: ```rust pub enum Bar { Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Allow using `..` without a base on an enum struct variant ```rust Bar::Foo { .. } ``` `#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants. Support `#[derive(Default)]` on enum struct variants with all defaulted fields ```rust pub enum Bar { #[default] Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Check for missing fields in typeck instead of mir_build. Expand test with `const` param case (needs `generic_const_exprs` enabled). Properly instantiate MIR const The following works: ```rust struct S<A> { a: Vec<A> = Vec::new(), } S::<i32> { .. } ``` Add lint for default fields that will always fail const-eval We *allow* this to happen for API writers that might want to rely on users' getting a compile error when using the default field, different to the error that they would get when the field isn't default. We could change this to *always* error instead of being a lint, if we wanted. This will *not* catch errors for partially evaluated consts, like when the expression relies on a const parameter. Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`: - Suggest adding a base expression if there are missing fields. - Suggest enabling the feature if all the missing fields have optional values. - Suggest removing `..` if there are no missing fields.
2024-12-02Rollup merge of #133746 - oli-obk:push-xwyrylxmrtvq, r=jieyouxuGuillaume Gomez-2/+2
Change `AttrArgs::Eq` to a struct variant Cleanups for simplifying https://github.com/rust-lang/rust/pull/131808 Basically changes `AttrArgs::Eq` to a struct variant and then avoids several matches on `AttrArgsEq` in favor of methods on it. This will make future refactorings simpler, as they can either keep methods or switch to field accesses without having to restructure code
2024-12-02Rollup merge of #133751 - lcnr:no-trait-solving-on-type, r=compiler-errorsGuillaume Gomez-1/+1
remove `Ty::is_copy_modulo_regions` Using these functions is likely incorrect if an `InferCtxt` is available, I moved this function to `TyCtxt` (and added it to `LateContext`) and added a note to the documentation that one should prefer `Infer::type_is_copy_modulo_regions` instead. I didn't yet move `is_sized` and `is_freeze`, though I think we should move these as well. r? `@compiler-errors` cc #132279
2024-12-02remove `Ty::is_copy_modulo_regions`lcnr-1/+1
2024-12-02Change `AttrArgs::Eq` into a struct variantOli Scherer-2/+2
2024-12-01Rollup merge of #133589 - voidc:remove-array-len, r=boxyuwuJacob Pratt-24/+12
Remove `hir::ArrayLen` This refactoring removes `hir::ArrayLen`, replacing it with `hir::ConstArg`. To represent inferred array lengths (previously `hir::ArrayLen::Infer`), a new variant `ConstArgKind::Infer` is added. r? `@BoxyUwU`
2024-11-30Remove hir::ArrayLen, introduce ConstArgKind::InferDominik Stolz-24/+12
Remove Node::ArrayLenInfer
2024-11-29Auto merge of #133588 - flip1995:clippy-subtree-update, r=Manishearthbors-48/+274
Clippy subtree update r? `@Manishearth`
2024-11-29Stop using `HybridBitSet` in clippy.Nicholas Nethercote-10/+10
The compiler uses `BitSet<Local>`, because the number of locals doesn't get that high, so clippy should do likewise.
2024-11-28Merge commit 'ff4a26d442bead94a4c96fb1de967374bc4fbd8e' into ↵Philipp Krones-48/+274
clippy-subtree-update
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-2/+2
2024-11-24Rollup merge of #133371 - RalfJung:is_trivially_const_drop, r=compiler-errorsMatthias Krüger-4/+3
remove is_trivially_const_drop I'm not sure this still brings any perf benefits, so let's benchmark this. r? `@compiler-errors`
2024-11-23no more Reveal :(lcnr-1/+1
2024-11-23remove is_trivially_const_dropRalf Jung-4/+3
2024-11-20reduce false positives of tail-expr-drop-order from consumed valuesDing Xiang Fei-0/+1
take 2 open up coroutines tweak the wordings the lint works up until 2021 We were missing one case, for ADTs, which was causing `Result` to yield incorrect results. only include field spans with significant types deduplicate and eliminate field spans switch to emit spans to impl Drops Co-authored-by: Niko Matsakis <nikomat@amazon.com> collect drops instead of taking liveness diff apply some suggestions and add explantory notes small fix on the cache let the query recurse through coroutine new suggestion format with extracted variable name fine-tune the drop span and messages bugfix on runtime borrows tweak message wording filter out ecosystem types earlier apply suggestions clippy check lint level at session level further restrict applicability of the lint translate bid into nop for stable mir detect cycle in type structure
2024-11-19remove `TypingMode::from_param_env` in clippylcnr-47/+44
2024-11-19move `fn is_item_raw` to `TypingEnv`lcnr-1/+1
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-23/+26
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-14Merge commit '786fbd6d683933cd0e567fdcd25d449a69b4320c' into ↵Philipp Krones-37/+34
clippy-subtree-update
2024-11-10ensure that all publicly reachable const fn have const stability infoRalf Jung-6/+2
2024-11-08Clippy: cfg out validate_diag on release buildsPhilipp Krones-3/+4
2024-11-07Merge commit 'f712eb5cdccd121d0569af12f20e6a0fabe4364d' into ↵Philipp Krones-108/+168
clippy-subtree-update
2024-11-05Auto merge of #132580 - compiler-errors:globs, r=Noratriebbors-5/+5
Remove unnecessary pub enum glob-imports from `rustc_middle::ty` We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly. `@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`. This PR is a bit large, but it's just naming. The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine. r? `@noratrieb` or reassign
2024-11-04Move two attribute lints to be early pass (post expansion)Jonathan Dönszelmann-2/+3
2024-11-04Remove BorrowKind glob, make names longerMichael Goulet-3/+3
2024-11-04ty::KContainer -> ty::AssocItemContainer::KMichael Goulet-2/+2
2024-11-03Rename the FIXMEs, remove a few that dont matter anymoreMichael Goulet-2/+2
2024-10-31stop using `ParamEnv::reveal` while handling MIRlcnr-1/+1
2024-10-31clippy: we've got a `LateContext` use it for `TypingMode`lcnr-1/+1
2024-10-31`ConstCx` stop using `ParamEnv::reveal`lcnr-2/+2
2024-10-30Remap impl-trait lifetimes on HIR instead of AST lowering.Camille GILLOT-4/+1
2024-10-30Rollup merge of #132338 - nnethercote:rm-Engine, r=nnethercoteMatthias Krüger-3/+1
Remove `Engine` It's just unnecessary plumbing. Removing it results in less code, and simpler code. r? ``@cjgillot``
2024-10-30Remove `Analysis::into_engine`.Nicholas Nethercote-3/+1
This is a standard pattern: ``` MyAnalysis.into_engine(tcx, body).iterate_to_fixpoint() ``` `into_engine` and `iterate_to_fixpoint` are always called in pairs, but sometimes with a builder-style `pass_name` call between them. But a builder-style interface is overkill here. This has been bugging me a for a while. This commit: - Merges `Engine::new` and `Engine::iterate_to_fixpoint`. This removes the need for `Engine` to have fields, leaving it as a trivial type that the next commit will remove. - Renames `Analysis::into_engine` as `Analysis::iterate_to_fixpoint`, gives it an extra argument for the optional pass name, and makes it call `Engine::iterate_to_fixpoint` instead of `Engine::new`. This turns the pattern from above into this: ``` MyAnalysis.iterate_to_fixpoint(tcx, body, None) ``` which is shorter at every call site, and there's less plumbing required to support it.