Skip to content

Commit ef6d427

Browse files
Bless tests
1 parent 3569bb6 commit ef6d427

35 files changed

+200
-159
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern "C" {
77
const extern fn bar() {
88
unsafe {
99
regular_in_block();
10-
//~^ ERROR: can only call other `const fn` within a `const fn`
10+
//~^ ERROR: calls in constant functions
1111
}
1212
}
1313

@@ -16,7 +16,7 @@ extern fn regular() {}
1616
const extern fn foo() {
1717
unsafe {
1818
regular();
19-
//~^ ERROR: can only call other `const fn` within a `const fn`
19+
//~^ ERROR: calls in constant functions
2020
}
2121
}
2222

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
error[E0723]: can only call other `const fn` within a `const fn`, but `regular_in_block` is not stable as `const fn`
1+
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
22
--> $DIR/const-extern-fn-call-extern-fn.rs:9:9
33
|
44
LL | regular_in_block();
55
| ^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
8-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
96

10-
error[E0723]: can only call other `const fn` within a `const fn`, but `regular` is not stable as `const fn`
7+
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
118
--> $DIR/const-extern-fn-call-extern-fn.rs:18:9
129
|
1310
LL | regular();
1411
| ^^^^^^^^^
15-
|
16-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
17-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
1812

1913
error: aborting due to 2 previous errors
2014

21-
For more information about this error, try `rustc --explain E0723`.
15+
For more information about this error, try `rustc --explain E0015`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const unsafe extern "C" fn closure() -> fn() { || {} }
66
const unsafe extern fn use_float() { 1.0 + 1.0; }
77
//~^ ERROR only int, `bool` and `char` operations are stable in const fn
88
const extern "C" fn ptr_cast(val: *const u8) { val as usize; }
9-
//~^ ERROR casting pointers to ints is unstable in const fn
9+
//~^ ERROR casting pointers to integers
1010

1111

1212
fn main() {}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ LL | const unsafe extern fn use_float() { 1.0 + 1.0; }
1616
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
1717
= help: add `#![feature(const_fn)]` to the crate attributes to enable
1818

19-
error[E0723]: casting pointers to ints is unstable in const fn
19+
error[E0658]: casting pointers to integers in constant functions is unstable
2020
--> $DIR/const-extern-fn-min-const-fn.rs:8:48
2121
|
2222
LL | const extern "C" fn ptr_cast(val: *const u8) { val as usize; }
2323
| ^^^^^^^^^^^^
2424
|
25-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
26-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
25+
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
26+
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
2727

2828
error: aborting due to 3 previous errors
2929

30-
For more information about this error, try `rustc --explain E0723`.
30+
Some errors have detailed explanations: E0658, E0723.
31+
For more information about an error, try `rustc --explain E0658`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Test that we can't call random fns in a const fn or do other bad things.
22

3-
#![feature(const_fn, const_transmute)]
3+
#![feature(const_fn, const_fn_transmute)]
44

55
use std::mem::transmute;
66

src/test/ui/consts/const-mut-refs/feature-gate-const_mut_refs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ fn main() {
22
foo(&mut 5);
33
}
44

5-
const fn foo(x: &mut i32) -> i32 { //~ ERROR mutable references in const fn are unstable
5+
const fn foo(x: &mut i32) -> i32 { //~ ERROR mutable references in const fn
66
*x + 1
7+
78
}

src/test/ui/consts/const_let_assign3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ struct S {
66

77
impl S {
88
const fn foo(&mut self, x: u32) {
9+
//~^ ERROR mutable references
910
self.state = x;
10-
//~^ contains unimplemented expression
1111
}
1212
}
1313

src/test/ui/consts/const_let_assign3.stderr

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
error[E0019]: constant function contains unimplemented expression type
2-
--> $DIR/const_let_assign3.rs:9:9
1+
error[E0723]: mutable references in const fn are unstable
2+
--> $DIR/const_let_assign3.rs:8:18
33
|
4-
LL | self.state = x;
5-
| ^^^^^^^^^^^^^^
4+
LL | const fn foo(&mut self, x: u32) {
5+
| ^^^^^^^^^
66
|
7-
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
7+
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
8+
= help: add `#![feature(const_fn)]` to the crate attributes to enable
89

910
error[E0764]: mutable references are not allowed in constants
1011
--> $DIR/const_let_assign3.rs:16:5
@@ -28,5 +29,5 @@ LL | *y = 42;
2829

2930
error: aborting due to 4 previous errors
3031

31-
Some errors have detailed explanations: E0019, E0764.
32+
Some errors have detailed explanations: E0019, E0723, E0764.
3233
For more information about an error, try `rustc --explain E0019`.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const fn foo(a: i32) -> Vec<i32> {
2-
vec![1, 2, 3] //~ ERROR heap allocations are not allowed in const fn
2+
vec![1, 2, 3]
3+
//~^ ERROR allocations are not allowed
4+
//~| ERROR unimplemented expression type
5+
//~| ERROR calls in constant functions
36
}
47

58
fn main() {}
Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1-
error[E0723]: heap allocations are not allowed in const fn
1+
error[E0010]: allocations are not allowed in constant functions
2+
--> $DIR/bad_const_fn_body_ice.rs:2:5
3+
|
4+
LL | vec![1, 2, 3]
5+
| ^^^^^^^^^^^^^ allocation not allowed in constant functions
6+
|
7+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error[E0019]: constant function contains unimplemented expression type
10+
--> $DIR/bad_const_fn_body_ice.rs:2:5
11+
|
12+
LL | vec![1, 2, 3]
13+
| ^^^^^^^^^^^^^
14+
|
15+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
16+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
219
--> $DIR/bad_const_fn_body_ice.rs:2:5
320
|
421
LL | vec![1, 2, 3]
522
| ^^^^^^^^^^^^^
623
|
7-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
8-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
924
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
1025

11-
error: aborting due to previous error
26+
error: aborting due to 3 previous errors
1227

13-
For more information about this error, try `rustc --explain E0723`.
28+
Some errors have detailed explanations: E0010, E0015, E0019.
29+
For more information about an error, try `rustc --explain E0010`.

src/test/ui/consts/min_const_fn/min_const_fn.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,25 @@ const fn foo11<T: std::fmt::Display>(t: T) -> T { t }
7878
const fn foo11_2<T: Send>(t: T) -> T { t }
7979
//~^ ERROR trait bounds other than `Sized` on const fn parameters are unstable
8080
const fn foo19(f: f32) -> f32 { f * 2.0 }
81-
//~^ ERROR only int, `bool` and `char` operations are stable in const fn
81+
//~^ ERROR int, `bool` and `char` operations
8282
const fn foo19_2(f: f32) -> f32 { 2.0 - f }
83-
//~^ ERROR only int, `bool` and `char` operations are stable in const fn
83+
//~^ ERROR int, `bool` and `char` operations
8484
const fn foo19_3(f: f32) -> f32 { -f }
85-
//~^ ERROR only int and `bool` operations are stable in const fn
85+
//~^ ERROR int, `bool` and `char` operations
8686
const fn foo19_4(f: f32, g: f32) -> f32 { f / g }
87-
//~^ ERROR only int, `bool` and `char` operations are stable in const fn
87+
//~^ ERROR int, `bool` and `char` operations
8888

8989
static BAR: u32 = 42;
90-
const fn foo25() -> u32 { BAR } //~ ERROR cannot access `static` items in const fn
91-
const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot access `static` items
90+
const fn foo25() -> u32 { BAR } //~ ERROR cannot refer to statics
91+
const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot refer to statics
9292
const fn foo30(x: *const u32) -> usize { x as usize }
93-
//~^ ERROR casting pointers to ints is unstable
93+
//~^ ERROR casting pointers to integers
9494
const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
95-
//~^ ERROR casting pointers to ints is unstable
95+
//~^ ERROR casting pointers to integers
9696
const fn foo30_2(x: *mut u32) -> usize { x as usize }
97-
//~^ ERROR casting pointers to ints is unstable
97+
//~^ ERROR casting pointers to integers
9898
const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
99-
//~^ ERROR casting pointers to ints is unstable
99+
//~^ ERROR casting pointers to integers
100100
const fn foo30_6() -> bool { let x = true; x }
101101
const fn inc(x: &mut i32) { *x += 1 }
102102
//~^ ERROR mutable references in const fn are unstable

src/test/ui/consts/min_const_fn/min_const_fn.stderr

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ LL | const fn foo19_2(f: f32) -> f32 { 2.0 - f }
9494
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
9595
= help: add `#![feature(const_fn)]` to the crate attributes to enable
9696

97-
error[E0723]: only int and `bool` operations are stable in const fn
97+
error[E0723]: only int, `bool` and `char` operations are stable in const fn
9898
--> $DIR/min_const_fn.rs:84:35
9999
|
100100
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 }
112112
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
113113
= help: add `#![feature(const_fn)]` to the crate attributes to enable
114114

115-
error[E0723]: cannot access `static` items in const fn
115+
error[E0013]: constant functions cannot refer to statics
116116
--> $DIR/min_const_fn.rs:90:27
117117
|
118118
LL | const fn foo25() -> u32 { BAR }
119119
| ^^^
120120
|
121-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
122-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
121+
= help: consider extracting the value of the `static` to a `const`, and referring to that
123122

124-
error[E0723]: cannot access `static` items in const fn
123+
error[E0013]: constant functions cannot refer to statics
125124
--> $DIR/min_const_fn.rs:91:37
126125
|
127126
LL | const fn foo26() -> &'static u32 { &BAR }
128127
| ^^^
129128
|
130-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
131-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
129+
= help: consider extracting the value of the `static` to a `const`, and referring to that
132130

133-
error[E0723]: casting pointers to ints is unstable in const fn
131+
error[E0658]: casting pointers to integers in constant functions is unstable
134132
--> $DIR/min_const_fn.rs:92:42
135133
|
136134
LL | const fn foo30(x: *const u32) -> usize { x as usize }
137135
| ^^^^^^^^^^
138136
|
139-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
140-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
137+
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
138+
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
141139

142-
error[E0723]: casting pointers to ints is unstable in const fn
140+
error[E0658]: casting pointers to integers in constant functions is unstable
143141
--> $DIR/min_const_fn.rs:94:63
144142
|
145143
LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
146144
| ^^^^^^^^^^
147145
|
148-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
149-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
146+
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
147+
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
150148

151-
error[E0723]: casting pointers to ints is unstable in const fn
149+
error[E0658]: casting pointers to integers in constant functions is unstable
152150
--> $DIR/min_const_fn.rs:96:42
153151
|
154152
LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
155153
| ^^^^^^^^^^
156154
|
157-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
158-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
155+
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
156+
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
159157

160-
error[E0723]: casting pointers to ints is unstable in const fn
158+
error[E0658]: casting pointers to integers in constant functions is unstable
161159
--> $DIR/min_const_fn.rs:98:63
162160
|
163161
LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
164162
| ^^^^^^^^^^
165163
|
166-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
167-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
164+
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
165+
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
168166

169167
error[E0723]: mutable references in const fn are unstable
170168
--> $DIR/min_const_fn.rs:101:14
@@ -267,5 +265,5 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
267265

268266
error: aborting due to 30 previous errors
269267

270-
Some errors have detailed explanations: E0493, E0723.
271-
For more information about an error, try `rustc --explain E0493`.
268+
Some errors have detailed explanations: E0013, E0493, E0658, E0723.
269+
For more information about an error, try `rustc --explain E0013`.

src/test/ui/consts/min_const_fn/min_const_fn_libstd_stability.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ const fn foo() -> u32 { 42 }
1313
#[stable(feature = "rust1", since = "1.0.0")]
1414
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
1515
// can't call non-min_const_fn
16-
const fn bar() -> u32 { foo() } //~ ERROR can only call other `const fn`
16+
const fn bar() -> u32 { foo() } //~ ERROR not yet stable as a const fn
1717

1818
#[unstable(feature = "rust1", issue = "none")]
1919
const fn foo2() -> u32 { 42 }
2020

2121
#[stable(feature = "rust1", since = "1.0.0")]
2222
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
2323
// can't call non-min_const_fn
24-
const fn bar2() -> u32 { foo2() } //~ ERROR can only call other `const fn`
24+
const fn bar2() -> u32 { foo2() } //~ ERROR not yet stable as a const fn
2525

2626
#[stable(feature = "rust1", since = "1.0.0")]
2727
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
2828
// conformity is required, even with `const_fn` feature gate
29-
const fn bar3() -> u32 { (5f32 + 6f32) as u32 } //~ ERROR only int, `bool` and `char` operations
29+
const fn bar3() -> u32 { (5f32 + 6f32) as u32 }
30+
//~^ ERROR const-stable function cannot use `#[feature(const_fn)]`
3031

3132
// check whether this function cannot be called even with the feature gate active
3233
#[unstable(feature = "foo2", issue = "none")]
@@ -35,6 +36,6 @@ const fn foo2_gated() -> u32 { 42 }
3536
#[stable(feature = "rust1", since = "1.0.0")]
3637
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
3738
// can't call non-min_const_fn
38-
const fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR can only call other `const fn`
39+
const fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR not yet stable as a const fn
3940

4041
fn main() {}
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
error[E0723]: can only call other `const fn` within a `const fn`, but `foo` is not stable as `const fn`
1+
error: `foo` is not yet stable as a const fn
22
--> $DIR/min_const_fn_libstd_stability.rs:16:25
33
|
44
LL | const fn bar() -> u32 { foo() }
55
| ^^^^^
66
|
7-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
8-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
7+
= help: Const-stable functions can only call other const-stable functions
98

10-
error[E0723]: can only call other `const fn` within a `const fn`, but `foo2` is not stable as `const fn`
9+
error: `foo2` is not yet stable as a const fn
1110
--> $DIR/min_const_fn_libstd_stability.rs:24:26
1211
|
1312
LL | const fn bar2() -> u32 { foo2() }
1413
| ^^^^^^
1514
|
16-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
17-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
15+
= help: Const-stable functions can only call other const-stable functions
1816

19-
error[E0723]: only int, `bool` and `char` operations are stable in const fn
17+
error: const-stable function cannot use `#[feature(const_fn)]`
2018
--> $DIR/min_const_fn_libstd_stability.rs:29:26
2119
|
2220
LL | const fn bar3() -> u32 { (5f32 + 6f32) as u32 }
2321
| ^^^^^^^^^^^^^
2422
|
25-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
26-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
23+
= note: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
24+
help: if it is not part of the public API, make this function unstably const
25+
|
26+
LL | #[rustc_const_unstable(feature = "...", issue = "...")]
27+
|
2728

28-
error[E0723]: can only call other `const fn` within a `const fn`, but `foo2_gated` is not stable as `const fn`
29-
--> $DIR/min_const_fn_libstd_stability.rs:38:32
29+
error: `foo2_gated` is not yet stable as a const fn
30+
--> $DIR/min_const_fn_libstd_stability.rs:39:32
3031
|
3132
LL | const fn bar2_gated() -> u32 { foo2_gated() }
3233
| ^^^^^^^^^^^^
3334
|
34-
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
35-
= help: add `#![feature(const_fn)]` to the crate attributes to enable
35+
= help: Const-stable functions can only call other const-stable functions
3636

3737
error: aborting due to 4 previous errors
3838

39-
For more information about this error, try `rustc --explain E0723`.

src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ fn main() {}
1212
const unsafe fn no_union() {
1313
union Foo { x: (), y: () }
1414
Foo { x: () }.y
15-
//~^ accessing union fields is unstable
15+
//~^ unions in const fn
1616
}

0 commit comments

Comments
 (0)