Esteban Küber
5228e28469
Account for const stability in clippy when checking constness
2025-07-07 23:07:32 +00:00
Esteban Küber
d6f7aad00e
Make Default const and add some const Default impls
...
Full list of `impl const Default` types:
- ()
- bool
- char
- Cell
- std::ascii::Char
- usize
- u8
- u16
- u32
- u64
- u128
- i8
- i16
- i32
- i64
- i128
- f16
- f32
- f64
- f128
- std::marker::PhantomData<T>
- Option<T>
- std::iter::Empty<T>
- std::ptr::Alignment
- &[T]
- &mut [T]
- &str
- &mut str
- String
- Vec<T>
2025-07-07 22:09:37 +00:00
Scott Schafer
7060377bfe
refactor: Make -Ztrack-diagnostics emit like a note
2025-07-03 07:19:25 -06:00
Samuel Tardieu
8bd580b80e
Add track_caller attributes to trace origin of Clippy lints
...
This allows the use of `-Z track-diagnostics` to see the origin of
Clippy lints emission, as is already the case for lints coming from
rustc.
2025-07-02 11:50:25 +02:00
Guillaume Gomez
4793fd1c46
Update clippy source code to make use of TyCtxt::def_descr instead of ItemKind::descr
2025-07-01 17:27:48 +02:00
bors
06a87e91c9
Auto merge of #143116 - matthiaskrgr:rollup-zy9ez06, r=matthiaskrgr
...
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#139858 (New const traits syntax)
- rust-lang/rust#140809 (Reduce special casing for the panic runtime)
- rust-lang/rust#142730 (suggest declaring modules when file found but module not defined)
- rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver)
- rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell)
- rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology)
- rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv)
- rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`)
- rust-lang/rust#143106 (gce: don't ICE on non-local const)
Failed merges:
- rust-lang/rust#143036 (Remove support for `dyn*` from the compiler)
r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-27 23:15:35 +00:00
Philipp Krones
074ccaf3c0
Merge commit ' c5dbd1de07' into clippy-subtree-update
2025-06-27 12:20:57 +02:00
Oli Scherer
4f3c17486e
Change const trait bound syntax from ~const to [const]
2025-06-26 13:46:45 +00:00
bors
73273f2571
Auto merge of #140748 - m-ou-se:super-format-args3, r=jdonszelmann
...
Allow storing `format_args!()` in variable
Fixes https://github.com/rust-lang/rust/issues/92698
Tracking issue for super let: https://github.com/rust-lang/rust/issues/139076
Tracking issue for format_args: https://github.com/rust-lang/rust/issues/99012
This change allows:
```rust
let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!
println!("{f}");
```
This will need an FCP.
This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging https://github.com/rust-lang/rust/pull/139114 .)
(This is a second version of https://github.com/rust-lang/rust/pull/139135 )
2025-06-19 19:13:32 +00:00
Jakub Beránek
62a36e611f
Rollup merge of #141610 - BoxyUwU:stabilize_generic_arg_infer, r=lcnr,traviscross
...
Stabilize `feature(generic_arg_infer)`
Fixes rust-lang/rust#85077
r? lcnr
cc ````@rust-lang/project-const-generics````
2025-06-18 18:06:49 +02:00
Mara Bos
a01dd1edaf
Update/bless clippy tests.
2025-06-18 10:20:46 +02:00
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
Boxy
4cb48c8d75
stabilize gai
2025-06-11 15:30:15 +01: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
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