Commit graph

3788 commits

Author SHA1 Message Date
David Wood
765015d7e5 clippy: {Meta,Pointee,}Sized in non-minicore
One clippy test is `no_core` and needs to have `MetaSized` and
`PointeeSized` added to it.
2025-06-16 23:04:37 +00:00
Matthias Krüger
252a6dd40b Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
Unimplement unsized_locals

Implements https://github.com/rust-lang/compiler-team/issues/630

Tracking issue here: https://github.com/rust-lang/rust/issues/111942

Note that this just removes the feature, not the implementation, and does not touch `unsized_fn_params`. This is because it is required to support `Box<dyn FnOnce()>: FnOnce()`.

There may be more that should be removed (possibly in follow up prs)
- the `forget_unsized` function and `forget` intrinsic.
- the `unsized_locals` test directory; I've just fixed up the tests for now
- various codegen support for unsized values and allocas

cc ``@JakobDegen`` ``@oli-obk`` ``@Noratrieb`` ``@programmerjake`` ``@bjorn3``

``@rustbot`` label F-unsized_locals

Fixes rust-lang/rust#79409
2025-06-14 11:27:10 +02:00
Philipp Krones
cbd683fe31 Merge commit '4ef75291b5' into clippy-subtree-update 2025-06-13 11:24:45 +02:00
mejrs
88d298317f Unimplement unsized_locals 2025-06-13 01:16:36 +02:00
bors
2f80ead27c Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, r=traviscross,jieyouxu
Add a new `mismatched-lifetime-syntaxes` lint

