diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-07-05 20:38:16 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-07-05 20:38:21 +0000 |
| commit | fca286a39edc17480bce0ce9215a1eab349e9497 (patch) | |
| tree | aeb223cc022faa3cd6378437004ad0a00ac5f8bd | |
| parent | c4225812973cee4bba952cbf7a421f69871fed0d (diff) | |
| download | rust-fca286a39edc17480bce0ce9215a1eab349e9497.tar.gz rust-fca286a39edc17480bce0ce9215a1eab349e9497.zip | |
Use verbose suggestion for `ptr::null_mut()`
| -rw-r--r-- | compiler/rustc_hir_typeck/src/errors.rs | 1 | ||||
| -rw-r--r-- | tests/ui/typeck/ptr-null-mutability-suggestions.stderr | 10 |
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index e49b921e63c..f1ed2ade3d4 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -501,6 +501,7 @@ pub enum SuggestBoxing { #[suggestion( hir_typeck_suggest_ptr_null_mut, applicability = "maybe-incorrect", + style = "verbose", code = "core::ptr::null_mut()" )] pub struct SuggestPtrNullMut { diff --git a/tests/ui/typeck/ptr-null-mutability-suggestions.stderr b/tests/ui/typeck/ptr-null-mutability-suggestions.stderr index b615d9fb45c..2912977a461 100644 --- a/tests/ui/typeck/ptr-null-mutability-suggestions.stderr +++ b/tests/ui/typeck/ptr-null-mutability-suggestions.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/ptr-null-mutability-suggestions.rs:9:24 | LL | expecting_null_mut(ptr::null()); - | ------------------ ^^^^^^^^^^^ - | | | - | | types differ in mutability - | | help: consider using `core::ptr::null_mut` instead: `core::ptr::null_mut()` + | ------------------ ^^^^^^^^^^^ types differ in mutability + | | | arguments to this function are incorrect | = note: expected raw pointer `*mut u8` @@ -15,6 +13,10 @@ note: function defined here | LL | fn expecting_null_mut(_: *mut u8) {} | ^^^^^^^^^^^^^^^^^^ ---------- +help: consider using `core::ptr::null_mut` instead + | +LL | expecting_null_mut(core::ptr::null_mut()); + | ~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error |
