Commit Graph

10489 Commits

Author SHA1 Message Date
codemountains
2226f16945 Rename NestedMetaItem to MetaItemInner 2024-10-06 23:28:30 +09:00
bors
d0507302fc Auto merge of #130540 - veera-sivarajan:fix-87525, r=estebank
Add a Lint for Pointer to Integer Transmutes in Consts

Fixes #87525

This PR adds a MirLint for pointer to integer transmutes in const functions and associated consts. The implementation closely follows this comment: https://github.com/rust-lang/rust/pull/85769#issuecomment-880969112. More details about the implementation can be found in the comments.

Note: This could break some sound code as mentioned by RalfJung in https://github.com/rust-lang/rust/pull/85769#issuecomment-886491680:

> ... technically const-code could transmute/cast an int to a ptr and then transmute it back and that would be correct -- so the lint will deny some sound code. Does not seem terribly likely though.

References:
1. https://doc.rust-lang.org/std/mem/fn.transmute.html
2. https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants
2024-10-06 02:39:23 +00:00
Veera
98b59a1cf6 Add a Lint for Pointer to Integer Transmutes in Consts 2024-10-05 12:48:02 +00:00
Matthias Krüger
a0653c5e98 Rollup merge of #131256 - RalfJung:f16-f128-const, r=ibraheemdev
move f16/f128 const fn under f16/f128 feature gate

The `*_const` features were added to work around https://github.com/rust-lang/rust/issues/129656, which should not be needed any more.
2024-10-05 13:15:58 +02:00
Ralf Jung
7f390d6fe0 move f16/f128 const fn under f16/f128 feature gate 2024-10-05 10:13:18 +02: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
Jubilee
7bac9cd747 Rollup merge of #129517 - cjgillot:known-panic-array, r=pnkfelix
Compute array length from type for unconditional panic lint.

Fixes https://github.com/rust-lang/rust/issues/98444

The cases that involve slicing are harder, so https://github.com/rust-lang/rust/issues/38035 remains open.
2024-10-04 19:19:22 -07:00
Camille GILLOT
810bd5dd09 Bless clippy. 2024-10-05 00:19:43 +00:00
Camille GILLOT
8ad3e13765 Adapt clippy. 2024-10-04 23:50:02 +00:00
Noah Lev
1a29a78335 rm ItemKind::OpaqueTy
This introduce an additional collection of opaques on HIR, as they can no
longer be listed using the free item list.
2024-10-04 23:28:22 +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
Ralf Jung
4891dd4627 make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
Jubilee
ad3464493d Rollup merge of #130912 - estebank:point-at-arg-type, r=compiler-errors
On implicit `Sized` bound on fn argument, point at type instead of pattern

Instead of

