Skip to content

Commit de2123a

Browse files
committed
bless you
1 parent 75fdc8a commit de2123a

File tree

60 files changed

+199
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+199
-87
lines changed

src/test/ui/borrowck/issue-64453.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ struct Project;
22
struct Value;
33

44
static settings_dir: String = format!("");
5-
//~^ ERROR calls in statics are limited to constant functions
5+
//~^ ERROR cannot call non-const fn
66
//~| ERROR is not yet stable as a const
77

88
fn from_string(_: String) -> Value {

src/test/ui/borrowck/issue-64453.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ LL | static settings_dir: String = format!("");
77
= help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable
88
= note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
99

10-
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
10+
error[E0015]: cannot call non-const fn `format` in statics
1111
--> $DIR/issue-64453.rs:4:31
1212
|
1313
LL | static settings_dir: String = format!("");
1414
| ^^^^^^^^^^^
1515
|
16+
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
1617
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
1718

1819
error[E0507]: cannot move out of static item `settings_dir`

src/test/ui/check-static-values-constraints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static mut STATIC13: SafeStruct = SafeStruct{field1: SafeEnum::Variant1,
8787
static mut STATIC14: SafeStruct = SafeStruct {
8888
field1: SafeEnum::Variant1,
8989
field2: SafeEnum::Variant4("str".to_string())
90-
//~^ ERROR calls in statics are limited to constant functions
90+
//~^ ERROR cannot call non-const fn
9191
};
9292

9393
static STATIC15: &'static [Box<MyOwned>] = &[

src/test/ui/check-static-values-constraints.stderr

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ error[E0010]: allocations are not allowed in statics
1515
LL | static STATIC11: Box<MyOwned> = box MyOwned;
1616
| ^^^^^^^^^^^ allocation not allowed in statics
1717

18-
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
19-
--> $DIR/check-static-values-constraints.rs:89:32
18+
error[E0015]: cannot call non-const fn `<str as ToString>::to_string` in statics
19+
--> $DIR/check-static-values-constraints.rs:89:38
2020
|
2121
LL | field2: SafeEnum::Variant4("str".to_string())
22-
| ^^^^^^^^^^^^^^^^^
22+
| ^^^^^^^^^^^
23+
|
24+
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
2325

2426
error[E0010]: allocations are not allowed in statics
2527
--> $DIR/check-static-values-constraints.rs:94:5

src/test/ui/const-generics/nested-type.full.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17_usize>::value` in constants
22
--> $DIR/nested-type.rs:15:5
33
|
44
LL | Foo::<17>::value()
55
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
68

79
error: aborting due to previous error
810

src/test/ui/const-generics/nested-type.min.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ LL | | }]>;
1414
= note: the only supported types are integers, `bool` and `char`
1515
= help: more complex types are supported with `#![feature(adt_const_params)]`
1616

17-
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
17+
error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17_usize>::value` in constants
1818
--> $DIR/nested-type.rs:15:5
1919
|
2020
LL | Foo::<17>::value()
2121
| ^^^^^^^^^^^^^^^^^^
22+
|
23+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
2224

2325
error: aborting due to 2 previous errors
2426

src/test/ui/const-generics/nested-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden
1313
}
1414

1515
Foo::<17>::value()
16-
//~^ ERROR calls in constants are limited to constant functions
16+
//~^ ERROR cannot call non-const fn
1717
}]>;
1818

1919
fn main() {}

src/test/ui/consts/const-call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ fn f(x: usize) -> usize {
44

55
fn main() {
66
let _ = [0; f(2)];
7-
//~^ ERROR calls in constants are limited to constant functions
7+
//~^ ERROR cannot call non-const fn
88
}

src/test/ui/consts/const-call.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `f` in constants
22
--> $DIR/const-call.rs:6:17
33
|
44
LL | let _ = [0; f(2)];
55
| ^^^^
6+
|
7+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
68

79
error: aborting due to previous error
810

src/test/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern "C" {
77
const extern "C" fn bar() {
88
unsafe {
99
regular_in_block();
10-
//~^ ERROR: calls in constant functions
10+
//~^ ERROR: cannot call non-const fn
1111
}
1212
}
1313

@@ -16,7 +16,7 @@ extern "C" fn regular() {}
1616
const extern "C" fn foo() {
1717
unsafe {
1818
regular();
19-
//~^ ERROR: calls in constant functions
19+
//~^ ERROR: cannot call non-const fn
2020
}
2121
}
2222

src/test/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `regular_in_block` in constant functions
22
--> $DIR/const-extern-fn-call-extern-fn.rs:9:9
33
|
44
LL | regular_in_block();
55
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
68

7-
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
9+
error[E0015]: cannot call non-const fn `regular` in constant functions
810
--> $DIR/const-extern-fn-call-extern-fn.rs:18:9
911
|
1012
LL | regular();
1113
| ^^^^^^^^^
14+
|
15+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
1216

1317
error: aborting due to 2 previous errors
1418

src/test/ui/consts/const-fn-error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const fn f(x: usize) -> usize {
44
let mut sum = 0;
55
for i in 0..x {
66
//~^ ERROR mutable references
7-
//~| ERROR calls in constant functions
8-
//~| ERROR calls in constant functions
7+
//~| ERROR cannot convert
8+
//~| ERROR cannot call non-const fn
99
//~| ERROR E0080
1010
//~| ERROR `for` is not allowed in a `const fn`
1111
sum += i;

src/test/ui/consts/const-fn-error.stderr

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ LL | | }
1313
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
1414
= help: add `#![feature(const_for)]` to the crate attributes to enable
1515

16-
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
16+
error[E0015]: cannot convert `std::ops::Range<usize>` into an iterator in constant functions
1717
--> $DIR/const-fn-error.rs:5:14
1818
|
1919
LL | for i in 0..x {
2020
| ^^^^
21+
|
22+
note: impl defined here, but it is not `const`
23+
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
24+
|
25+
LL | impl<I: Iterator> IntoIterator for I {
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
2128

2229
error[E0658]: mutable references are not allowed in constant functions
2330
--> $DIR/const-fn-error.rs:5:14
@@ -28,11 +35,13 @@ LL | for i in 0..x {
2835
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
2936
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
3037

31-
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
38+
error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions
3239
--> $DIR/const-fn-error.rs:5:14
3340
|
3441
LL | for i in 0..x {
3542
| ^^^^
43+
|
44+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
3645

3746
error[E0080]: evaluation of constant value failed
3847
--> $DIR/const-fn-error.rs:5:14

src/test/ui/consts/const-fn-not-safe-for-const.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `random` in constant functions
22
--> $DIR/const-fn-not-safe-for-const.rs:14:5
33
|
44
LL | random()
55
| ^^^^^^^^
6+
|
7+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
68

79
error[E0013]: constant functions cannot refer to statics
810
--> $DIR/const-fn-not-safe-for-const.rs:20:5

src/test/ui/consts/const-for.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
const _: () = {
55
for _ in 0..5 {}
6-
//~^ error: calls in constants are limited to
7-
//~| error: calls in constants are limited to
6+
//~^ error: cannot convert
7+
//~| error: cannot call non-const fn
88
};
99

1010
fn main() {}

src/test/ui/consts/const-for.stderr

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
22
--> $DIR/const-for.rs:5:14
33
|
44
LL | for _ in 0..5 {}
55
| ^^^^
6+
|
7+
note: impl defined here, but it is not `const`
8+
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
9+
|
10+
LL | impl<I: Iterator> IntoIterator for I {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
613

7-
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
14+
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
815
--> $DIR/const-for.rs:5:14
916
|
1017
LL | for _ in 0..5 {}
1118
| ^^^^
19+
|
20+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
1221

1322
error: aborting due to 2 previous errors
1423

src/test/ui/consts/control-flow/issue-46843.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn non_const() -> Thing {
88
}
99

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

src/test/ui/consts/control-flow/issue-46843.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `non_const` in constants
22
--> $DIR/issue-46843.rs:10:26
33
|
44
LL | pub const Q: i32 = match non_const() {
55
| ^^^^^^^^^^^
6+
|
7+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
68

79
error: aborting due to previous error
810

src/test/ui/consts/intrinsic_without_const_stab.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
1111
}
1212

1313
unsafe { copy(src, dst, count) }
14-
//~^ ERROR calls in constant functions are limited to constant functions
14+
//~^ ERROR cannot call non-const fn
1515
}
1616

1717
fn main() {}

src/test/ui/consts/intrinsic_without_const_stab.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `copy::copy::<T>` in constant functions
22
--> $DIR/intrinsic_without_const_stab.rs:13:14
33
|
44
LL | unsafe { copy(src, dst, count) }
55
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
68

79
error: aborting due to previous error
810

src/test/ui/consts/intrinsic_without_const_stab_fail.rs

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

1515
fn main() {}

src/test/ui/consts/intrinsic_without_const_stab_fail.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `copy::<T>` in constant functions
22
--> $DIR/intrinsic_without_const_stab_fail.rs:12:14
33
|
44
LL | unsafe { copy(src, dst, count) }
55
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
68

79
error: aborting due to previous error
810

src/test/ui/consts/issue-28113.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const X: u8 =
44
|| -> u8 { 5 }()
5-
//~^ ERROR calls in constants are limited to constant functions
5+
//~^ ERROR cannot call non-const fn
66
;
77

88
fn main() {}

src/test/ui/consts/issue-28113.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `<[closure@$DIR/issue-28113.rs:4:5: 4:19] as Fn<()>>::call` in constants
22
--> $DIR/issue-28113.rs:4:5
33
|
44
LL | || -> u8 { 5 }()
55
| ^^^^^^^^^^^^^^^^
6+
|
7+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
68

79
error: aborting due to previous error
810

src/test/ui/consts/issue-32829-2.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const bad : u32 = {
88
const bad_two : u32 = {
99
{
1010
invalid();
11-
//~^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
11+
//~^ ERROR: cannot call non-const fn `invalid`
1212
0
1313
}
1414
};
@@ -30,7 +30,7 @@ static bad_four : u32 = {
3030
static bad_five : u32 = {
3131
{
3232
invalid();
33-
//~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
33+
//~^ ERROR: cannot call non-const fn `invalid`
3434
0
3535
}
3636
};
@@ -52,7 +52,7 @@ static mut bad_seven : u32 = {
5252
static mut bad_eight : u32 = {
5353
{
5454
invalid();
55-
//~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
55+
//~^ ERROR: cannot call non-const fn `invalid`
5656
0
5757
}
5858
};

src/test/ui/consts/issue-32829-2.stderr

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
1+
error[E0015]: cannot call non-const fn `invalid` in constants
22
--> $DIR/issue-32829-2.rs:10:9
33
|
44
LL | invalid();
55
| ^^^^^^^^^
6+
|
7+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
68

7-
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
9+
error[E0015]: cannot call non-const fn `invalid` in statics
810
--> $DIR/issue-32829-2.rs:32:9
911
|
1012
LL | invalid();
1113
| ^^^^^^^^^
14+
|
15+
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
1216

13-
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
17+
error[E0015]: cannot call non-const fn `invalid` in statics
1418
--> $DIR/issue-32829-2.rs:54:9
1519
|
1620
LL | invalid();
1721
| ^^^^^^^^^
22+
|
23+
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
1824

1925
error: aborting due to 3 previous errors
2026

src/test/ui/consts/issue-43105.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn xyz() -> u8 { 42 }
22

33
const NUM: u8 = xyz();
4-
//~^ ERROR calls in constants are limited to constant functions, tuple structs and tuple variants
4+
//~^ ERROR cannot call non-const fn
55

66
fn main() {
77
match 1 {

0 commit comments

Comments
 (0)