Emit feature gate suggestion
This commit is contained in:
parent
e5d90652e2
commit
4497ff3762
5 changed files with 75 additions and 40 deletions
|
|
@ -18,13 +18,13 @@ const fn no_unsafe() { unsafe {} }
|
|||
|
||||
// not ok
|
||||
const fn foo8() -> i32 {
|
||||
unsafe { foo4() } //~ ERROR unsafe operations are not allowed in const fn
|
||||
unsafe { foo4() } //~ ERROR calls to `const unsafe fn` in const fns are unstable
|
||||
}
|
||||
const fn foo9() -> *const String {
|
||||
unsafe { foo5::<String>() } //~ ERROR unsafe operations are not allowed in const fn
|
||||
unsafe { foo5::<String>() } //~ ERROR calls to `const unsafe fn` in const fns are unstable
|
||||
}
|
||||
const fn foo10() -> *const Vec<std::cell::Cell<u32>> {
|
||||
unsafe { foo6::<Vec<std::cell::Cell<u32>>>() } //~ ERROR not allowed in const fn
|
||||
unsafe { foo6::<Vec<std::cell::Cell<u32>>>() } //~ ERROR calls to `const unsafe fn` in const fns
|
||||
}
|
||||
const unsafe fn foo30_3(x: *mut usize) -> usize { *x } //~ ERROR not allowed in const fn
|
||||
//~^ dereferencing raw pointers in constant functions
|
||||
|
|
|
|||
|
|
@ -14,29 +14,29 @@ LL | Foo { x: () }.y //~ ERROR not allowed in const fn
|
|||
|
|
||||
= help: add #![feature(const_fn_union)] to the crate attributes to enable
|
||||
|
||||
error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
|
||||
error[E0658]: calls to `const unsafe fn` in const fns are unstable (see issue #55607)
|
||||
--> $DIR/min_const_fn_unsafe.rs:21:14
|
||||
|
|
||||
LL | unsafe { foo4() } //~ ERROR unsafe operations are not allowed in const fn
|
||||
| ^^^^^^ call to unsafe function
|
||||
LL | unsafe { foo4() } //~ ERROR calls to `const unsafe fn` in const fns are unstable
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
= help: add #![feature(min_const_unsafe_fn)] to the crate attributes to enable
|
||||
|
||||
error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
|
||||
error[E0658]: calls to `const unsafe fn` in const fns are unstable (see issue #55607)
|
||||
--> $DIR/min_const_fn_unsafe.rs:24:14
|
||||
|
|
||||
LL | unsafe { foo5::<String>() } //~ ERROR unsafe operations are not allowed in const fn
|
||||
| ^^^^^^^^^^^^^^^^ call to unsafe function
|
||||
LL | unsafe { foo5::<String>() } //~ ERROR calls to `const unsafe fn` in const fns are unstable
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
= help: add #![feature(min_const_unsafe_fn)] to the crate attributes to enable
|
||||
|
||||
error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
|
||||
error[E0658]: calls to `const unsafe fn` in const fns are unstable (see issue #55607)
|
||||
--> $DIR/min_const_fn_unsafe.rs:27:14
|
||||
|
|
||||
LL | unsafe { foo6::<Vec<std::cell::Cell<u32>>>() } //~ ERROR not allowed in const fn
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
||||
LL | unsafe { foo6::<Vec<std::cell::Cell<u32>>>() } //~ ERROR calls to `const unsafe fn` in const fns
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
= help: add #![feature(min_const_unsafe_fn)] to the crate attributes to enable
|
||||
|
||||
error: dereference of raw pointer is unsafe and unsafe operations are not allowed in const fn
|
||||
--> $DIR/min_const_fn_unsafe.rs:29:51
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue