Commit Graph

5166 Commits

Author SHA1 Message Date
lcnr c783d1e387 InterpCx store TypingEnv instead of a ParamEnv 2024-11-19 21:36:23 +01:00
lcnr d8e5f7ad8a remove TypingMode::from_param_env in clippy 2024-11-19 19:31:02 +01:00
lcnr 809b420e16 move fn is_item_raw to TypingEnv 2024-11-19 18:06:20 +01:00
lcnr bb93c23c08 use TypingEnv when no infcx is available
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-18 10:38:56 +01:00
Philipp Krones 1ceaa90413 Merge commit '786fbd6d683933cd0e567fdcd25d449a69b4320c' into clippy-subtree-update 2024-11-14 19:35:26 +01:00
Boxy e5b1caef85 Consolidate type system const evaluation under traits::evaluate_const
mew
2024-11-12 02:54:03 +00:00
Philipp Krones 6ced8c33c0 Merge commit 'f712eb5cdccd121d0569af12f20e6a0fabe4364d' into clippy-subtree-update 2024-11-07 22:37:01 +01:00
Matthias Krüger 4847c40c8b Rollup merge of #132637 - blyxyas:lint-less-passes, r=flip1995
Do not filter empty lint passes & re-do CTFE pass

Some structs implement `LintPass` without having a `Lint` associated with them #125116 broke that behaviour by filtering them out. This PR ensures that lintless passes are not filtered out.
2024-11-05 20:10:53 +01:00
blyxyas 626406f1b3 Do not filter empty passes & Make CTFE Clippy into lintless pass 2024-11-05 15:27:09 +01:00
bors d8a3fcc792 Auto merge of #132580 - compiler-errors:globs, r=Noratrieb
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-05 08:30:56 +00:00
Jonathan Dönszelmann 63d0ba9de9 Move two attribute lints to be early pass (post expansion) 2024-11-04 22:47:22 +01:00
Michael Goulet efeed550c4 Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
Michael Goulet b14362f665 ty::KContainer -> ty::AssocItemContainer::K 2024-11-04 04:45:52 +00:00
bors 9f89421036 Auto merge of #132301 - compiler-errors:adjust, r=lcnr
Remove region from adjustments

It's not necessary to store this region, because it's only used in THIR and MemCat/ExprUse, both of which already basically only deal with erased regions anyways.
2024-10-31 10:17:49 +00:00
Camille GILLOT d9a0fec48a Remap impl-trait lifetimes on HIR instead of AST lowering. 2024-10-30 16:18:50 +00:00
lcnr 8d190cc411 update tools 2024-10-29 17:01:24 +01:00
Michael Goulet 353868aa64 Remove region from adjustments 2024-10-29 01:34:06 +00:00
Pavel Grigorenko f286174690 New lint: dangling_pointers_from_temporaries 2024-10-28 14:16:05 +03:00
bors 9e36f89701 Auto merge of #125116 - blyxyas:ignore-allowed-lints-final, r=cjgillot
(Big performance change) Do not run lints that cannot emit

Before this change, adding a lint was a difficult matter because it always had some overhead involved. This was because all lints would run, no matter their default level, or if the user had `#![allow]`ed them. This PR changes that. This change would improve both the Rust lint infrastructure and Clippy, but Clippy will see the most benefit, as it has about 900 registered lints (and growing!)

So yeah, with this little patch we filter all lints pre-linting, and remove any lint that is either:
- Manually `#![allow]`ed in the whole crate,
- Allowed in the command line, or
- Not manually enabled with `#[warn]` or similar, and its default level is `Allow`

As some lints **need** to run, this PR also adds **loadbearing lints**. On a lint declaration, you can use the ``@eval_always` = true` marker to label it as loadbearing. A loadbearing lint will never be filtered (it will always run)

Fixes #106983
2024-10-26 16:37:43 +00:00
Deadbeef 350d1c4aee Effects cleanup
- removed extra bits from predicates queries that are no longer needed in the new system
- removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
2024-10-26 10:19:07 +08:00
Ralf Jung 54f9bc4884 nightly feature tracking: get rid of the per-feature bool fields 2024-10-23 09:14:41 +01:00
Michael Goulet 088f07a0a7 Represent TraitBoundModifiers as distinct parts in HIR 2024-10-22 19:48:44 +00:00
Ralf Jung 2fd8222bd4 terminology: #[feature] *enables* a feature (instead of "declaring" or "activating" it) 2024-10-22 07:37:54 +01:00
blyxyas 3773534f29 Move COGNITIVE_COMPLEXITY to use macro again 2024-10-21 19:27:34 +02:00
bors 1d0dad5eb3 Auto merge of #131988 - matthiaskrgr:rollup-tx173wn, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #126588 (Added more scenarios where comma to be removed in the function arg)
 - #131728 (bootstrap: extract builder cargo to its own module)
 - #131968 (Rip out old effects var handling code from traits)
 - #131981 (Remove the `BoundConstness::NotConst` variant)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-21 06:13:34 +00:00
