]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/min_const_fn/min_const_fn_unsafe_feature_gate.stderr
Add test for dereferencing raw pointers and immediately referencing again
[rust.git] / src / test / ui / consts / min_const_fn / min_const_fn_unsafe_feature_gate.stderr
1 error[E0658]: dereferencing raw pointers in constant functions is unstable (see issue #51911)
2   --> $DIR/min_const_fn_unsafe_feature_gate.rs:47:51
3    |
4 LL | const unsafe fn foo30_3(x: *mut usize) -> usize { *x } //~ ERROR not allowed in const fn
5    |                                                   ^^
6    |
7    = help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable
8
9 error[E0658]: dereferencing raw pointers in constant functions is unstable (see issue #51911)
10   --> $DIR/min_const_fn_unsafe_feature_gate.rs:50:60
11    |
12 LL | const unsafe fn foo30_4(x: *mut usize) -> &'static usize { &*x } //~ ERROR not allowed in const fn
13    |                                                            ^^^
14    |
15    = help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable
16
17 error[E0658]: unions in const fn are unstable (see issue #51909)
18   --> $DIR/min_const_fn_unsafe_feature_gate.rs:57:5
19    |
20 LL |     Foo { x: () }.y //~ ERROR not allowed in const fn
21    |     ^^^^^^^^^^^^^^^
22    |
23    = help: add #![feature(const_fn_union)] to the crate attributes to enable
24
25 error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
26   --> $DIR/min_const_fn_unsafe_feature_gate.rs:39:5
27    |
28 LL |     foo4() //~ ERROR not allowed in const fn
29    |     ^^^^^^ call to unsafe function
30    |
31    = note: consult the function's documentation for information on how to avoid undefined behavior
32
33 error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
34   --> $DIR/min_const_fn_unsafe_feature_gate.rs:42:5
35    |
36 LL |     foo5::<String>() //~ ERROR not allowed in const fn
37    |     ^^^^^^^^^^^^^^^^ call to unsafe function
38    |
39    = note: consult the function's documentation for information on how to avoid undefined behavior
40
41 error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
42   --> $DIR/min_const_fn_unsafe_feature_gate.rs:45:5
43    |
44 LL |     foo6::<Vec<std::cell::Cell<u32>>>() //~ ERROR not allowed in const fn
45    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
46    |
47    = note: consult the function's documentation for information on how to avoid undefined behavior
48
49 error: dereference of raw pointer is unsafe and unsafe operations are not allowed in const fn
50   --> $DIR/min_const_fn_unsafe_feature_gate.rs:47:51
51    |
52 LL | const unsafe fn foo30_3(x: *mut usize) -> usize { *x } //~ ERROR not allowed in const fn
53    |                                                   ^^ dereference of raw pointer
54    |
55    = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
56
57 error: dereference of raw pointer is unsafe and unsafe operations are not allowed in const fn
58   --> $DIR/min_const_fn_unsafe_feature_gate.rs:50:60
59    |
60 LL | const unsafe fn foo30_4(x: *mut usize) -> &'static usize { &*x } //~ ERROR not allowed in const fn
61    |                                                            ^^^ dereference of raw pointer
62    |
63    = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
64
65 error: access to union field is unsafe and unsafe operations are not allowed in const fn
66   --> $DIR/min_const_fn_unsafe_feature_gate.rs:57:5
67    |
68 LL |     Foo { x: () }.y //~ ERROR not allowed in const fn
69    |     ^^^^^^^^^^^^^^^ access to union field
70    |
71    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
72
73 error: aborting due to 9 previous errors
74
75 For more information about this error, try `rustc --explain E0658`.