```
error[E0277]: the size for values of type `(dyn ThriftService<(), AssocType = _> + 'static)` cannot be known at compilation time
  --> $DIR/issue-59324.rs:23:20
   |
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
   |                    ^^^^^^^ doesn't have a size known at compile-time
```

output

```
error[E0277]: the size for values of type `(dyn ThriftService<(), AssocType = _> + 'static)` cannot be known at compilation time
  --> $DIR/issue-59324.rs:23:29
   |
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
   |                             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
```
2024-09-26 22:20:57 -07:00
Esteban Küber
eff6d414c0 On implicit Sized bound on fn argument, point at type instead of pattern
Instead of

```
error[E0277]: the size for values of type `(dyn ThriftService<(), AssocType = _> + 'static)` cannot be known at compilation time
  --> $DIR/issue-59324.rs:23:20
   |
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
   |                    ^^^^^^^ doesn't have a size known at compile-time
```

output

```
error[E0277]: the size for values of type `(dyn ThriftService<(), AssocType = _> + 'static)` cannot be known at compilation time
  --> $DIR/issue-59324.rs:23:29
   |
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
   |                             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
```
2024-09-27 00:45:02 +00: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
Trevor Gross
e691743119 Rollup merge of #130764 - compiler-errors:inherent, r=estebank
Separate collection of crate-local inherent impls from error tracking

#119895 changed the return type of the `crate_inherent_impls` query from `CrateInherentImpls` to `Result<CrateInherentImpls, ErrorGuaranteed>` to avoid needing to use the non-parallel-friendly `track_errors()` to track if an error was reporting from within the query... This was mostly fine until #121113, which stopped halting compilation when we hit an `Err(ErrorGuaranteed)` in the `crate_inherent_impls` query.

Thus we proceed onwards to typeck, and since a return type of `Result<CrateInherentImpls, ErrorGuaranteed>` means that the query can *either* return one of "the list inherent impls" or "error has been reported", later on when we want to assemble method or associated item candidates for inherent impls, we were just treating any `Err(ErrorGuaranteed)` return value as if Rust had no inherent impls defined anywhere at all! This leads to basically every inherent method call failing with an error, lol, which was reported in #127798.

This PR changes the `crate_inherent_impls` query to return `(CrateInherentImpls, Result<(), ErrorGuaranteed>)`, i.e. returning the inherent impls collected *and* whether an error was reported in the query itself. It firewalls the latter part of that query into a new `crate_inherent_impls_validity_check` just for the `ensure()` call.

This fixes #127798.
2024-09-24 19:47:50 -04:00
Lukas Markeffsky
08a8e68d2e be even more precise about "cast" vs "coercion" 2024-09-24 23:12:02 +02:00
Lukas Markeffsky
d802a7a3c7 unify dyn* coercions with other pointer coercions 2024-09-24 22:17:55 +02:00
Philipp Krones
6c2e82496f Remove unused import from Clippy versions.py file 2024-09-24 18:13:17 +02:00
Michael Goulet
f8969853eb Fix tools 2024-09-24 10:12:05 -04:00
Philipp Krones
4108c6e5a0 Hotfix: remove profile from clippy Cargo.toml 2024-09-24 11:58:48 +02:00
Philipp Krones
b61fcbee76 Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into clippy-subtree-update 2024-09-24 11:58:04 +02:00
Ben Kimock
249210e8d8 Fix clippy 2024-09-21 01:07:00 -04:00
bors
bb04c68b2e Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errors
Disallow hidden references to mutable static

Closes #123060

Tracking:
- https://github.com/rust-lang/rust/issues/123758
2024-09-20 17:25:34 +00:00
GnomedDev
4f319002cd [Clippy] Remove final std paths for diagnostic item 2024-09-20 10:39:31 +01:00
GnomedDev
07b6e0713e Categorise paths in clippy_utils::paths 2024-09-19 13:13:43 +01:00
GnomedDev
c7453b4280 [Clippy] Swap open_options to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
GnomedDev
917775fff1 [Clippy] Swap iter_over_hash_type to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
GnomedDev
37e38320b4 [Clippy] Swap non_octal_unix_permissions to use diagnostic item instead of path 2024-09-19 13:13:43 +01:00
GnomedDev
f1fc9c07c4 [Clippy] Swap unnecessary_owned_empty_strings to use diagnostic item instead of path 2024-09-19 13:13:43 +01:00
GnomedDev
1b76ae683c [Clippy] Swap manual_strip to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
GnomedDev
acb6748f80 [Clippy] Swap unnecessary_to_owned to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
98dc68e85e [Clippy] Swap instant_subtraction to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
d63e35ba22 [Clippy] Swap waker_clone_wake to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
45c1700e13 [Clippy] Swap filter_map_bool_then to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
b0152909d6 [Clippy] Swap manual_while_let_some to use diagnostic items instead of paths 2024-09-19 13:13:42 +01:00
GnomedDev
984bd6fed6 [Clippy] Swap repeat_vec_with_capacity to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
545967955a [Clippy] Swap VecArgs::hir to use diagnostic items instead of paths 2024-09-19 13:13:40 +01:00
GnomedDev
f66915e8f8 [Clippy] Swap single_char_add_str/format_push_string to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
959f7a2bbb [Clippy] Swap manual_main_separator_str to use diagnostic item instead of path 2024-09-19 13:13:20 +01:00
GnomedDev
1922a99bc6 [Clippy] Swap redundant_clone to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
8fc9e67cf5 [Clippy] Swap float_equality_without_abs to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
7ffd485be0 [Clippy] Swap option_as_ref_deref to use diagnostic items instead of paths 2024-09-19 13:13:19 +01:00
GnomedDev
71dbfd55a1 [Clippy] Swap lines_filter_map_ok to use a diagnostic item instead of path 2024-09-19 08:26:41 +01:00
GnomedDev
5a13a93d41 [Clippy] Swap map_entry to use diagnostic items instead of paths 2024-09-19 08:26:37 +01:00