diff options
| author | bors <bors@rust-lang.org> | 2024-03-29 18:23:57 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-29 18:23:57 +0000 | 
| commit | af4a5a13a15fa0c60e06321077ef452f769b42fd (patch) | |
| tree | 34fa2676e47438840fbdb8ced2dbf3337452935d /compiler/rustc_lint/src/lints.rs | |
| parent | 399fa2f6e419fd2c70942c191c2e55814af8d167 (diff) | |
| parent | d4b514f982e4214e0f9237c905670b1207ae0c95 (diff) | |
| download | rust-af4a5a13a15fa0c60e06321077ef452f769b42fd.tar.gz rust-af4a5a13a15fa0c60e06321077ef452f769b42fd.zip | |
Auto merge of #121268 - Urgau:improve_ambi_wide_ptr_cmps, r=Nadrieril
Add detection of [Partial]Ord methods in the `ambiguous_wide_pointer_comparisons` lint Partially addresses https://github.com/rust-lang/rust/issues/121264 by adding diagnostics items for PartialOrd and Ord methods, detecting such diagnostics items as "binary operation" and suggesting the correct replacement. I also took the opportunity to change the suggestion to use new methods `.cast()` on `*mut T` an d `*const T`.
Diffstat (limited to 'compiler/rustc_lint/src/lints.rs')
| -rw-r--r-- | compiler/rustc_lint/src/lints.rs | 14 | 
1 files changed, 8 insertions, 6 deletions
| diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 1dac2d89c6b..cf3890dc61c 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1668,14 +1668,16 @@ pub enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> { Cast { deref_left: &'a str, deref_right: &'a str, - #[suggestion_part(code = "{deref_left}")] + paren_left: &'a str, + paren_right: &'a str, + #[suggestion_part(code = "({deref_left}")] left_before: Option<Span>, - #[suggestion_part(code = " as *const ()")] - left: Span, - #[suggestion_part(code = "{deref_right}")] + #[suggestion_part(code = "{paren_left}.cast::<()>()")] + left_after: Span, + #[suggestion_part(code = "({deref_right}")] right_before: Option<Span>, - #[suggestion_part(code = " as *const ()")] - right: Span, + #[suggestion_part(code = "{paren_right}.cast::<()>()")] + right_after: Span, }, } | 
