You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnmain(){let _x = main as*const() == main as*const();}
Run cargo clippy --fix outputs:
Checking test_ v0.1.0 (/home/lrne/Project/Rust/test_)
warning: failed to automatically apply fixes suggested by rustc to crate `test_`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error[E0308]: arguments to this function are incorrect
--> src/main.rs:2:14
|
2 | let _x = std::ptr::eq(main, main);
| ^^^^^^^^^^^^
|
note: expected `*const _`, found fn item
--> src/main.rs:2:27
|
2 | let _x = std::ptr::eq(main, main);
| ^^^^
= note: expected raw pointer `*const _`
found fn item `fn() {main}`
note: expected `*const _`, found fn item
--> src/main.rs:2:33
|
2 | let _x = std::ptr::eq(main, main);
| ^^^^
= note: expected raw pointer `*const _`
found fn item `fn() {main}`
note: function defined here
--> /home/lrne/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:2143:8
|
2143 | pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
| ^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
Original diagnostics will follow.
warning: equal expressions as operands to `==`
--> src/main.rs:2:14
|
2 | let _x = main as *const () == main as *const ();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
= note: `#[warn(clippy::eq_op)]` on by default
warning: use `std::ptr::eq` when comparing raw pointers
--> src/main.rs:2:14
|
2 | let _x = main as *const () == main as *const ();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(main, main)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
= note: `#[warn(clippy::ptr_eq)]` on by default
warning: `test_` (bin "test_" test) generated 2 warnings (run `cargo clippy --fix --bin "test_" --tests` to apply 1 suggestion)
warning: failed to automatically apply fixes suggested by rustc to crate `test_`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error[E0308]: arguments to this function are incorrect
--> src/main.rs:2:14
|
2 | let _x = std::ptr::eq(main, main);
| ^^^^^^^^^^^^
|
note: expected `*const _`, found fn item
--> src/main.rs:2:27
|
2 | let _x = std::ptr::eq(main, main);
| ^^^^
= note: expected raw pointer `*const _`
found fn item `fn() {main}`
note: expected `*const _`, found fn item
--> src/main.rs:2:33
|
2 | let _x = std::ptr::eq(main, main);
| ^^^^
= note: expected raw pointer `*const _`
found fn item `fn() {main}`
note: function defined here
--> /home/lrne/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:2143:8
|
2143 | pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
| ^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
Original diagnostics will follow.
warning: `test_` (bin "test_") generated 2 warnings (2 duplicates)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.81s
This PR:
- lints more case of raw pointer comparisons
- do not omit the named function to raw pointer conversion before
suggesting
- trigger the `ptr_eq` lint only if `cmp_null` doesn't trigger first, as
this is a more specialized version
- lints against `!=` in addition to `==`
The `ptr_eq` code has been moved from under `operators` to `ptr.rs`, in
order to benefit from factorization.
Fix#14337
changelog: [`ptr_eq`]: handle more cases
Uh oh!
There was an error while loading. Please reload this page.
Description
Run
cargo clippy --fix
outputs:Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: