about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/typeck/ptr-null-mutability-suggestions.fixed11
-rw-r--r--tests/ui/typeck/ptr-null-mutability-suggestions.rs11
-rw-r--r--tests/ui/typeck/ptr-null-mutability-suggestions.stderr21
3 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/typeck/ptr-null-mutability-suggestions.fixed b/tests/ui/typeck/ptr-null-mutability-suggestions.fixed
new file mode 100644
index 00000000000..d00536b29cf
--- /dev/null
+++ b/tests/ui/typeck/ptr-null-mutability-suggestions.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+
+#[allow(unused_imports)]
+use std::ptr;
+
+fn expecting_null_mut(_: *mut u8) {}
+
+fn main() {
+    expecting_null_mut(core::ptr::null_mut());
+    //~^ ERROR mismatched types
+}
diff --git a/tests/ui/typeck/ptr-null-mutability-suggestions.rs b/tests/ui/typeck/ptr-null-mutability-suggestions.rs
new file mode 100644
index 00000000000..ea3066d2289
--- /dev/null
+++ b/tests/ui/typeck/ptr-null-mutability-suggestions.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+
+#[allow(unused_imports)]
+use std::ptr;
+
+fn expecting_null_mut(_: *mut u8) {}
+
+fn main() {
+    expecting_null_mut(ptr::null());
+    //~^ ERROR mismatched types
+}
diff --git a/tests/ui/typeck/ptr-null-mutability-suggestions.stderr b/tests/ui/typeck/ptr-null-mutability-suggestions.stderr
new file mode 100644
index 00000000000..705b029bdea
--- /dev/null
+++ b/tests/ui/typeck/ptr-null-mutability-suggestions.stderr
@@ -0,0 +1,21 @@
+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()`
+   |     arguments to this function are incorrect
+   |
+   = note: expected raw pointer `*mut u8`
+              found raw pointer `*const _`
+note: function defined here
+  --> $DIR/ptr-null-mutability-suggestions.rs:6:4
+   |
+LL | fn expecting_null_mut(_: *mut u8) {}
+   |    ^^^^^^^^^^^^^^^^^^ ----------
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.