Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hide suggestion to wrap function in unsafe block
  • Loading branch information
Nemo157 committed Jun 13, 2023
commit 62a712a8bbb29a5d2f4e82b74d1ee5aa0490a5a3
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn {
diag.note(self.details.note());

if let Some((start, end)) = self.suggest_unsafe_block {
diag.multipart_suggestion_verbose(
diag.tool_only_multipart_suggestion(
crate::fluent_generated::mir_transform_suggestion,
vec![(start, " unsafe {".into()), (end, "}".into())],
Applicability::MaybeIncorrect,
Expand Down
16 changes: 0 additions & 16 deletions tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.mir.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ note: the lint level is defined here
|
LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^
help: consider wrapping the function body in an unsafe block
|
LL ~ unsafe fn deny_level() { unsafe {
LL | unsf();
...
LL |
LL ~ }}
|

error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:15:5
Expand Down Expand Up @@ -60,14 +52,6 @@ note: the lint level is defined here
LL | #[deny(warnings)]
| ^^^^^^^^
= note: `#[deny(unsafe_op_in_unsafe_fn)]` implied by `#[deny(warnings)]`
help: consider wrapping the function body in an unsafe block
|
LL ~ unsafe fn warning_level() { unsafe {
LL | unsf();
...
LL |
LL ~ }}
|

error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:31:5
Expand Down
21 changes: 0 additions & 21 deletions tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ note: the lint level is defined here
|
LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^
help: consider wrapping the function body in an unsafe block
|
LL ~ pub unsafe fn foo() { unsafe {
LL | unsf();
LL | unsf();
LL ~ }}
|

error: call to unsafe function is unsafe and requires unsafe block (error E0133)
--> $DIR/wrapping-unsafe-block-sugg.rs:9:5
Expand All @@ -33,13 +26,6 @@ LL | let y = *x;
| ^^ dereference of raw pointer
|
= note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
help: consider wrapping the function body in an unsafe block
|
LL ~ pub unsafe fn bar(x: *const i32) -> i32 { unsafe {
LL | let y = *x;
LL | y + *x
LL ~ }}
|

error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
--> $DIR/wrapping-unsafe-block-sugg.rs:14:9
Expand All @@ -56,13 +42,6 @@ LL | let y = BAZ;
| ^^^ use of mutable static
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
help: consider wrapping the function body in an unsafe block
|
LL ~ pub unsafe fn baz() -> i32 { unsafe {
LL | let y = BAZ;
LL | y + BAZ
LL ~ }}
|

error: use of mutable static is unsafe and requires unsafe block (error E0133)
--> $DIR/wrapping-unsafe-block-sugg.rs:20:9
Expand Down