Auto merge of #7294 - stevenengler:unsafe-ptr-deref-msg, r=Manishearth

Improve message for `not_unsafe_ptr_arg_deref` lint

changelog: Improved message for the ['not_unsafe_ptr_arg_deref'] lint

Doesn't close any issue, but implements a suggestion from https://github.com/rust-lang/rust-clippy/issues/3045#issuecomment-791556803.
This commit is contained in:
bors 2021-05-31 00:36:46 +00:00
commit 860cb8f977
2 changed files with 10 additions and 10 deletions

View file

@ -116,7 +116,7 @@ impl<'a, 'tcx> DerefVisitor<'a, 'tcx> {
self.cx, self.cx,
NOT_UNSAFE_PTR_ARG_DEREF, NOT_UNSAFE_PTR_ARG_DEREF,
ptr.span, ptr.span,
"this public function dereferences a raw pointer but is not marked `unsafe`", "this public function might dereference a raw pointer but is not marked `unsafe`",
); );
} }
} }

View file

@ -30,7 +30,7 @@ error: this function has too many arguments (8/7)
LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:63:34 --> $DIR/functions.rs:63:34
| |
LL | println!("{}", unsafe { *p }); LL | println!("{}", unsafe { *p });
@ -38,49 +38,49 @@ LL | println!("{}", unsafe { *p });
| |
= note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings` = note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:64:35 --> $DIR/functions.rs:64:35
| |
LL | println!("{:?}", unsafe { p.as_ref() }); LL | println!("{:?}", unsafe { p.as_ref() });
| ^ | ^
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:65:33 --> $DIR/functions.rs:65:33
| |
LL | unsafe { std::ptr::read(p) }; LL | unsafe { std::ptr::read(p) };
| ^ | ^
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:76:30 --> $DIR/functions.rs:76:30
| |
LL | println!("{}", unsafe { *p }); LL | println!("{}", unsafe { *p });
| ^ | ^
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:77:31 --> $DIR/functions.rs:77:31
| |
LL | println!("{:?}", unsafe { p.as_ref() }); LL | println!("{:?}", unsafe { p.as_ref() });
| ^ | ^
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:78:29 --> $DIR/functions.rs:78:29
| |
LL | unsafe { std::ptr::read(p) }; LL | unsafe { std::ptr::read(p) };
| ^ | ^
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:87:34 --> $DIR/functions.rs:87:34
| |
LL | println!("{}", unsafe { *p }); LL | println!("{}", unsafe { *p });
| ^ | ^
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:88:35 --> $DIR/functions.rs:88:35
| |
LL | println!("{:?}", unsafe { p.as_ref() }); LL | println!("{:?}", unsafe { p.as_ref() });
| ^ | ^
error: this public function dereferences a raw pointer but is not marked `unsafe` error: this public function might dereference a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:89:33 --> $DIR/functions.rs:89:33
| |
LL | unsafe { std::ptr::read(p) }; LL | unsafe { std::ptr::read(p) };