@@ -26,5 +26,51 @@ LL | unsf();
26
26
|
27
27
= note: consult the function's documentation for information on how to avoid undefined behavior
28
28
29
- error: aborting due to 2 previous errors
29
+ error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
30
+ --> $DIR/wrapping-unsafe-block-sugg.rs:13:13
31
+ |
32
+ LL | let y = *x;
33
+ | ^^ dereference of raw pointer
34
+ |
35
+ = 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
+ |
43
+
44
+ error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
45
+ --> $DIR/wrapping-unsafe-block-sugg.rs:14:9
46
+ |
47
+ LL | y + *x
48
+ | ^^ dereference of raw pointer
49
+ |
50
+ = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
51
+
52
+ error: use of mutable static is unsafe and requires unsafe block (error E0133)
53
+ --> $DIR/wrapping-unsafe-block-sugg.rs:19:13
54
+ |
55
+ LL | let y = BAZ;
56
+ | ^^^ use of mutable static
57
+ |
58
+ = 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
+ |
66
+
67
+ error: use of mutable static is unsafe and requires unsafe block (error E0133)
68
+ --> $DIR/wrapping-unsafe-block-sugg.rs:20:9
69
+ |
70
+ LL | y + BAZ
71
+ | ^^^ use of mutable static
72
+ |
73
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
74
+
75
+ error: aborting due to 6 previous errors
30
76
0 commit comments