1
Fork 0

bless you

This commit is contained in:
Deadbeef 2021-12-10 01:10:05 +08:00
parent f7f0f843b7
commit b5235ea732
No known key found for this signature in database
GPG key ID: 6D017A96D8E6C2F9
60 changed files with 200 additions and 87 deletions

View file

@ -2,7 +2,7 @@ struct Project;
struct Value; struct Value;
static settings_dir: String = format!(""); static settings_dir: String = format!("");
//~^ ERROR calls in statics are limited to constant functions //~^ ERROR cannot call non-const fn
//~| ERROR is not yet stable as a const //~| ERROR is not yet stable as a const
fn from_string(_: String) -> Value { fn from_string(_: String) -> Value {

View file

@ -7,12 +7,13 @@ LL | static settings_dir: String = format!("");
= help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable = help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable
= note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `format` in statics
--> $DIR/issue-64453.rs:4:31 --> $DIR/issue-64453.rs:4:31
| |
LL | static settings_dir: String = format!(""); LL | static settings_dir: String = format!("");
| ^^^^^^^^^^^ | ^^^^^^^^^^^
| |
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0507]: cannot move out of static item `settings_dir` error[E0507]: cannot move out of static item `settings_dir`

View file

@ -87,7 +87,7 @@ static mut STATIC13: SafeStruct = SafeStruct{field1: SafeEnum::Variant1,
static mut STATIC14: SafeStruct = SafeStruct { static mut STATIC14: SafeStruct = SafeStruct {
field1: SafeEnum::Variant1, field1: SafeEnum::Variant1,
field2: SafeEnum::Variant4("str".to_string()) field2: SafeEnum::Variant4("str".to_string())
//~^ ERROR calls in statics are limited to constant functions //~^ ERROR cannot call non-const fn
}; };
static STATIC15: &'static [Box<MyOwned>] = &[ static STATIC15: &'static [Box<MyOwned>] = &[

View file

@ -15,11 +15,13 @@ error[E0010]: allocations are not allowed in statics
LL | static STATIC11: Box<MyOwned> = box MyOwned; LL | static STATIC11: Box<MyOwned> = box MyOwned;
| ^^^^^^^^^^^ allocation not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<str as ToString>::to_string` in statics
--> $DIR/check-static-values-constraints.rs:89:32 --> $DIR/check-static-values-constraints.rs:89:38
| |
LL | field2: SafeEnum::Variant4("str".to_string()) LL | field2: SafeEnum::Variant4("str".to_string())
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
error[E0010]: allocations are not allowed in statics error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:94:5 --> $DIR/check-static-values-constraints.rs:94:5

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17_usize>::value` in constants
--> $DIR/nested-type.rs:15:5 --> $DIR/nested-type.rs:15:5
| |
LL | Foo::<17>::value() LL | Foo::<17>::value()
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -14,11 +14,13 @@ LL | | }]>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#![feature(adt_const_params)]` = help: more complex types are supported with `#![feature(adt_const_params)]`
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17_usize>::value` in constants
--> $DIR/nested-type.rs:15:5 --> $DIR/nested-type.rs:15:5
| |
LL | Foo::<17>::value() LL | Foo::<17>::value()
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -13,7 +13,7 @@ struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden
} }
Foo::<17>::value() Foo::<17>::value()
//~^ ERROR calls in constants are limited to constant functions //~^ ERROR cannot call non-const fn
}]>; }]>;
fn main() {} fn main() {}

View file

@ -4,5 +4,5 @@ fn f(x: usize) -> usize {
fn main() { fn main() {
let _ = [0; f(2)]; let _ = [0; f(2)];
//~^ ERROR calls in constants are limited to constant functions //~^ ERROR cannot call non-const fn
} }

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `f` in constants
--> $DIR/const-call.rs:6:17 --> $DIR/const-call.rs:6:17
| |
LL | let _ = [0; f(2)]; LL | let _ = [0; f(2)];
| ^^^^ | ^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ extern "C" {
const extern "C" fn bar() { const extern "C" fn bar() {
unsafe { unsafe {
regular_in_block(); regular_in_block();
//~^ ERROR: calls in constant functions //~^ ERROR: cannot call non-const fn
} }
} }
@ -16,7 +16,7 @@ extern "C" fn regular() {}
const extern "C" fn foo() { const extern "C" fn foo() {
unsafe { unsafe {
regular(); regular();
//~^ ERROR: calls in constant functions //~^ ERROR: cannot call non-const fn
} }
} }

View file

@ -1,14 +1,18 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `regular_in_block` in constant functions
--> $DIR/const-extern-fn-call-extern-fn.rs:9:9 --> $DIR/const-extern-fn-call-extern-fn.rs:9:9
| |
LL | regular_in_block(); LL | regular_in_block();
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `regular` in constant functions
--> $DIR/const-extern-fn-call-extern-fn.rs:18:9 --> $DIR/const-extern-fn-call-extern-fn.rs:18:9
| |
LL | regular(); LL | regular();
| ^^^^^^^^^ | ^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -4,8 +4,9 @@ const fn f(x: usize) -> usize {
let mut sum = 0; let mut sum = 0;
for i in 0..x { for i in 0..x {
//~^ ERROR mutable references //~^ ERROR mutable references
//~| ERROR calls in constant functions //~| ERROR cannot convert
//~| ERROR calls in constant functions //~| ERROR cannot call non-const fn
//~| ERROR E0080
//~| ERROR `for` is not allowed in a `const fn` //~| ERROR `for` is not allowed in a `const fn`
sum += i; sum += i;
} }

View file

@ -13,11 +13,18 @@ LL | | }
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information = note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
= help: add `#![feature(const_for)]` to the crate attributes to enable = help: add `#![feature(const_for)]` to the crate attributes to enable
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot convert `std::ops::Range<usize>` into an iterator in constant functions
--> $DIR/const-fn-error.rs:5:14 --> $DIR/const-fn-error.rs:5:14
| |
LL | for i in 0..x { LL | for i in 0..x {
| ^^^^ | ^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
LL | impl<I: Iterator> IntoIterator for I {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error[E0658]: mutable references are not allowed in constant functions error[E0658]: mutable references are not allowed in constant functions
--> $DIR/const-fn-error.rs:5:14 --> $DIR/const-fn-error.rs:5:14
@ -28,11 +35,13 @@ LL | for i in 0..x {
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions
--> $DIR/const-fn-error.rs:5:14 --> $DIR/const-fn-error.rs:5:14
| |
LL | for i in 0..x { LL | for i in 0..x {
| ^^^^ | ^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `random` in constant functions
--> $DIR/const-fn-not-safe-for-const.rs:14:5 --> $DIR/const-fn-not-safe-for-const.rs:14:5
| |
LL | random() LL | random()
| ^^^^^^^^ | ^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error[E0013]: constant functions cannot refer to statics error[E0013]: constant functions cannot refer to statics
--> $DIR/const-fn-not-safe-for-const.rs:20:5 --> $DIR/const-fn-not-safe-for-const.rs:20:5

View file

@ -3,8 +3,8 @@
const _: () = { const _: () = {
for _ in 0..5 {} for _ in 0..5 {}
//~^ error: calls in constants are limited to //~^ error: cannot convert
//~| error: calls in constants are limited to //~| error: cannot call non-const fn
}; };
fn main() {} fn main() {}

View file

@ -1,14 +1,23 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
--> $DIR/const-for.rs:5:14 --> $DIR/const-for.rs:5:14
| |
LL | for _ in 0..5 {} LL | for _ in 0..5 {}
| ^^^^ | ^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
LL | impl<I: Iterator> IntoIterator for I {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
--> $DIR/const-for.rs:5:14 --> $DIR/const-for.rs:5:14
| |
LL | for _ in 0..5 {} LL | for _ in 0..5 {}
| ^^^^ | ^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -8,7 +8,7 @@ fn non_const() -> Thing {
} }
pub const Q: i32 = match non_const() { pub const Q: i32 = match non_const() {
//~^ ERROR calls in constants are limited to constant functions //~^ ERROR cannot call non-const fn
Thing::This => 1, Thing::This => 1,
Thing::That => 0 Thing::That => 0
}; };

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `non_const` in constants
--> $DIR/issue-46843.rs:10:26 --> $DIR/issue-46843.rs:10:26
| |
LL | pub const Q: i32 = match non_const() { LL | pub const Q: i32 = match non_const() {
| ^^^^^^^^^^^ | ^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -11,7 +11,7 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
} }
unsafe { copy(src, dst, count) } unsafe { copy(src, dst, count) }
//~^ ERROR calls in constant functions are limited to constant functions //~^ ERROR cannot call non-const fn
} }
fn main() {} fn main() {}

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `copy::copy::<T>` in constant functions
--> $DIR/intrinsic_without_const_stab.rs:13:14 --> $DIR/intrinsic_without_const_stab.rs:13:14
| |
LL | unsafe { copy(src, dst, count) } LL | unsafe { copy(src, dst, count) }
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -9,7 +9,7 @@ extern "rust-intrinsic" {
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
#[inline] #[inline]
pub const unsafe fn stuff<T>(src: *const T, dst: *mut T, count: usize) { pub const unsafe fn stuff<T>(src: *const T, dst: *mut T, count: usize) {
unsafe { copy(src, dst, count) } //~ ERROR calls in constant functions are limited unsafe { copy(src, dst, count) } //~ ERROR cannot call non-const fn
} }
fn main() {} fn main() {}

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `copy::<T>` in constant functions
--> $DIR/intrinsic_without_const_stab_fail.rs:12:14 --> $DIR/intrinsic_without_const_stab_fail.rs:12:14
| |
LL | unsafe { copy(src, dst, count) } LL | unsafe { copy(src, dst, count) }
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,7 +2,7 @@
const X: u8 = const X: u8 =
|| -> u8 { 5 }() || -> u8 { 5 }()
//~^ ERROR calls in constants are limited to constant functions //~^ ERROR cannot call non-const fn
; ;
fn main() {} fn main() {}

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<[closure@$DIR/issue-28113.rs:4:5: 4:19] as Fn<()>>::call` in constants
--> $DIR/issue-28113.rs:4:5 --> $DIR/issue-28113.rs:4:5
| |
LL | || -> u8 { 5 }() LL | || -> u8 { 5 }()
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -8,7 +8,7 @@ const bad : u32 = {
const bad_two : u32 = { const bad_two : u32 = {
{ {
invalid(); invalid();
//~^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants //~^ ERROR: cannot call non-const fn `invalid`
0 0
} }
}; };
@ -30,7 +30,7 @@ static bad_four : u32 = {
static bad_five : u32 = { static bad_five : u32 = {
{ {
invalid(); invalid();
//~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants //~^ ERROR: cannot call non-const fn `invalid`
0 0
} }
}; };
@ -52,7 +52,7 @@ static mut bad_seven : u32 = {
static mut bad_eight : u32 = { static mut bad_eight : u32 = {
{ {
invalid(); invalid();
//~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants //~^ ERROR: cannot call non-const fn `invalid`
0 0
} }
}; };

View file

@ -1,20 +1,26 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `invalid` in constants
--> $DIR/issue-32829-2.rs:10:9 --> $DIR/issue-32829-2.rs:10:9
| |
LL | invalid(); LL | invalid();
| ^^^^^^^^^ | ^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `invalid` in statics
--> $DIR/issue-32829-2.rs:32:9 --> $DIR/issue-32829-2.rs:32:9
| |
LL | invalid(); LL | invalid();
| ^^^^^^^^^ | ^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `invalid` in statics
--> $DIR/issue-32829-2.rs:54:9 --> $DIR/issue-32829-2.rs:54:9
| |
LL | invalid(); LL | invalid();
| ^^^^^^^^^ | ^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -1,7 +1,7 @@
fn xyz() -> u8 { 42 } fn xyz() -> u8 { 42 }
const NUM: u8 = xyz(); const NUM: u8 = xyz();
//~^ ERROR calls in constants are limited to constant functions, tuple structs and tuple variants //~^ ERROR cannot call non-const fn
fn main() { fn main() {
match 1 { match 1 {

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `xyz` in constants
--> $DIR/issue-43105.rs:3:17 --> $DIR/issue-43105.rs:3:17
| |
LL | const NUM: u8 = xyz(); LL | const NUM: u8 = xyz();
| ^^^^^ | ^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: could not evaluate constant pattern error: could not evaluate constant pattern
--> $DIR/issue-43105.rs:8:9 --> $DIR/issue-43105.rs:8:9

View file

@ -1,7 +1,7 @@
#![feature(const_fn_fn_ptr_basics)] #![feature(const_fn_fn_ptr_basics)]
const fn foo() { (||{})() } const fn foo() { (||{})() }
//~^ ERROR calls in constant functions //~^ ERROR cannot call non-const fn
const fn bad(input: fn()) { const fn bad(input: fn()) {
input() input()

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<[closure@$DIR/issue-56164.rs:3:18: 3:24] as Fn<()>>::call` in constant functions
--> $DIR/issue-56164.rs:3:18 --> $DIR/issue-56164.rs:3:18
| |
LL | const fn foo() { (||{})() } LL | const fn foo() { (||{})() }
| ^^^^^^^^ | ^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: function pointers are not allowed in const fn error: function pointers are not allowed in const fn
--> $DIR/issue-56164.rs:7:5 --> $DIR/issue-56164.rs:7:5

View file

@ -3,7 +3,7 @@
// in the length part of an array. // in the length part of an array.
struct Bug { struct Bug {
a: [(); (|| { 0 })()] //~ ERROR calls in constants are limited to a: [(); (|| { 0 })()] //~ ERROR cannot call non-const fn
} }
fn main() {} fn main() {}

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<[closure@$DIR/issue-68542-closure-in-array-len.rs:6:13: 6:23] as Fn<()>>::call` in constants
--> $DIR/issue-68542-closure-in-array-len.rs:6:13 --> $DIR/issue-68542-closure-in-array-len.rs:6:13
| |
LL | a: [(); (|| { 0 })()] LL | a: [(); (|| { 0 })()]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,7 +1,7 @@
const fn foo(a: i32) -> Vec<i32> { const fn foo(a: i32) -> Vec<i32> {
vec![1, 2, 3] vec![1, 2, 3]
//~^ ERROR allocations are not allowed //~^ ERROR allocations are not allowed
//~| ERROR calls in constant functions //~| ERROR cannot call non-const fn
} }
fn main() {} fn main() {}

View file

@ -6,12 +6,13 @@ LL | vec![1, 2, 3]
| |
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `vec` (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 error[E0015]: cannot call non-const fn `slice::<impl [i32]>::into_vec::<std::alloc::Global>` in constant functions
--> $DIR/bad_const_fn_body_ice.rs:2:5 --> $DIR/bad_const_fn_body_ice.rs:2:5
| |
LL | vec![1, 2, 3] LL | vec![1, 2, 3]
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
| |
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -6,6 +6,6 @@ fn bar() -> Foo {
} }
static foo: Foo = bar(); static foo: Foo = bar();
//~^ ERROR calls in statics are limited to constant functions, tuple structs and tuple variants //~^ ERROR cannot call non-const fn
fn main() {} fn main() {}

View file

@ -1,8 +1,10 @@
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `bar` in statics
--> $DIR/mir_check_nonconst.rs:8:19 --> $DIR/mir_check_nonconst.rs:8:19
| |
LL | static foo: Foo = bar(); LL | static foo: Foo = bar();
| ^^^^^ | ^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<F as FnOnce<()>>::call_once` in constant functions
--> $DIR/unstable-const-fn-in-libcore.rs:24:26 --> $DIR/unstable-const-fn-in-libcore.rs:24:26
| |
LL | Opt::None => f(), LL | Opt::None => f(),
| ^^^ | ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/unstable-const-fn-in-libcore.rs:19:53 --> $DIR/unstable-const-fn-in-libcore.rs:19:53

View file

@ -1,8 +1,10 @@
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `Y::foo` in statics
--> $DIR/issue-16538.rs:15:23 --> $DIR/issue-16538.rs:15:23
| |
LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
error[E0133]: use of extern static is unsafe and requires unsafe function or block error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-16538.rs:15:30 --> $DIR/issue-16538.rs:15:30

View file

@ -14,11 +14,13 @@ LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
| |
= note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `Y::foo` in statics
--> $DIR/issue-16538.rs:15:23 --> $DIR/issue-16538.rs:15:23
| |
LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -2,7 +2,7 @@ struct A;
struct B; struct B;
static S: &'static B = &A; static S: &'static B = &A;
//~^ ERROR calls in statics are limited to constant functions //~^ ERROR cannot perform deref coercion on `A` in statics
use std::ops::Deref; use std::ops::Deref;

View file

@ -1,8 +1,21 @@
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot perform deref coercion on `A` in statics
--> $DIR/issue-25901.rs:4:24 --> $DIR/issue-25901.rs:4:24
| |
LL | static S: &'static B = &A; LL | static S: &'static B = &A;
| ^^ | ^^
|
= note: attempting to deref into `B`
note: deref defined here
--> $DIR/issue-25901.rs:10:5
|
LL | type Target = B;
| ^^^^^^^^^^^^^^^^
note: impl defined here, but it is not `const`
--> $DIR/issue-25901.rs:9:1
|
LL | impl Deref for A {
| ^^^^^^^^^^^^^^^^
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,14 +1,18 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<Dim3 as Dim>::dim` in constants
--> $DIR/issue-39559-2.rs:14:24 --> $DIR/issue-39559-2.rs:14:24
| |
LL | let array: [usize; Dim3::dim()] LL | let array: [usize; Dim3::dim()]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<Dim3 as Dim>::dim` in constants
--> $DIR/issue-39559-2.rs:16:15 --> $DIR/issue-39559-2.rs:16:15
| |
LL | = [0; Dim3::dim()]; LL | = [0; Dim3::dim()];
| ^^^^^^^^^^^ | ^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -8,7 +8,7 @@ fn main() {
[(); { for _ in 0usize.. {}; 0}]; [(); { for _ in 0usize.. {}; 0}];
//~^ ERROR `for` is not allowed in a `const` //~^ ERROR `for` is not allowed in a `const`
//~| ERROR calls in constants are limited to constant functions //~| ERROR cannot convert
//~| ERROR mutable references are not allowed in constants //~| ERROR mutable references are not allowed in constants
//~| ERROR calls in constants are limited to constant functions //~| ERROR cannot call non-const fn
} }

View file

@ -38,11 +38,18 @@ LL | [(); loop { break }];
| expected `usize`, found `()` | expected `usize`, found `()`
| help: give it a value of the expected type: `break 42` | help: give it a value of the expected type: `break 42`
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot convert `RangeFrom<usize>` into an iterator in constants
--> $DIR/issue-52443.rs:9:21 --> $DIR/issue-52443.rs:9:21
| |
LL | [(); { for _ in 0usize.. {}; 0}]; LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^ | ^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
LL | impl<I: Iterator> IntoIterator for I {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error[E0658]: mutable references are not allowed in constants error[E0658]: mutable references are not allowed in constants
--> $DIR/issue-52443.rs:9:21 --> $DIR/issue-52443.rs:9:21
@ -53,11 +60,13 @@ LL | [(); { for _ in 0usize.. {}; 0}];
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<RangeFrom<usize> as Iterator>::next` in constants
--> $DIR/issue-52443.rs:9:21 --> $DIR/issue-52443.rs:9:21
| |
LL | [(); { for _ in 0usize.. {}; 0}]; LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^ | ^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to 6 previous errors; 1 warning emitted error: aborting due to 6 previous errors; 1 warning emitted

View file

@ -22,7 +22,7 @@ pub const fn add_i32(a: i32, b: i32) -> i32 {
pub const fn add_u32(a: u32, b: u32) -> u32 { pub const fn add_u32(a: u32, b: u32) -> u32 {
a.plus(b) a.plus(b)
//~^ ERROR calls in constant functions are limited to constant functions //~^ ERROR cannot call non-const fn
} }
fn main() {} fn main() {}

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<u32 as Plus>::plus` in constant functions
--> $DIR/call-const-trait-method-fail.rs:24:5 --> $DIR/call-const-trait-method-fail.rs:24:7
| |
LL | a.plus(b) LL | a.plus(b)
| ^^^^^^^^^ | ^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -3,7 +3,7 @@
pub const fn equals_self<T: PartialEq>(t: &T) -> bool { pub const fn equals_self<T: PartialEq>(t: &T) -> bool {
*t == *t *t == *t
//~^ ERROR calls in constant functions are limited to constant functions //~^ ERROR cannot call non-const operator
} }
fn main() {} fn main() {}

View file

@ -1,8 +1,14 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const operator in constant functions
--> $DIR/call-generic-method-fail.rs:5:5 --> $DIR/call-generic-method-fail.rs:5:5
| |
LL | *t == *t LL | *t == *t
| ^^^^^^^^ | ^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: consider further restricting this bound
|
LL | pub const fn equals_self<T: PartialEq + ~const std::cmp::PartialEq>(t: &T) -> bool {
| ++++++++++++++++++++++++++++
error: aborting due to previous error error: aborting due to previous error

View file

@ -9,7 +9,7 @@ fn non_const() {}
impl const T for S { impl const T for S {
fn foo() { non_const() } fn foo() { non_const() }
//~^ ERROR calls in constant functions //~^ ERROR cannot call non-const fn
} }
fn main() {} fn main() {}

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `non_const` in constant functions
--> $DIR/const-check-fns-in-const-impl.rs:11:16 --> $DIR/const-check-fns-in-const-impl.rs:11:16
| |
LL | fn foo() { non_const() } LL | fn foo() { non_const() }
| ^^^^^^^^^^^ | ^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -23,7 +23,7 @@ impl const ConstDefaultFn for ConstImpl {
const fn test() { const fn test() {
NonConstImpl.a(); NonConstImpl.a();
//~^ ERROR calls in constant functions are limited to constant functions, tuple structs and tuple variants //~^ ERROR cannot call non-const fn
ConstImpl.a(); ConstImpl.a();
} }

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<NonConstImpl as ConstDefaultFn>::a` in constant functions
--> $DIR/const-default-method-bodies.rs:25:5 --> $DIR/const-default-method-bodies.rs:25:18
| |
LL | NonConstImpl.a(); LL | NonConstImpl.a();
| ^^^^^^^^^^^^^^^^ | ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<cross_crate::NonConst as cross_crate::MyTrait>::func` in constant functions
--> $DIR/cross-crate.rs:15:5 --> $DIR/cross-crate.rs:15:14
| |
LL | NonConst.func(); LL | NonConst.func();
| ^^^^^^^^^^^^^^^ | ^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -13,9 +13,9 @@ fn non_const_context() {
const fn const_context() { const fn const_context() {
NonConst.func(); NonConst.func();
//~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants //~^ ERROR: cannot call non-const fn
Const.func(); Const.func();
//[stock]~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants //[stock]~^ ERROR: cannot call non-const fn
} }
fn main() {} fn main() {}

View file

@ -1,14 +1,18 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<cross_crate::NonConst as cross_crate::MyTrait>::func` in constant functions
--> $DIR/cross-crate.rs:15:5 --> $DIR/cross-crate.rs:15:14
| |
LL | NonConst.func(); LL | NonConst.func();
| ^^^^^^^^^^^^^^^ | ^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<cross_crate::Const as cross_crate::MyTrait>::func` in constant functions
--> $DIR/cross-crate.rs:17:5 --> $DIR/cross-crate.rs:17:11
| |
LL | Const.func(); LL | Const.func();
| ^^^^^^^^^^^^ | ^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -7,7 +7,7 @@ pub trait A {
pub const fn foo<T: A>() -> bool { pub const fn foo<T: A>() -> bool {
T::assoc() T::assoc()
//~^ ERROR calls in constant functions are limited //~^ ERROR cannot call non-const fn
} }
fn main() {} fn main() {}

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<T as A>::assoc` in constant functions
--> $DIR/issue-88155.rs:9:5 --> $DIR/issue-88155.rs:9:5
| |
LL | T::assoc() LL | T::assoc()
| ^^^^^^^^^^ | ^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -11,7 +11,7 @@ fn non_const_context() -> Vec<usize> {
const fn const_context() -> Vec<usize> { const fn const_context() -> Vec<usize> {
Default::default() Default::default()
//[stock]~^ ERROR calls in constant functions are limited //[stock]~^ ERROR cannot call non-const fn
} }
fn main() { fn main() {

View file

@ -1,8 +1,10 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `<Vec<usize> as Default>::default` in constant functions
--> $DIR/std-impl-gate.rs:13:5 --> $DIR/std-impl-gate.rs:13:5
| |
LL | Default::default() LL | Default::default()
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,8 +1,10 @@
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `foo` in statics
--> $DIR/static-vec-repeat-not-constant.rs:3:25 --> $DIR/static-vec-repeat-not-constant.rs:3:25
| |
LL | static a: [isize; 2] = [foo(); 2]; LL | static a: [isize; 2] = [foo(); 2];
| ^^^^^ | ^^^^^
|
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error error: aborting due to previous error