The lang-team [discussed this](https://hackmd.io/nf4ZUYd7Rp6rq-1svJZSaQ) and I attempted to [summarize](https://github.com/rust-lang/rust/pull/120808#issuecomment-2701863833) their decision. The summary-of-the-summary is:

- Using two different kinds of syntax for elided lifetimes is confusing. In rare cases, it may even [lead to unsound code](https://github.com/rust-lang/rust/issues/48686)! Some examples:

    ```rust
    // Lint will warn about these
    fn(v: ContainsLifetime) -> ContainsLifetime<'_>;
    fn(&'static u8) -> &u8;
    ```

- Matching up references with no lifetime syntax, references with anonymous lifetime syntax, and paths with anonymous lifetime syntax is an exception to the simplest possible rule:

    ```rust
    // Lint will not warn about these
    fn(&u8) -> &'_ u8;
    fn(&'_ u8) -> &u8;
    fn(&u8) -> ContainsLifetime<'_>;
    ```

- Having a lint for consistent syntax of elided lifetimes will make the [future goal](https://github.com/rust-lang/rust/issues/91639) of warning-by-default for paths participating in elision much simpler.

---

This new lint attempts to accomplish the goal of enforcing consistent syntax. In the process, it supersedes and replaces the existing `elided-named-lifetimes` lint, which means it starts out life as warn-by-default.
2025-06-05 19:49:30 +00:00
Jake Goulding
8b59e34a80 Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
Matthias Krüger
a0b0f918f3 Rollup merge of #141698 - oli-obk:ctfe-err-flip, r=RalfJung
Use the informative error as the main const eval error message

r? `@RalfJung`

I only did the minimal changes necessary to the const eval error machinery. I'd prefer not to mix test changes with refactorings 😆
2025-06-03 21:53:37 +02:00
Oli Scherer
d1f9d02104 Clarify why we are talking about a failed const eval at a random place 2025-06-02 15:37:15 +00:00
Oli Scherer
166f664495 Use the informative error as the main const eval error message 2025-06-02 15:37:15 +00:00
bors
8708e3fca1 Auto merge of #141814 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2025-06-02 12:56:24 +00:00
Jacob Pratt
61465edac2 Rollup merge of #141072 - Rynibami:stabilize-const-result-flatten, r=jhpratt
Stabilize feature `result_flattening`

Stabilizes the `Result::flatten` method

## Implementations

- [x] Implementation `Result::flatten`: https://github.com/rust-lang/rust/pull/70140
- [x] Implementation `const` `Result::flatten`: https://github.com/rust-lang/rust/pull/130692
- [x] Update stabilization attribute macros (this PR)

## Stabilization process

- [x] Created this PR [suggested](https://github.com/rust-lang/rust/issues/70142#issuecomment-2885044548) by ``@RalfJung``
- [x] FCP (haven't found any, is it applicable here?)
- [ ] Close issue rust-lang/rust#70142
2025-06-01 00:35:50 +02:00
Philipp Krones
9f86a576e3 Merge commit '57cbadd68a' 2025-05-31 14:22:15 +02:00
beetrees
1d903b6d10 Stabilise repr128 2025-05-28 15:14:34 +01:00
Matthias Krüger
7e5c819796 Rollup merge of #141130 - mejrs:use_self, r=compiler-errors
rustc_on_unimplemented cleanups

Addresses some of the fixmes from https://github.com/rust-lang/rust/pull/139091 and https://github.com/rust-lang/rust/pull/140307.

- switch from `_Self` to `Self` in library
- properly validate that arguments in the `on` filter and the format strings are actually valid

See https://github.com/rust-lang/rustc-dev-guide/pull/2357 for the relevant documentation.
2025-05-22 16:02:30 +02:00
Philipp Krones
7debaf6b44 Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
mejrs
f3bad7f4dd do away with _Self and TraitName and check generic params for rustc_on_unimplemented 2025-05-17 15:15:53 +02:00
Ryan van Polen
a9225f8263 Updated feature flag and output of clippy/tests/ui/map_flatten* 2025-05-16 13:28:33 +02:00
Philipp Krones
93bd4d8931 Merge commit '0450db33a5' into clippy-subtree-update 2025-05-15 19:28:39 +02:00
Stuart Cook
874ad22b74 Rollup merge of #139773 - thaliaarchi:vec-into-iter-last, r=workingjubilee
Implement `Iterator::last` for `vec::IntoIter`

Avoid iterating everything when we have random access to the last element.
2025-05-06 16:28:39 +10:00
bors
32e150d651 Auto merge of #131160 - ismailarilik:handle-potential-query-instability-lint-for-rustc-middle, r=oli-obk
Handle `rustc_middle` cases of `rustc::potential_query_instability` lint

This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_middle/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/lib.rs#L29) 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

r? `@compiler-errors`
2025-05-06 01:36:23 +00:00
ismailarilik
59aaecbbf9 Handle rustc_middle cases of rustc::potential_query_instability lint 2025-05-05 16:36:04 +03:00
Thalia Archibald
3564afaa77 Implement Iterator::last for vec::IntoIter 2025-05-02 20:08:28 -07:00
Philipp Krones
dd5113daab Merge commit '03a5b6b976' into clippy-subtree-update 2025-05-01 10:22:55 +02:00
yuk1ty
148c9a1981 Fix error message for static references or mutable references 2025-04-26 14:48:30 +09:00
bendn
6e64338a49 Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etc 2025-04-24 13:14:36 +07:00
Philipp Krones
ff428d91c2 Merge commit '0621446356' into clippy-subtree-update 2025-04-22 18:24:43 +02:00
Urgau
5f26d0e970 Drop clippy::invalid_null_ptr_usage 2025-03-30 19:33:15 +02:00
Philipp Krones
c86216ebe7 Merge commit '1e5237f4a5' into clippy-subtree-update 2025-03-20 22:34:29 +01:00
Esteban Küber
915e44216a Do not suggest using -Zmacro-backtrace for builtin macros
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-14 19:50:03 +00:00
Oli Scherer
cb044d4d7b Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
Philipp Krones
a6a78e13e2 Clippy: skip check_host_compiler check in rustc testsuite
This test only makes sense to run in the Clippy repo

In the Rust repo the name of the host_compiler is dev, not nightly
2025-02-28 23:27:22 +01:00
Philipp Krones
fe01c44995 Merge commit '9f9a822509' into clippy-subtree-update 2025-02-28 23:27:09 +01:00
Jana Dönszelmann
17bda0c0fe simplify must-use lint slightly 2025-02-24 14:31:19 +01:00
Jana Dönszelmann
443b0f5ccf Fix rustdoc and clippy 2025-02-24 14:31:19 +01:00
Michael Goulet
a04e819b93 Trim suggestion part before generating highlights 2025-02-21 00:54:01 +00:00
Michael Goulet
fef0ea905a More sophisticated span trimming 2025-02-21 00:41:17 +00:00
Nicholas Nethercote
8cf9eea5b3 Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11:00
Michael Goulet
fc532c5b32 Trim suggestion parts to the subset that is purely additive 2025-02-14 00:44:10 -08:00
Esteban Küber
3a0b1ae59d Show diff suggestion format on verbose replacement
```
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
  --> $DIR/attempted-access-non-fatal.rs:7:15
   |
LL |     let _ = 2.l;
   |               ^
   |
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
   |
LL -     let _ = 2.l;
LL +     let _ = 2.0f64;
   |
```
2025-02-10 20:21:39 +00:00
Jana Dönszelmann
477be9470a add tests for spurious failure and fix typo 2025-02-07 16:59:17 +01:00
Jonathan Dönszelmann
4044c1aa49 fix empty after lint on impl/trait items
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-02-07 16:47:26 +01:00
Guillaume Gomez
42453bd73a Update UI tests 2025-02-07 16:47:26 +01:00
Philipp Krones
5aa9d7ae7f Merge commit '3e3715c312' into clippy-subtree-update 2025-02-06 15:00:24 +01:00
Philipp Krones
9da9ddb7db Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
Kalle Wachsmuth
25a77cf4f4 remove clippy::double_neg 2025-01-26 12:15:12 +01:00
bors
d22dcb9cb4 Auto merge of #134299 - RalfJung:remove-start, r=compiler-errors
remove support for the (unstable) #[start] attribute

As explained by `@Noratrieb:`
`#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction.

I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple:
- `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail)
- `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways*

`#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is  a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program.
So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place.

Note that this feature has **not** been RFCed in the first place.

*This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.*

Closes https://github.com/rust-lang/rust/issues/29633

try-job: x86_64-gnu-nopt
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: test-various
2025-01-21 19:46:20 +00:00
Ralf Jung
759212cd59 remove support for the #[start] attribute 2025-01-21 06:59:15 -07:00
Guillaume Gomez
e31493b9b8 Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable, 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-15 16:30:11 +01:00
Jacob Pratt
1361c1f006 Rollup merge of #132397 - m-ou-se:warn-missing-abi, r=Nadrieril
Make missing_abi lint warn-by-default.

This makes the missing_abi lint warn-by-default, as suggested here: https://github.com/rust-lang/rfcs/pull/3722#issuecomment-2447719047

This needs a lang FCP.
2025-01-15 04:08:10 -05:00
Ralf Jung
caebd67ba9 intrinsics: deprecate calling them via the unstable std::intrinsics path 2025-01-15 09:41:33 +01:00