Commit graph

21381 commits

Author SHA1 Message Date
Guillaume Gomez
34b1765e65 Move more def paths into clippy_utils::paths 2024-12-29 20:39:43 +01:00
Alejandra González
b57d98b00e
Do not remove required parentheses in borrow_as_ptr suggestion (#13884)
Also, simplify boolean shortcut expression, and ensure that
applicability is properly applied, as it was ignored and
`MachineApplicable` was always used.

changelog: [`borrow_as_ptr`]: do not remove required parentheses in
autofix suggestion

Close #13882
2024-12-29 16:29:53 +00:00
Fridtjof Stoldt
f5f1abd8fb
borrow_interior_mutable_const ICE into FN (#13877)
This PR just makes sure that we exit the function before getting an ICE
and adds a regression test. Related to #12979. We would need to keep
researching the issue, but as the ICEing code isn't that complicated,
getting a hotfix into nightly is urgent.

changelog:[`borrow_interior_mutable_const`] Fix ICE #12979
2024-12-29 15:52:35 +00:00
Samuel Tardieu
eef47fc0b7 Do not remove required parentheses in borrow_as_ptr suggestion
Also, simplify boolean expression, and ensure that proper applicability
is used.
2024-12-29 16:50:05 +01:00
dswij
c8ba3e1d7a
use the correct ParamEnv when checking future's output type (#13863)
Fixes #13862

`missing_headers::check` is sometimes called from outside of a body
(specifically, from `check_attributes`, where the LateContext's ParamEnv
is not yet properly initialized for that item). Using that empty
ParamEnv for trait solving things from within the body can then lead to
various ICEs, like the linked issue where we have a const generic
parameter `DMA_INST` without a `ConstArgHasType` bound in the ParamEnv
so the const parameter has no type, which is normally not supposed to
happen.

We have the item's DefId so we can just get its ParamEnv/TypingEnv from
there, and using that one for trait solving should be safe.

changelog: none
2024-12-29 09:31:57 +00:00
dswij
aef47725a3
Examples fixes for regex (#13874)
Examples fixes for regex

changelog: none
2024-12-29 09:30:01 +00:00
llogiq
786f090bb9
Do not trigger trailing_empty_array in tests (#13844)
Close #13837

changelog: [`trailing_empty_array`]: do not trigger on tests
2024-12-29 00:10:58 +00:00
blyxyas
d7cc6c45c8 borrow_interior_mutable_const ICE into FN
Convert the ICE reported in #12979 into a false negative.
We prefer a false negative to a ICE (because the ICE could
still affect the user even when not activating the lint).
2024-12-28 19:42:30 +01:00
Philipp Krones
998c780126
fix arguments of ExprKind::MethodCall (#13890)
changelog: none
2024-12-28 13:47:09 +00:00
lapla-cogito
09022bbd45
fix arguments of ExprKind::MethodCall 2024-12-28 22:41:29 +09:00
Timo
a8968e5dd8
Make inconsistent_struct_constructor "all fields are shorthand" requirement configurable (#13737)
Fixes #11846.

This PR has three commits:
- The first commit adds an `initializer-suggestions` configuration to
control suggestion applicability when initializers are present. The
following are the options:
  - "none": do not suggest
- "maybe-incorrect": suggest, but do not apply suggestions with `--fix`
  - "machine-applicable": suggest and apply suggestions with `--fix`
- The second commit fixes suggestions to handle field attributes
(problem [noticed by
@samueltardieu](https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1859261645)).
- The third commit adds `initializer-suggestions = "machine-applicable"`
to Clippy's `clippy.toml` and applies the suggestions. (Nothing seems to
break.)

---

changelog: make `inconsistent_struct_constructor` "all fields are
shorthand" requirement configurable
2024-12-27 22:05:03 +00:00
Fridtjof Stoldt
363e61dcbf
remove description of known problems in match_same_arms that have already been resolved (#13873)
The "known problems" pointed out in the `match_same_arms` lint seem to
have already been resolved.

changelog: none
2024-12-27 22:03:38 +00:00
Fridtjof Stoldt
4be0e62b22
correct suggestion for manual_div_ceil lint (#13864)
fix #13843

The `manual_div_ceil` lint makes incorrect suggestion when type suffixes
need to be made explicit in the suggested code.

changelog: [`manual_div_ceil`]: suggested code now includes appropriate
type suffixes where necessary
2024-12-27 21:44:13 +00:00
Timo
553a381764
Remove obsolete comment (#13850)
`is_integer_const()` does the const folding.

changelog: none
2024-12-27 15:04:29 +00:00
Samuel Moelius
8a38bcc390 Make "all fields are shorthand" requirement configurable
Handle field attributes in suggestions

Fix adjacent code

Address review comments

https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1861352124

Address all review comments but one

This comment is not yet addressed: https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1874544907

`initializer_suggestions` -> `lint_inconsistent_struct_field_initializers`
2024-12-26 19:36:58 -05:00
Philipp Krones
609cd310be
Rustup (#13881)
r? @ghost

changelog: none
2024-12-26 13:52:31 +00:00
Philipp Krones
416f7e84c0
Bump nightly version -> 2024-12-26 2024-12-26 14:47:30 +01:00
Philipp Krones
14af404672
Merge remote-tracking branch 'upstream/master' into rustup 2024-12-26 14:46:57 +01:00
Philipp Krones
dff0294ab3
fix examples using Ty.kind() in the book (#13875)
`Ty.kind()` is a method.

changelog: none
2024-12-26 12:31:32 +00:00
lapla-cogito
b28bfbceeb
fix examples using Ty.kind() 2024-12-25 13:59:48 +09:00
llogiq
85b609419b
auto-fix if_not_else (#13809)
fix #13411

The `if_not_else` lint can be fixed automatically, but the issue above
reports that there is no implementation to do so. Therefore, this PR
implements it.

----

changelog: [`if_not_else`]: make suggestions for modified code
2024-12-24 21:45:42 +00:00
alexey semenyuk
be09596df9
Examples fixes for regex 2024-12-24 18:36:10 +05:00
lapla-cogito
887aa269b6
add more tests 2024-12-24 21:10:43 +09:00
lapla-cogito
71f1a8702d
remove known problems section from match_same_arms 2024-12-24 18:44:34 +09:00
bors
b5fe6ec47b Auto merge of #134625 - compiler-errors:unsafe-binders-ty, r=oli-obk
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-24 00:51:51 +00:00
Alejandra González
988042e0b2
chore: multipart suggestions for let_unit_value lint (#13754)
This should address #13099 for the let_unit test.

changelog: [let_unit]: Updated let_unit to use multipart_suggestions
where appropriate
2024-12-23 14:50:01 +00:00
Timo
592fd34c1b
Fix has_iter_method documentation (#13867)
changelog: none
2024-12-23 02:21:16 +00:00
Samuel Tardieu
1f8ba334a5 Fix has_iter_method documentation 2024-12-23 00:42:34 +01:00
Michael Goulet
4d735d831e Begin to implement type system layer of unsafe binders 2024-12-22 21:57:57 +00:00
lapla-cogito
de86302691
correct suggestion for manual_div_ceil lint 2024-12-23 01:40:51 +09:00
Scott McMurray
c772140a1f Update clippy 2024-12-22 06:12:45 -08:00
y21
15ab2ff55a use the correct ParamEnv when checking future's return type in missing_errors_doc 2024-12-21 21:09:40 +01:00
llogiq
b3fadd5a8e
Add allow-indexing-slicing-in-tests option (#13854)
Close #13842

changelog: [`indexing_slicing`]: add allow-indexing-slicing-in-tests
option to be able ignore at test
2024-12-19 20:11:48 +00:00
Alexey Semenyuk
6f6ddd299c Add allow-indexing-slicing-in-tests option 2024-12-20 01:06:49 +05:00
bors
54a396a9bd Auto merge of #133961 - lcnr:borrowck-cleanup, r=jackh726
cleanup region handling: add `LateParamRegionKind`

The second commit is to enable a split between `BoundRegionKind` and `LateParamRegionKind`, by avoiding `BoundRegionKind` where it isn't necessary.

The third comment then adds `LateParamRegionKind` to avoid having the same late-param region for separate bound regions. This fixes #124021.

r? `@compiler-errors`
2024-12-19 08:33:20 +00:00
Manish Goregaokar
a775a1b41f
Use multipart suggestion in unnecessary_to_owned (#13847)
It is related to https://github.com/rust-lang/rust-clippy/issues/13099

What was done:
- removed `@no-rustfix` from `tests/ui/unnecessary_to_owned.rs`
- checked for suggestions in `src/methods/unnecessary_to_owned.rs`
(there is already one multipart_suggestion, and I don't see any other)
- ran `cargo uibless`

I am new to Rust, and this is my first PR.

changelog: none
2024-12-19 01:25:29 +00:00
Oleksandr Polieno
1e0b59d6a6 Use multipart suggestion in unnecessary_to_owned 2024-12-19 07:29:18 +07:00
lcnr
f415510fba introduce LateParamRegionKind 2024-12-18 16:05:44 +01:00
许杰友 Jieyou Xu (Joe)
550d36d895 Rollup merge of #134161 - nnethercote:overhaul-token-cursors, r=spastorino
Overhaul token cursors

Some nice cleanups here.

r? `````@davidtwco`````
2024-12-18 22:56:53 +08:00
Alejandra González
9f4941a873
chore: starting to fix unnecessary_iter_cloned (#13848)
This will address https://github.com/rust-lang/rust-clippy/issues/13099
for the unnecessary_iter_cloned test.

changelog: [unnecessary_iter_cloned]: unnecessary_iter_cloned
manual_assert to use multipart_suggestions where appropriate
2024-12-17 23:48:16 +00:00
Nicholas Nethercote
1cb4dcafd1 Rename RefTokenTreeCursor.
Because `TokenStreamIter` is a much better name for a `TokenStream`
iterator. Also rename the `TokenStream::trees` method as
`TokenStream::iter`, and some local variables.
2024-12-18 10:39:07 +11:00
Samuel Tardieu
639f40568e Remove obsolete comment
`is_integer_const()` does the const folding.
2024-12-18 00:37:41 +01:00
Nicholas Nethercote
5c200c2255 Simplify RefTokenTreeCursor::look_ahead.
It's only ever used with a lookahead of 0, so this commit removes the
lookahead and renames it `peek`.
2024-12-18 10:31:39 +11:00
Philipp Krones
8ea395ed14
fix a broken anchor in the book (#13846)
changelog: none
2024-12-17 21:37:59 +00:00
Philipp Krones
f8da18cdef
Do not mark attributes with unknown namespace as useless (#13766)
Fixes #13764

changelog: [`useless_attribute`]: do not trigger on attributes with
unknown namespace
2024-12-17 21:37:10 +00:00
Scott Gerring
8fe39b276f Change unnecessary_iter_cloned to use multipart_suggestion 2024-12-17 18:14:34 +01:00
Jason Newcomb
0f9cc8d58b
Don't trigger filter_map_identity with an iterator from an empty array (#13826)
fix #12653

changelog: [`filter_map_identity`]: don't lint for creating an iterator
from an empty array
2024-12-17 13:34:04 +00:00
lapla-cogito
81c0cf8a2d
fix the team anchor in book 2024-12-17 21:53:50 +09:00
Alexey Semenyuk
a5d5edc581 Do not trigger trailing_empty_array in tests 2024-12-17 14:16:48 +05:00
Jonathan Dönszelmann
4d05825f3e rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00