Closed
Description
Code
use std::cmp::Ordering;
fn ptr_cmp<T: ?Sized>(p1: *const T, p2: *const T) -> Ordering {
{ #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) }
}
Current output
warning: unnecessary braces around block return value
--> src/main.rs:4:5
|
4 | { #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^
|
= note: `#[warn(unused_braces)]` on by default
help: remove these braces
|
4 - { #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) }
4 + p1.cmp(&p2)
|
Desired output
warning: unnecessary braces around block return value
--> src/main.rs:4:5
|
4 | { #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) }
| ^^ ^^
|
= note: `#[warn(unused_braces)]` on by default
help: remove these braces
|
4 - { #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) }
4 + #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2)
|
Rationale and extra context
Removing the attributes can change the meaning of the code.
Rust Version
rustc 1.88.0-beta.1 (be8721b77 2025-05-09)
binary: rustc
commit-hash: be8721b77bafe41f05bd77cda681a1610f44d7cd
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.88.0-beta.1
LLVM version: 20.1.4