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
Soveu
149671192d
new lint for as *const _ and as *mut _ casting
2024-12-06 20:44:03 +01:00
Jason Newcomb
a5e46a6b08
update borrow_as_ptr to suggest &raw syntax ( #13689 )
...
This PR updates the `borrow_as_ptr` lint to no longer suggest `addr_of!`
and `addr_of_mut!` and instead use the preferred `&raw const` and `&raw
mut` syntax.
Not sure about two things:
1. Do I need to set or update a MSRV for the lint anywhere?
2. There is a `borrow_as_ptr_no_std` test as well as a `borrow_as_ptr`
test. They used to be more relevant as the lint needed to select `std`
or `core`, but that is gone now, so maybe the `borrow_as_ptr_no_std`
should be deleted?
changelog: update `borrow_as_ptr` to suggest `&raw` syntax
2024-12-05 10:18:19 +00:00
cyrgani
9925f999f6
update borrow_as_ptr to suggest &raw when the MSRV allows it
2024-12-05 09:48:55 +01:00
cyrgani
c8b10ac671
fix the order of emitting ref_as_ptr and borrow_as_ptr
2024-12-05 09:46:57 +01:00
Philipp Krones
b24360aa87
Merge remote-tracking branch 'upstream/master' into rustup
2024-11-28 18:56:49 +01:00
lcnr
809b420e16
move fn is_item_raw to TypingEnv
2024-11-19 18:06:20 +01:00
Samuel Tardieu
ca963b653e
Simplify instances of Option::map_or(true, …) in Clippy sources
2024-11-16 00:12:41 +01:00
Philipp Krones
5c1811ab94
Rename all clippy_config::msrvs -> clippy_utils::msrvs
2024-11-15 19:38:09 +01:00
Philipp Krones
1ceaa90413
Merge commit ' 786fbd6d68' into clippy-subtree-update
2024-11-14 19:35:26 +01:00
Jacherr
89210d7c5a
new lint unnecessary_map_or
2024-11-12 23:00:26 +00:00
Philipp Krones
6ced8c33c0
Merge commit ' f712eb5cdc' into clippy-subtree-update
2024-11-07 22:37:01 +01:00
Samuel Tardieu
f2f73f9c9c
Replace .map(…).any(identity) by .any(…)
2024-10-29 11:55:13 +01:00
Philipp Krones
fea5e77da1
Merge commit ' a109190d70' into clippy-subtree-update
2024-10-18 13:44:06 +02:00
GnomedDev
dedc380df9
Apply fixes from lint
2024-10-13 21:03:38 +01:00
GnomedDev
ef1db3f502
Check MethodCall/Call arg count earlier or at all
2024-10-13 11:24:47 +01:00
Philipp Krones
277c4e4baf
Merge commit ' aa0d551351' into clippy-subtree-update
2024-10-03 16:32:51 +02:00
Samuel Tardieu
0791efaaac
Use std_or_core to determine the correct prefix
...
Replace hand-crafted tests by the a call to the `std_or_core()` utility
function.
2024-09-24 19:09:40 +02:00
Philipp Krones
b61fcbee76
Merge commit ' 7901289135' into clippy-subtree-update
2024-09-24 11:58:04 +02:00
Philipp Krones
3ab1da8bab
Formatting
2024-09-22 20:52:15 +02:00
Samuel Tardieu
30608732c2
Handle null pointer constness cast through methods
...
This covers two cases:
- `core::ptr::null::<T>().cast_mut()` -> `core::ptr::null_mut::<T>()`
- `core::ptr::null_mut::<T>().cast_const()` -> `core::ptr::null::<T>()`
2024-09-09 10:18:31 +02:00
Samuel Tardieu
9e9526c6ab
Special-case suggestions for null pointers constness cast
2024-09-09 10:18:31 +02:00
Jason Newcomb
173d5a6af0
Merge commit ' 0f8eabd623' into clippyup
2024-08-24 18:33:44 -04:00
Jason Newcomb
e348fe2233
Merge branch 'master' into rustup
2024-08-24 16:31:01 -04:00
Jason Newcomb
9450b4af48
Replace more uses of snippet_opt.
2024-08-21 14:41:18 -04:00
Alex Macleod
4f661302c6
Replace span_suggestion_with_style with _verbose
2024-08-17 18:09:28 +00:00
Jason Newcomb
ddf2ba5886
Remove more instances of snippet_opt.
2024-08-11 18:07:53 -04:00
Nicholas Nethercote
e785219238
Shrink TyKind::FnPtr.
...
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and
`FnHeader`, which can be packed more efficiently. This reduces the size
of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms.
This reduces peak memory usage by a few percent on some benchmarks. It
also reduces cache misses and page faults similarly, though this doesn't
translate to clear cycles or wall-time improvements on CI.
2024-08-09 14:33:25 +10:00
Philipp Krones
1ac76a2062
Merge commit ' cb806113e0' into clippy-subtree-update
2024-08-08 19:13:50 +02:00
bors
b1e87922c1
Auto merge of #13200 - Jarcho:constant_no_typeck, r=Alexendoo
...
Don't use `LateContext` in the constant evaluator
This also changes the interface to require explicitly creating the context. `constant` could be added back in, but the others are probably not worth it.
A couple of bugs have been fixed. The wrong `TypeckResults` was used once when evaluating a constant, and the wrong `ParamEnv` was used by some callers (there wasn't a way to use the correct one).
changelog: none
2024-08-08 14:42:42 +00:00
Jason Newcomb
e4ad36d6a8
Require ConstEvalCtxt to be constructed.
2024-08-08 10:37:10 -04:00
Jason Newcomb
16633a2d7b
Replace in_constant with is_in_const_context. Use only the state in LateContext to avoid walking the HIR tree.
2024-08-07 09:57:27 -04:00
xFrednet
0532104247
Migrating restriction lints to span_lint_and_then (e -> i)
2024-08-03 10:18:15 +02:00
Philipp Krones
4e6851e50b
Merge commit ' 37f4fbb929' into clippy-subtree-update
2024-07-25 18:29:17 +02:00
bors
5e6540f049
Auto merge of #13146 - Alexendoo:cast-lossless-128, r=y21
...
Lint casts to `u128` in `cast_lossless`
Reverts #12496 per https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Should.20.60as.20u128.60.20trigger.20cast_lossless
Also changes the lint messages and refactors the suggestion production - Fixes #12695
changelog: [`cast_lossless`]: lint casts to `u128`
2024-07-24 21:00:05 +00:00
Alex Macleod
6d28e1a954
Lint casts to u128 in cast_lossless
2024-07-24 14:32:41 +00:00
Alex Macleod
7010d3c67e
Don't suggest .cast_mut/.cast_const for types with erased lifetimes
2024-07-23 11:12:26 +00:00
Jason Newcomb
e34c6dbae5
Refactor for using config values:
...
* Construct lint passes by taking `Conf` by reference.
* Use `HashSet` configs in less places
* Move some `check_crate` code into the pass constructor when possible.
2024-07-17 14:05:49 -04:00
Florian Bartels
edeb0fcddc
Fix syntax errors in example code
2024-07-12 11:12:01 +02:00
Philipp Krones
c1fd25d0aa
Merge commit ' b794b8e08c' into clippy-subtree-update
2024-07-11 15:44:03 +02:00
bors
8d3b1f9e30
Auto merge of #12984 - bitfield:fix_doc_nits_c, r=Alexendoo
...
Fix doc nits
More tender love and polish for the documentation and suggestion texts: adding formatting, links, full stops, tweaking wording for readability, changing 'which' to 'that' where appropriate, and other standard copyediting changes.
changelog: Docs [ `await_holding_lock` ]: fix doc nits
changelog: Docs [ `await_holding_refcell_ref` ]: fix doc nits
changelog: Docs [ `await_holding_invalid_type` ]: fix doc nits
changelog: Docs [ `cast_precision_loss` ]: fix doc nits
changelog: Docs [ `cast_sign_loss` ]: fix doc nits
changelog: Docs [ `cast_possible_truncation` ]: fix doc nits
changelog: Docs [ `cast_possible_wrap` ]: fix doc nits
changelog: Docs [ `cast_lossless` ]: fix doc nits
changelog: Docs [ `unnecessary_cast` ]: fix doc nits
changelog: Docs [ `cast_ptr_alignment` ]: fix doc nits
changelog: Docs [ `fn_to_numeric_cast` ]: fix doc nits
changelog: Docs [ `fn_to_numeric_cast_with_truncation` ]: fix doc nits
changelog: Docs [ `fn_to_numeric_cast_any` ]: fix doc nits
changelog: Docs [ `char_lit_as_u8` ]: fix doc nits
changelog: Docs [ `ptr_as_ptr` ]: fix doc nits
changelog: Docs [ `ptr_cast_constness` ]: fix doc nits
changelog: Docs [ `as_ptr_cast_mut` ]: fix doc nits
changelog: Docs [ `little_endian_bytes` ]: fix doc nits
changelog: Docs [ `big_endian_bytes` ]: fix doc nits
changelog: Docs [ `bind_instead_of_map` ]: fix doc nits
changelog: Docs [ `same_name_method` ]: fix doc nits
2024-07-10 17:55:08 +00:00
John Arundel
d23df74712
resolve code review comments
2024-07-08 19:05:35 +01:00
John Arundel
5a9e5e4acf
resolve code review comments
2024-07-07 10:49:26 +01:00
John Arundel
f7050b0c78
resolve code review comments
2024-07-07 10:44:27 +01:00
Philipp Krones
abdd057163
Merge commit ' 68a799aea9' into clippy-subtree-update
2024-06-27 18:56:04 +02:00
Philipp Krones
e9e7a815a7
Merge remote-tracking branch 'upstream/master' into rustup
2024-06-27 18:49:59 +02:00
John Arundel
625091d236
Fix doc nits
2024-06-23 13:11:54 +01:00
Trevor Gross
8cde354f0b
Resolve Clippy f16 and f128 unimplemented!/FIXMEs
...
This removes the ICE codepaths for `f16` and `f128` in Clippy.
`rustc_apfloat` is used as a dependency for the parsing of these types,
since their `FromStr` implementation will not be available in the
standard library for a while.
2024-06-19 13:30:21 -04:00
Jason Newcomb
a002f93e51
expr_use_ctxt changes:
...
* Delay the parsing of the use node
* Mark when the `SyntaxContext` changes rather than return `None`
* Return a default value if the HIR tree is broken rather than `None`
2024-06-16 18:00:21 -04:00
Philipp Krones
3bff119f63
Merge commit ' 3e5a02b13b' into clippy-subtree-update
2024-06-13 12:30:48 +02:00