Skip to content

Commit 62a712a

Browse files
committed
Hide suggestion to wrap function in unsafe block
1 parent aca61b2 commit 62a712a

File tree

3 files changed

+1
-38
lines changed

3 files changed

+1
-38
lines changed

compiler/rustc_mir_transform/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn {
147147
diag.note(self.details.note());
148148

149149
if let Some((start, end)) = self.suggest_unsafe_block {
150-
diag.multipart_suggestion_verbose(
150+
diag.tool_only_multipart_suggestion(
151151
crate::fluent_generated::mir_transform_suggestion,
152152
vec![(start, " unsafe {".into()), (end, "}".into())],
153153
Applicability::MaybeIncorrect,

tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.mir.stderr

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ note: the lint level is defined here
1010
|
1111
LL | #![deny(unsafe_op_in_unsafe_fn)]
1212
| ^^^^^^^^^^^^^^^^^^^^^^
13-
help: consider wrapping the function body in an unsafe block
14-
|
15-
LL ~ unsafe fn deny_level() { unsafe {
16-
LL | unsf();
17-
...
18-
LL |
19-
LL ~ }}
20-
|
2113

2214
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
2315
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:15:5
@@ -60,14 +52,6 @@ note: the lint level is defined here
6052
LL | #[deny(warnings)]
6153
| ^^^^^^^^
6254
= note: `#[deny(unsafe_op_in_unsafe_fn)]` implied by `#[deny(warnings)]`
63-
help: consider wrapping the function body in an unsafe block
64-
|
65-
LL ~ unsafe fn warning_level() { unsafe {
66-
LL | unsf();
67-
...
68-
LL |
69-
LL ~ }}
70-
|
7155

7256
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
7357
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:31:5

tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ note: the lint level is defined here
1010
|
1111
LL | #![deny(unsafe_op_in_unsafe_fn)]
1212
| ^^^^^^^^^^^^^^^^^^^^^^
13-
help: consider wrapping the function body in an unsafe block
14-
|
15-
LL ~ pub unsafe fn foo() { unsafe {
16-
LL | unsf();
17-
LL | unsf();
18-
LL ~ }}
19-
|
2013

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

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

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

0 commit comments

Comments
 (0)