const extern fn bar() {
unsafe {
regular_in_block();
- //~^ ERROR: can only call other `const fn` within a `const fn`
+ //~^ ERROR: calls in constant functions
}
}
const extern fn foo() {
unsafe {
regular();
- //~^ ERROR: can only call other `const fn` within a `const fn`
+ //~^ ERROR: calls in constant functions
}
}
-error[E0723]: can only call other `const fn` within a `const fn`, but `regular_in_block` is not stable as `const fn`
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/const-extern-fn-call-extern-fn.rs:9:9
|
LL | regular_in_block();
| ^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
-error[E0723]: can only call other `const fn` within a `const fn`, but `regular` is not stable as `const fn`
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/const-extern-fn-call-extern-fn.rs:18:9
|
LL | regular();
| ^^^^^^^^^
- |
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0723`.
+For more information about this error, try `rustc --explain E0015`.
const unsafe extern fn use_float() { 1.0 + 1.0; }
//~^ ERROR only int, `bool` and `char` operations are stable in const fn
const extern "C" fn ptr_cast(val: *const u8) { val as usize; }
-//~^ ERROR casting pointers to ints is unstable in const fn
+//~^ ERROR casting pointers to integers
fn main() {}
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
-error[E0723]: casting pointers to ints is unstable in const fn
+error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/const-extern-fn-min-const-fn.rs:8:48
|
LL | const extern "C" fn ptr_cast(val: *const u8) { val as usize; }
| ^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
+ = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
error: aborting due to 3 previous errors
-For more information about this error, try `rustc --explain E0723`.
+Some errors have detailed explanations: E0658, E0723.
+For more information about an error, try `rustc --explain E0658`.
// Test that we can't call random fns in a const fn or do other bad things.
-#![feature(const_fn, const_transmute)]
+#![feature(const_fn, const_fn_transmute)]
use std::mem::transmute;
foo(&mut 5);
}
-const fn foo(x: &mut i32) -> i32 { //~ ERROR mutable references in const fn are unstable
+const fn foo(x: &mut i32) -> i32 { //~ ERROR mutable references in const fn
*x + 1
+
}
impl S {
const fn foo(&mut self, x: u32) {
+ //~^ ERROR mutable references
self.state = x;
- //~^ contains unimplemented expression
}
}
-error[E0019]: constant function contains unimplemented expression type
- --> $DIR/const_let_assign3.rs:9:9
+error[E0723]: mutable references in const fn are unstable
+ --> $DIR/const_let_assign3.rs:8:18
|
-LL | self.state = x;
- | ^^^^^^^^^^^^^^
+LL | const fn foo(&mut self, x: u32) {
+ | ^^^^^^^^^
|
- = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+ = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
+ = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0764]: mutable references are not allowed in constants
--> $DIR/const_let_assign3.rs:16:5
error: aborting due to 4 previous errors
-Some errors have detailed explanations: E0019, E0764.
+Some errors have detailed explanations: E0019, E0723, E0764.
For more information about an error, try `rustc --explain E0019`.
const fn foo(a: i32) -> Vec<i32> {
- vec![1, 2, 3] //~ ERROR heap allocations are not allowed in const fn
+ vec![1, 2, 3]
+ //~^ ERROR allocations are not allowed
+ //~| ERROR unimplemented expression type
+ //~| ERROR calls in constant functions
}
fn main() {}
-error[E0723]: heap allocations are not allowed in const fn
+error[E0010]: allocations are not allowed in constant functions
+ --> $DIR/bad_const_fn_body_ice.rs:2:5
+ |
+LL | vec![1, 2, 3]
+ | ^^^^^^^^^^^^^ allocation not allowed in constant functions
+ |
+ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0019]: constant function contains unimplemented expression type
+ --> $DIR/bad_const_fn_body_ice.rs:2:5
+ |
+LL | vec![1, 2, 3]
+ | ^^^^^^^^^^^^^
+ |
+ = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/bad_const_fn_body_ice.rs:2:5
|
LL | vec![1, 2, 3]
| ^^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-error: aborting due to previous error
+error: aborting due to 3 previous errors
-For more information about this error, try `rustc --explain E0723`.
+Some errors have detailed explanations: E0010, E0015, E0019.
+For more information about an error, try `rustc --explain E0010`.
const fn foo11_2<T: Send>(t: T) -> T { t }
//~^ ERROR trait bounds other than `Sized` on const fn parameters are unstable
const fn foo19(f: f32) -> f32 { f * 2.0 }
-//~^ ERROR only int, `bool` and `char` operations are stable in const fn
+//~^ ERROR int, `bool` and `char` operations
const fn foo19_2(f: f32) -> f32 { 2.0 - f }
-//~^ ERROR only int, `bool` and `char` operations are stable in const fn
+//~^ ERROR int, `bool` and `char` operations
const fn foo19_3(f: f32) -> f32 { -f }
-//~^ ERROR only int and `bool` operations are stable in const fn
+//~^ ERROR int, `bool` and `char` operations
const fn foo19_4(f: f32, g: f32) -> f32 { f / g }
-//~^ ERROR only int, `bool` and `char` operations are stable in const fn
+//~^ ERROR int, `bool` and `char` operations
static BAR: u32 = 42;
-const fn foo25() -> u32 { BAR } //~ ERROR cannot access `static` items in const fn
-const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot access `static` items
+const fn foo25() -> u32 { BAR } //~ ERROR cannot refer to statics
+const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot refer to statics
const fn foo30(x: *const u32) -> usize { x as usize }
-//~^ ERROR casting pointers to ints is unstable
+//~^ ERROR casting pointers to integers
const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
-//~^ ERROR casting pointers to ints is unstable
+//~^ ERROR casting pointers to integers
const fn foo30_2(x: *mut u32) -> usize { x as usize }
-//~^ ERROR casting pointers to ints is unstable
+//~^ ERROR casting pointers to integers
const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
-//~^ ERROR casting pointers to ints is unstable
+//~^ ERROR casting pointers to integers
const fn foo30_6() -> bool { let x = true; x }
const fn inc(x: &mut i32) { *x += 1 }
//~^ ERROR mutable references in const fn are unstable
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
-error[E0723]: only int and `bool` operations are stable in const fn
+error[E0723]: only int, `bool` and `char` operations are stable in const fn
--> $DIR/min_const_fn.rs:84:35
|
LL | const fn foo19_3(f: f32) -> f32 { -f }
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
-error[E0723]: cannot access `static` items in const fn
+error[E0013]: constant functions cannot refer to statics
--> $DIR/min_const_fn.rs:90:27
|
LL | const fn foo25() -> u32 { BAR }
| ^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: consider extracting the value of the `static` to a `const`, and referring to that
-error[E0723]: cannot access `static` items in const fn
+error[E0013]: constant functions cannot refer to statics
--> $DIR/min_const_fn.rs:91:37
|
LL | const fn foo26() -> &'static u32 { &BAR }
| ^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: consider extracting the value of the `static` to a `const`, and referring to that
-error[E0723]: casting pointers to ints is unstable in const fn
+error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/min_const_fn.rs:92:42
|
LL | const fn foo30(x: *const u32) -> usize { x as usize }
| ^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
+ = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
-error[E0723]: casting pointers to ints is unstable in const fn
+error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/min_const_fn.rs:94:63
|
LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
| ^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
+ = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
-error[E0723]: casting pointers to ints is unstable in const fn
+error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/min_const_fn.rs:96:42
|
LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
| ^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
+ = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
-error[E0723]: casting pointers to ints is unstable in const fn
+error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/min_const_fn.rs:98:63
|
LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
| ^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
+ = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
error[E0723]: mutable references in const fn are unstable
--> $DIR/min_const_fn.rs:101:14
error: aborting due to 30 previous errors
-Some errors have detailed explanations: E0493, E0723.
-For more information about an error, try `rustc --explain E0493`.
+Some errors have detailed explanations: E0013, E0493, E0658, E0723.
+For more information about an error, try `rustc --explain E0013`.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
-const fn bar() -> u32 { foo() } //~ ERROR can only call other `const fn`
+const fn bar() -> u32 { foo() } //~ ERROR not yet stable as a const fn
#[unstable(feature = "rust1", issue = "none")]
const fn foo2() -> u32 { 42 }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
-const fn bar2() -> u32 { foo2() } //~ ERROR can only call other `const fn`
+const fn bar2() -> u32 { foo2() } //~ ERROR not yet stable as a const fn
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// conformity is required, even with `const_fn` feature gate
-const fn bar3() -> u32 { (5f32 + 6f32) as u32 } //~ ERROR only int, `bool` and `char` operations
+const fn bar3() -> u32 { (5f32 + 6f32) as u32 }
+//~^ ERROR const-stable function cannot use `#[feature(const_fn)]`
// check whether this function cannot be called even with the feature gate active
#[unstable(feature = "foo2", issue = "none")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
-const fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR can only call other `const fn`
+const fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR not yet stable as a const fn
fn main() {}
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo` is not stable as `const fn`
+error: `foo` is not yet stable as a const fn
--> $DIR/min_const_fn_libstd_stability.rs:16:25
|
LL | const fn bar() -> u32 { foo() }
| ^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo2` is not stable as `const fn`
+error: `foo2` is not yet stable as a const fn
--> $DIR/min_const_fn_libstd_stability.rs:24:26
|
LL | const fn bar2() -> u32 { foo2() }
| ^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
-error[E0723]: only int, `bool` and `char` operations are stable in const fn
+error: const-stable function cannot use `#[feature(const_fn)]`
--> $DIR/min_const_fn_libstd_stability.rs:29:26
|
LL | const fn bar3() -> u32 { (5f32 + 6f32) as u32 }
| ^^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = note: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
+help: if it is not part of the public API, make this function unstably const
+ |
+LL | #[rustc_const_unstable(feature = "...", issue = "...")]
+ |
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo2_gated` is not stable as `const fn`
- --> $DIR/min_const_fn_libstd_stability.rs:38:32
+error: `foo2_gated` is not yet stable as a const fn
+ --> $DIR/min_const_fn_libstd_stability.rs:39:32
|
LL | const fn bar2_gated() -> u32 { foo2_gated() }
| ^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
error: aborting due to 4 previous errors
-For more information about this error, try `rustc --explain E0723`.
const unsafe fn no_union() {
union Foo { x: (), y: () }
Foo { x: () }.y
- //~^ accessing union fields is unstable
+ //~^ unions in const fn
}
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
-error[E0723]: accessing union fields is unstable
+error[E0658]: unions in const fn are unstable
--> $DIR/min_const_fn_unsafe_bad.rs:14:5
|
LL | Foo { x: () }.y
| ^^^^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = note: see issue #51909 <https://github.com/rust-lang/rust/issues/51909> for more information
+ = help: add `#![feature(const_fn_union)]` to the crate attributes to enable
error: aborting due to 4 previous errors
-Some errors have detailed explanations: E0658, E0723.
-For more information about an error, try `rustc --explain E0658`.
+For more information about this error, try `rustc --explain E0658`.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
-const unsafe fn bar() -> u32 { unsafe { foo() } } //~ ERROR can only call other `const fn`
+const unsafe fn bar() -> u32 { unsafe { foo() } } //~ ERROR not yet stable as a const fn
#[unstable(feature = "rust1", issue = "none")]
const unsafe fn foo2() -> u32 { 42 }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
-const unsafe fn bar2() -> u32 { unsafe { foo2() } } //~ ERROR can only call other `const fn`
+const unsafe fn bar2() -> u32 { unsafe { foo2() } } //~ ERROR not yet stable as a const fn
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// conformity is required, even with `const_fn` feature gate
-const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 } //~ ERROR only int, `bool` and `char` op
+const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 }
+//~^ ERROR const-stable function cannot use `#[feature(const_fn)]`
// check whether this function cannot be called even with the feature gate active
#[unstable(feature = "foo2", issue = "none")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
const unsafe fn bar2_gated() -> u32 { unsafe { foo2_gated() } }
-//~^ ERROR can only call other `const fn`
+//~^ ERROR not yet stable as a const fn
fn main() {}
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo` is not stable as `const fn`
+error: `foo` is not yet stable as a const fn
--> $DIR/min_const_unsafe_fn_libstd_stability.rs:16:41
|
LL | const unsafe fn bar() -> u32 { unsafe { foo() } }
| ^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo2` is not stable as `const fn`
+error: `foo2` is not yet stable as a const fn
--> $DIR/min_const_unsafe_fn_libstd_stability.rs:24:42
|
LL | const unsafe fn bar2() -> u32 { unsafe { foo2() } }
| ^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
-error[E0723]: only int, `bool` and `char` operations are stable in const fn
+error: const-stable function cannot use `#[feature(const_fn)]`
--> $DIR/min_const_unsafe_fn_libstd_stability.rs:29:33
|
LL | const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 }
| ^^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = note: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
+help: if it is not part of the public API, make this function unstably const
+ |
+LL | #[rustc_const_unstable(feature = "...", issue = "...")]
+ |
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo2_gated` is not stable as `const fn`
- --> $DIR/min_const_unsafe_fn_libstd_stability.rs:38:48
+error: `foo2_gated` is not yet stable as a const fn
+ --> $DIR/min_const_unsafe_fn_libstd_stability.rs:39:48
|
LL | const unsafe fn bar2_gated() -> u32 { unsafe { foo2_gated() } }
| ^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
error: aborting due to 4 previous errors
-For more information about this error, try `rustc --explain E0723`.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
-const unsafe fn bar() -> u32 { foo() } //~ ERROR can only call other `const fn`
+const unsafe fn bar() -> u32 { foo() } //~ ERROR not yet stable as a const fn
#[unstable(feature = "rust1", issue = "none")]
const fn foo2() -> u32 { 42 }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
-const unsafe fn bar2() -> u32 { foo2() } //~ ERROR can only call other `const fn`
+const unsafe fn bar2() -> u32 { foo2() } //~ ERROR not yet stable as a const fn
// check whether this function cannot be called even with the feature gate active
#[unstable(feature = "foo2", issue = "none")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
-const unsafe fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR can only call other `const fn`
+const unsafe fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR not yet stable as a const fn
fn main() {}
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo` is not stable as `const fn`
+error: `foo` is not yet stable as a const fn
--> $DIR/min_const_unsafe_fn_libstd_stability2.rs:16:32
|
LL | const unsafe fn bar() -> u32 { foo() }
| ^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo2` is not stable as `const fn`
+error: `foo2` is not yet stable as a const fn
--> $DIR/min_const_unsafe_fn_libstd_stability2.rs:24:33
|
LL | const unsafe fn bar2() -> u32 { foo2() }
| ^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
-error[E0723]: can only call other `const fn` within a `const fn`, but `foo2_gated` is not stable as `const fn`
+error: `foo2_gated` is not yet stable as a const fn
--> $DIR/min_const_unsafe_fn_libstd_stability2.rs:33:39
|
LL | const unsafe fn bar2_gated() -> u32 { foo2_gated() }
| ^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
error: aborting due to 3 previous errors
-For more information about this error, try `rustc --explain E0723`.
warning: skipping const checks
|
+help: skipping check for `const_fn` feature
+ --> $DIR/abi-mismatch.rs:9:23
+ |
+LL | const fn call_rust_fn(my_fn: extern "Rust" fn()) {
+ | ^^^^^
+help: skipping check for `const_fn` feature
+ --> $DIR/abi-mismatch.rs:10:5
+ |
+LL | my_fn();
+ | ^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/abi-mismatch.rs:10:5
|
pub const fn dangling_slice<T>() -> NonNull<[T]> {
NonNull::<[T; 0]>::dangling()
- //~^ ERROR: unsizing casts are only allowed for references right now
+ //~^ ERROR: unsizing casts to types besides slices
}
fn main() {}
-error[E0723]: unsizing casts are only allowed for references right now
+error[E0723]: unsizing casts to types besides slices are not allowed in const fn
--> $DIR/unsizing-cast-non-null.rs:6:5
|
LL | NonNull::<[T; 0]>::dangling()
#![stable(feature = "core", since = "1.6.0")]
#![feature(rustc_const_unstable)]
#![feature(staged_api)]
+#![feature(const_fn)]
enum Opt<T> {
Some(T),
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
- --> $DIR/unstable-const-fn-in-libcore.rs:23:26
+ --> $DIR/unstable-const-fn-in-libcore.rs:24:26
|
LL | Opt::None => f(),
| ^^^
error[E0493]: destructors cannot be evaluated at compile-time
- --> $DIR/unstable-const-fn-in-libcore.rs:18:53
+ --> $DIR/unstable-const-fn-in-libcore.rs:19:53
|
LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
| ^ constant functions cannot evaluate destructors
| - value is dropped here
error[E0493]: destructors cannot be evaluated at compile-time
- --> $DIR/unstable-const-fn-in-libcore.rs:18:47
+ --> $DIR/unstable-const-fn-in-libcore.rs:19:47
|
LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
| ^^^^ constant functions cannot evaluate destructors
extern "C" fn ff4() {} // OK.
const async unsafe extern "C" fn ff5() {} // OK.
//~^ ERROR functions cannot be both `const` and `async`
+ //~| ERROR `from_generator` is not yet stable as a const fn
trait X {
async fn ft1(); //~ ERROR functions in traits cannot be declared `async`
const async unsafe extern "C" fn ft5() {}
//~^ ERROR functions in traits cannot be declared `async`
//~| ERROR functions in traits cannot be declared const
+ //~| ERROR `from_generator` is not yet stable as a const fn
//~| ERROR method `ft5` has an incompatible type for trait
//~| ERROR functions cannot be both `const` and `async`
}
extern "C" fn fi4() {} // OK.
const async unsafe extern "C" fn fi5() {}
//~^ ERROR functions cannot be both `const` and `async`
+ //~| ERROR `from_generator` is not yet stable as a const fn
}
extern {
| `const` because of this
error[E0706]: functions in traits cannot be declared `async`
- --> $DIR/fn-header-semantic-fail.rs:17:9
+ --> $DIR/fn-header-semantic-fail.rs:18:9
|
LL | async fn ft1();
| -----^^^^^^^^^^
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0379]: functions in traits cannot be declared const
- --> $DIR/fn-header-semantic-fail.rs:19:9
+ --> $DIR/fn-header-semantic-fail.rs:20:9
|
LL | const fn ft3();
| ^^^^^ functions in traits cannot be const
error[E0379]: functions in traits cannot be declared const
- --> $DIR/fn-header-semantic-fail.rs:21:9
+ --> $DIR/fn-header-semantic-fail.rs:22:9
|
LL | const async unsafe extern "C" fn ft5();
| ^^^^^ functions in traits cannot be const
error[E0706]: functions in traits cannot be declared `async`
- --> $DIR/fn-header-semantic-fail.rs:21:9
+ --> $DIR/fn-header-semantic-fail.rs:22:9
|
LL | const async unsafe extern "C" fn ft5();
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: functions cannot be both `const` and `async`
- --> $DIR/fn-header-semantic-fail.rs:21:9
+ --> $DIR/fn-header-semantic-fail.rs:22:9
|
LL | const async unsafe extern "C" fn ft5();
| ^^^^^-^^^^^----------------------------
| `const` because of this
error[E0706]: functions in traits cannot be declared `async`
- --> $DIR/fn-header-semantic-fail.rs:29:9
+ --> $DIR/fn-header-semantic-fail.rs:30:9
|
LL | async fn ft1() {}
| -----^^^^^^^^^^^^
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0379]: functions in traits cannot be declared const
- --> $DIR/fn-header-semantic-fail.rs:32:9
+ --> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const fn ft3() {}
| ^^^^^ functions in traits cannot be const
error[E0379]: functions in traits cannot be declared const
- --> $DIR/fn-header-semantic-fail.rs:34:9
+ --> $DIR/fn-header-semantic-fail.rs:35:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^ functions in traits cannot be const
error[E0706]: functions in traits cannot be declared `async`
- --> $DIR/fn-header-semantic-fail.rs:34:9
+ --> $DIR/fn-header-semantic-fail.rs:35:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: functions cannot be both `const` and `async`
- --> $DIR/fn-header-semantic-fail.rs:34:9
+ --> $DIR/fn-header-semantic-fail.rs:35:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^-^^^^^------------------------------
| `const` because of this
error: functions cannot be both `const` and `async`
- --> $DIR/fn-header-semantic-fail.rs:46:9
+ --> $DIR/fn-header-semantic-fail.rs:48:9
|
LL | const async unsafe extern "C" fn fi5() {}
| ^^^^^-^^^^^------------------------------
| `const` because of this
error: functions in `extern` blocks cannot have qualifiers
- --> $DIR/fn-header-semantic-fail.rs:51:18
+ --> $DIR/fn-header-semantic-fail.rs:54:18
|
LL | extern {
| ------ in this `extern` block
| help: remove the qualifiers: `fn`
error: functions in `extern` blocks cannot have qualifiers
- --> $DIR/fn-header-semantic-fail.rs:52:19
+ --> $DIR/fn-header-semantic-fail.rs:55:19
|
LL | extern {
| ------ in this `extern` block
| help: remove the qualifiers: `fn`
error: functions in `extern` blocks cannot have qualifiers
- --> $DIR/fn-header-semantic-fail.rs:53:18
+ --> $DIR/fn-header-semantic-fail.rs:56:18
|
LL | extern {
| ------ in this `extern` block
| help: remove the qualifiers: `fn`
error: functions in `extern` blocks cannot have qualifiers
- --> $DIR/fn-header-semantic-fail.rs:54:23
+ --> $DIR/fn-header-semantic-fail.rs:57:23
|
LL | extern {
| ------ in this `extern` block
| help: remove the qualifiers: `fn`
error: functions in `extern` blocks cannot have qualifiers
- --> $DIR/fn-header-semantic-fail.rs:55:42
+ --> $DIR/fn-header-semantic-fail.rs:58:42
|
LL | extern {
| ------ in this `extern` block
| help: remove the qualifiers: `fn`
error: functions cannot be both `const` and `async`
- --> $DIR/fn-header-semantic-fail.rs:55:9
+ --> $DIR/fn-header-semantic-fail.rs:58:9
|
LL | const async unsafe extern "C" fn fe5();
| ^^^^^-^^^^^----------------------------
| | `async` because of this
| `const` because of this
+error: `from_generator` is not yet stable as a const fn
+ --> $DIR/fn-header-semantic-fail.rs:13:44
+ |
+LL | const async unsafe extern "C" fn ff5() {} // OK.
+ | ^^
+ |
+ = help: add `#![feature(gen_future)]` to the crate attributes to enable
+
error[E0053]: method `ft1` has an incompatible type for trait
- --> $DIR/fn-header-semantic-fail.rs:29:24
+ --> $DIR/fn-header-semantic-fail.rs:30:24
|
LL | async fn ft1();
| - type in trait
found fn pointer `fn() -> impl Future`
error[E0053]: method `ft5` has an incompatible type for trait
- --> $DIR/fn-header-semantic-fail.rs:34:48
+ --> $DIR/fn-header-semantic-fail.rs:35:48
|
LL | const async unsafe extern "C" fn ft5();
| - type in trait
= note: expected fn pointer `unsafe extern "C" fn()`
found fn pointer `unsafe extern "C" fn() -> impl Future`
-error: aborting due to 20 previous errors
+error: `from_generator` is not yet stable as a const fn
+ --> $DIR/fn-header-semantic-fail.rs:35:48
+ |
+LL | const async unsafe extern "C" fn ft5() {}
+ | ^^
+ |
+ = help: add `#![feature(gen_future)]` to the crate attributes to enable
+
+error: `from_generator` is not yet stable as a const fn
+ --> $DIR/fn-header-semantic-fail.rs:48:48
+ |
+LL | const async unsafe extern "C" fn fi5() {}
+ | ^^
+ |
+ = help: add `#![feature(gen_future)]` to the crate attributes to enable
+
+error: aborting due to 23 previous errors
Some errors have detailed explanations: E0053, E0379, E0706.
For more information about an error, try `rustc --explain E0053`.
impl const T for S {
fn foo() { non_const() }
- //~^ ERROR can only call other `const fn`
+ //~^ ERROR calls in constant functions
}
fn main() {}
-error[E0723]: can only call other `const fn` within a `const fn`, but `non_const` is not stable as `const fn`
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/const-check-fns-in-const-impl.rs:12:16
|
LL | fn foo() { non_const() }
| ^^^^^^^^^^^
- |
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0723`.
+For more information about this error, try `rustc --explain E0015`.
error: fatal error triggered by #[rustc_error]
- --> $DIR/feature-gate.rs:16:1
+ --> $DIR/feature-gate.rs:17:1
|
LL | fn main() {}
| ^^^^^^^^^
#![cfg_attr(gated, feature(const_trait_bound_opt_out))]
#![allow(incomplete_features)]
#![feature(rustc_attrs)]
+#![feature(const_fn)]
trait T {
const CONST: i32;
error[E0658]: `?const` on trait bounds is experimental
- --> $DIR/feature-gate.rs:12:29
+ --> $DIR/feature-gate.rs:13:29
|
LL | const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST }
| ^^^^^^
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
pub const fn foo() -> Int {
Int(1i32) + Int(2i32)
- //~^ ERROR can only call other `const fn` within a `const fn`
+ //~^ ERROR not yet stable as a const fn
}
// ok
LL | | Int(self.0 - rhs.0)
LL | | }
| |_____^
- |
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
-error[E0723]: can only call other `const fn` within a `const fn`, but `<Int as Add>::add` is not stable as `const fn`
+error: `<Int as Add>::add` is not yet stable as a const fn
--> $DIR/stability.rs:32:5
|
LL | Int(1i32) + Int(2i32)
| ^^^^^^^^^^^^^^^^^^^^^
|
- = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
- = help: add `#![feature(const_fn)]` to the crate attributes to enable
+ = help: Const-stable functions can only call other const-stable functions
error: aborting due to 2 previous errors
const fn foo() -> NonZero<u32> {
let mut x = unsafe { NonZero(1) };
- let y = &mut x.0; //~ ERROR references in const fn are unstable
+ let y = &mut x.0; //~ ERROR mutable references
//~^ ERROR mutation of layout constrained field is unsafe
unsafe { NonZero(1) }
}
const fn bar() -> NonZero<u32> {
let mut x = unsafe { NonZero(1) };
- let y = unsafe { &mut x.0 }; //~ ERROR mutable references in const fn are unstable
+ let y = unsafe { &mut x.0 }; //~ ERROR mutable references
unsafe { NonZero(1) }
}