Bless tests

This commit is contained in:
Dylan MacKenzie 2020-09-17 10:32:07 -07:00
parent 3569bb6323
commit ef6d4277ed
35 changed files with 200 additions and 159 deletions

View File

@ -7,7 +7,7 @@ extern "C" {
const extern fn bar() {
unsafe {
regular_in_block();
//~^ ERROR: can only call other `const fn` within a `const fn`
//~^ ERROR: calls in constant functions
}
}
@ -16,7 +16,7 @@ extern fn regular() {}
const extern fn foo() {
unsafe {
regular();
//~^ ERROR: can only call other `const fn` within a `const fn`
//~^ ERROR: calls in constant functions
}
}

View File

@ -1,21 +1,15 @@
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`.

View File

@ -6,7 +6,7 @@ const unsafe extern "C" fn closure() -> fn() { || {} }
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() {}

View File

@ -16,15 +16,16 @@ LL | const unsafe extern fn use_float() { 1.0 + 1.0; }
= 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`.

View File

@ -1,6 +1,6 @@
// 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;

View File

@ -2,6 +2,7 @@ fn main() {
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
}

View File

@ -6,8 +6,8 @@ struct S {
impl S {
const fn foo(&mut self, x: u32) {
//~^ ERROR mutable references
self.state = x;
//~^ contains unimplemented expression
}
}

View File

@ -1,10 +1,11 @@
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
@ -28,5 +29,5 @@ LL | *y = 42;
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`.

View File

@ -1,5 +1,8 @@
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() {}

View File

@ -1,13 +1,29 @@
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]
| ^^^^^^^^^^^^^
|
= 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: 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: aborting due to previous error
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: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0723`.
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0010, E0015, E0019.
For more information about an error, try `rustc --explain E0010`.

View File

@ -78,25 +78,25 @@ const fn foo11<T: std::fmt::Display>(t: T) -> T { t }
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

View File

@ -94,7 +94,7 @@ LL | const fn foo19_2(f: f32) -> f32 { 2.0 - 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]: 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 }
@ -112,59 +112,57 @@ LL | const fn foo19_4(f: f32, g: f32) -> f32 { f / g }
= 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
@ -267,5 +265,5 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
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`.

View File

@ -13,7 +13,7 @@ const fn foo() -> 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 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 }
@ -21,12 +21,13 @@ 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")]
@ -35,6 +36,6 @@ const fn foo2_gated() -> 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_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() {}

View File

@ -1,39 +1,38 @@
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`.

View File

@ -12,5 +12,5 @@ fn main() {}
const unsafe fn no_union() {
union Foo { x: (), y: () }
Foo { x: () }.y
//~^ accessing union fields is unstable
//~^ unions in const fn
}

View File

@ -25,16 +25,15 @@ LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static u
= 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`.

View File

@ -13,7 +13,7 @@ const unsafe fn foo() -> 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 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 }
@ -21,12 +21,13 @@ 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")]
@ -36,6 +37,6 @@ const unsafe fn foo2_gated() -> u32 { 42 }
#[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() {}

View File

@ -1,39 +1,38 @@
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`.

View File

@ -13,7 +13,7 @@ const fn foo() -> 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 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 }
@ -21,7 +21,7 @@ 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")]
@ -30,6 +30,6 @@ const fn foo2_gated() -> 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_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() {}

View File

@ -1,30 +1,26 @@
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`.

View File

@ -12,6 +12,16 @@ LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "
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
|

View File

@ -4,7 +4,7 @@ use std::ptr::NonNull;
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() {}

View File

@ -1,4 +1,4 @@
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()

View File

@ -6,6 +6,7 @@
#![stable(feature = "core", since = "1.6.0")]
#![feature(rustc_const_unstable)]
#![feature(staged_api)]
#![feature(const_fn)]
enum Opt<T> {
Some(T),

View File

@ -1,11 +1,11 @@
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
@ -14,7 +14,7 @@ LL | }
| - 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

View File

@ -12,6 +12,7 @@ fn main() {
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`
@ -34,6 +35,7 @@ fn main() {
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`
}
@ -45,6 +47,7 @@ fn main() {
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 {

View File

@ -8,7 +8,7 @@ LL | const async unsafe extern "C" fn ff5() {} // OK.
| `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();
| -----^^^^^^^^^^
@ -19,19 +19,19 @@ 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();
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -42,7 +42,7 @@ 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();
| ^^^^^-^^^^^----------------------------
@ -51,7 +51,7 @@ 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() {}
| -----^^^^^^^^^^^^
@ -62,19 +62,19 @@ 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() {}
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -85,7 +85,7 @@ 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() {}
| ^^^^^-^^^^^------------------------------
@ -94,7 +94,7 @@ 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() {}
| ^^^^^-^^^^^------------------------------
@ -103,7 +103,7 @@ 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
@ -113,7 +113,7 @@ LL | async fn fe1();
| 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
@ -124,7 +124,7 @@ LL | unsafe fn fe2();
| 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
@ -135,7 +135,7 @@ LL | const fn fe3();
| 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
@ -146,7 +146,7 @@ LL | extern "C" fn fe4();
| 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
@ -157,7 +157,7 @@ LL | const async unsafe extern "C" fn fe5();
| 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();
| ^^^^^-^^^^^----------------------------
@ -165,8 +165,16 @@ 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
@ -181,7 +189,7 @@ LL | async fn ft1() {}
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
@ -195,7 +203,23 @@ LL | const async unsafe extern "C" fn ft5() {}
= 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`.

View File

@ -10,7 +10,7 @@ fn non_const() {}
impl const T for S {
fn foo() { non_const() }
//~^ ERROR can only call other `const fn`
//~^ ERROR calls in constant functions
}
fn main() {}

View File

@ -1,12 +1,9 @@
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`.

View File

@ -1,5 +1,5 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/feature-gate.rs:16:1
--> $DIR/feature-gate.rs:17:1
|
LL | fn main() {}
| ^^^^^^^^^

View File

@ -4,6 +4,7 @@
#![cfg_attr(gated, feature(const_trait_bound_opt_out))]
#![allow(incomplete_features)]
#![feature(rustc_attrs)]
#![feature(const_fn)]
trait T {
const CONST: i32;

View File

@ -1,5 +1,5 @@
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 }
| ^^^^^^

View File

@ -30,7 +30,7 @@ impl const std::ops::Add for Int {
#[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

View File

@ -6,18 +6,14 @@ LL | |
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

View File

@ -8,13 +8,13 @@ fn main() {
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) }
}