Michael Goulet d8b2f9364d Rip out old effects var handling code from traits 2024-10-20 13:40:22 +00:00
Michael Goulet 69b088626c Fix tests 2024-10-19 18:07:35 +00:00
blyxyas e518d66dc0 Apply review comments + use shallow_lint_levels_on 2024-10-19 16:20:52 +02:00
blyxyas e427a4e694 Remove module passes filtering 2024-10-19 16:20:51 +02:00
blyxyas 8f8aa46a87 Follow review comments (optimize the filtering) 2024-10-19 16:20:33 +02:00
blyxyas 698363122e Do not run lints that cannot emit
Before this change, adding a lint was a difficult matter
because it always had some overhead involved. This was
because all lints would run, no matter their default level,
or if the user had #![allow]ed them. This PR changes that
2024-10-19 16:19:44 +02:00
Philipp Krones 91a458f451 Hotfix TRAIT_METHODS static->const 2024-10-18 14:54:06 +02:00
Philipp Krones fea5e77da1 Merge commit 'a109190d7060236e655fc75533373fa274ec5343' into clippy-subtree-update 2024-10-18 13:44:06 +02:00
Michael Goulet 360d86e9ec Move trait bound modifiers into hir::PolyTraitRef 2024-10-14 09:20:38 -04:00
Matthias Krüger b1c468422a Rollup merge of #131277 - ismailarilik:handle-potential-query-instability-lint-for-clippy, r=xFrednet
Handle `clippy` cases of `rustc::potential_query_instability` lint

This PR removes `#![allow(rustc::potential_query_instability)]` line from [`src/tools/clippy/clippy_lints/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/src/tools/clippy/clippy_lints/src/lib.rs#L30) 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
2024-10-12 23:00:57 +02:00
bors 806a9dfddd Auto merge of #13464 - y21:issue13458, r=flip1995
Don't warn on proc macro generated code in `needless_return`

Fixes #13458
Fixes #13457
Fixes #13467
Fixes #13479
Fixes #13481
Fixes #13526
Fixes #13486

The fix is unfortunately a little more convoluted than just simply adding a `is_from_proc_macro`. That check *does*  fix the issue, however it also introduces a bunch of false negatives in the tests, specifically when the returned expression is in a different syntax context, e.g. `return format!(..)`.

The proc macro check builds up a start and end pattern based on the HIR nodes and compares it to a snippet of the span, however that would currently fail for `return format!(..)` because we would have the patterns `("return", <something inside of the format macro>)`, which doesn't compare equal. So we now return an empty string pattern for when it's in a different syntax context.

"Hide whitespace" helps a bit for reviewing the proc macro detection change

changelog: none
2024-10-10 11:34:13 +02:00
codemountains 2226f16945 Rename NestedMetaItem to MetaItemInner 2024-10-06 23:28:30 +09:00
bors a1beaa1992 Auto merge of #129244 - cjgillot:opaque-hir, r=compiler-errors
Make opaque types regular HIR nodes

Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead.

I haven't gone through all the test changes yet, so there may be a few surprises.

Many thanks to `@camelid` for the first draft.
Fixes https://github.com/rust-lang/rust/issues/129023

Fixes #129099
Fixes #125843
Fixes #119716
Fixes #121422
2024-10-05 06:19:35 +00:00
ismailarilik 0b632ec812 Handle clippy cases of rustc::potential_query_instability lint 2024-10-05 07:34:14 +03:00
Camille GILLOT 8ad3e13765 Adapt clippy. 2024-10-04 23:50:02 +00:00
Jubilee 47b681d276 Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnay
Stabilize the `map`/`value` methods on `ControlFlow`

And fix the stability attribute on the `pub use` in `core::ops`.

libs-api in https://github.com/rust-lang/rust/issues/75744#issuecomment-2231214910 seemed reasonably happy with naming for these, so let's try for an FCP.

Summary:
```rust
impl<B, C> ControlFlow<B, C> {
    pub fn break_value(self) -> Option<B>;
    pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C>;
    pub fn continue_value(self) -> Option<C>;
    pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T>;
}
```

Resolves #75744

``@rustbot`` label +needs-fcp +t-libs-api -t-libs

---

Aside, in case it keeps someone else from going down the same dead end: I looked at the `{break,continue}_value` methods and tried to make them `const` as part of this, but that's disallowed because of not having `const Drop`, so put it back to not even unstably-const.
2024-10-04 14:11:34 -07:00
Matthias Krüger 743623d4f7 Rollup merge of #131183 - compiler-errors:opaque-ty-origin, r=estebank
Refactoring to `OpaqueTyOrigin`

Pulled out of a larger PR that uses these changes to do cross-crate encoding of opaque origin, so we can use them for edition 2024 migrations. These changes should be self-explanatory on their own, tho 😄
2024-10-03 21:52:46 +02:00
Philipp Krones 277c4e4baf Merge commit 'aa0d551351a9c15d8a95fdb3e2946b505893dda8' into clippy-subtree-update 2024-10-03 16:32:51 +02:00
Michael Goulet cbd64a4868 Use named fields for OpaqueTyOrigin 2024-10-02 22:04:18 -04:00
Michael Goulet ce22fd34d9 Remove redundant in_trait from hir::TyKind::OpaqueDef 2024-10-02 21:59:55 -04:00
Scott McMurray d232d094b8 Remove the control_flow_enum feature from clippy 2024-09-25 19:00:19 -07:00
bors 52b31180b2 Auto merge of #130778 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`

Really delayed sync (2 1/2 weeks), because of a `debug_assertion` we hit, and I didn't have the time to investigate earlier.

It would be nice to merge this PR with some priority, as it includes a lot of formatting changes due to the rustfmt bump.

Include Cargo.lock update due to Clippy version bump and ui_test bump in Clippy.
2024-09-25 11:40:41 +00:00
Michael Goulet f8969853eb Fix tools 2024-09-24 10:12:05 -04:00
Philipp Krones b61fcbee76 Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into clippy-subtree-update 2024-09-24 11:58:04 +02:00
GnomedDev 4f319002cd [Clippy] Remove final std paths for diagnostic item 2024-09-20 10:39:31 +01:00