diff --git a/src/test/ui/lint/lint-deref-nullptr.rs b/src/test/ui/lint/lint-deref-nullptr.rs index 1dc54a5622b..d052dbd9b64 100644 --- a/src/test/ui/lint/lint-deref-nullptr.rs +++ b/src/test/ui/lint/lint-deref-nullptr.rs @@ -24,14 +24,12 @@ fn f() { //~^ ERROR dereferencing a null pointer let ub = &*ptr::null::(); //~^ ERROR dereferencing a null pointer + let ub = &*ptr::null_mut::(); + //~^ ERROR dereferencing a null pointer ptr::addr_of!(*ptr::null::()); //~^ ERROR dereferencing a null pointer ptr::addr_of_mut!(*ptr::null_mut::()); //~^ ERROR dereferencing a null pointer - let ub = *ptr::null::(); - //~^ ERROR dereferencing a null pointer - let ub = *ptr::null_mut::(); - //~^ ERROR dereferencing a null pointer let offset = ptr::addr_of!((*ptr::null::()).field); //~^ ERROR dereferencing a null pointer } diff --git a/src/test/ui/lint/lint-deref-nullptr.stderr b/src/test/ui/lint/lint-deref-nullptr.stderr index 40fdfad2368..c6f432e4e42 100644 --- a/src/test/ui/lint/lint-deref-nullptr.stderr +++ b/src/test/ui/lint/lint-deref-nullptr.stderr @@ -41,34 +41,28 @@ LL | let ub = &*ptr::null::(); | ^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:27:23 + --> $DIR/lint-deref-nullptr.rs:27:19 + | +LL | let ub = &*ptr::null_mut::(); + | ^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed + +error: dereferencing a null pointer + --> $DIR/lint-deref-nullptr.rs:29:23 | LL | ptr::addr_of!(*ptr::null::()); | ^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:29:27 + --> $DIR/lint-deref-nullptr.rs:31:27 | LL | ptr::addr_of_mut!(*ptr::null_mut::()); | ^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:31:18 - | -LL | let ub = *ptr::null::(); - | ^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed - -error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:33:18 - | -LL | let ub = *ptr::null_mut::(); - | ^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed - -error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:35:36 + --> $DIR/lint-deref-nullptr.rs:33:36 | LL | let offset = ptr::addr_of!((*ptr::null::()).field); | ^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed -error: aborting due to 11 previous errors +error: aborting due to 10 previous errors