Skip to content

Commit 4f5900a

Browse files
committed
test: adjust for the move to MIR-based const checking.
1 parent 78884b7 commit 4f5900a

19 files changed

+47
-75
lines changed

src/test/compile-fail/auxiliary/pub_static_array.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
pub static ARRAY: &'static [u8] = &[1];
11+
pub static ARRAY: [u8; 1] = [1];

src/test/compile-fail/check-static-immutable-mut-slices.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212

1313
static TEST: &'static mut [isize] = &mut [];
1414
//~^ ERROR references in statics may only refer to immutable values
15+
//~^^ ERROR references in statics may only refer to immutable values
1516

1617
pub fn main() { }

src/test/compile-fail/check-static-values-constraints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,5 @@ static STATIC19: Box<isize> =
140140
pub fn main() {
141141
let y = { static x: Box<isize> = box 3; x };
142142
//~^ ERROR allocations are not allowed in statics
143+
//~^^ ERROR cannot move out of static item
143144
}

src/test/compile-fail/const-fn-destructuring-arg.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#![feature(const_fn)]
1414

1515
// no destructuring
16-
const fn i((a, b): (u32, u32)) -> u32 { a + b } //~ ERROR: E0022
16+
const fn i((
17+
a, //~ ERROR: E0022
18+
b //~ ERROR: E0022
19+
): (u32, u32)) -> u32 {
20+
a + b
21+
}
1722

1823
fn main() {}

src/test/compile-fail/const-fn-error.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// test that const fn signature and body errors are checked
12-
// even in array lengths, which are evaluated before check_const
13-
1411
#![feature(const_fn)]
1512

1613
const X : usize = 2;
1714

1815
const fn f(x: usize) -> usize {
19-
let mut sum = 0; //~ ERROR: E0016
20-
for i in 0..x { //~ ERROR: E0016
16+
let mut sum = 0;
17+
for i in 0..x {
2118
sum += i;
2219
}
23-
sum
20+
sum //~ ERROR: E0250
2421
}
2522

2623
#[allow(unused_variables)]

src/test/compile-fail/const-fn-not-safe-for-const.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@ static Y: u32 = 0;
2929
const fn get_Y() -> u32 {
3030
Y
3131
//~^ ERROR E0013
32-
//~| ERROR cannot refer to other statics by value
32+
//~| ERROR cannot refer to statics by value
3333
}
3434

3535
const fn get_Y_addr() -> &'static u32 {
3636
&Y
3737
//~^ ERROR E0013
3838
}
3939

40+
const fn get() -> u32 {
41+
let x = 22; //~ ERROR E0016
42+
let y = 44; //~ ERROR E0016
43+
x + y
44+
}
45+
4046
fn main() {
4147
}

src/test/compile-fail/const-fn-not-safe-for-const2.rs

-44
This file was deleted.

src/test/compile-fail/issue-17718-borrow-interior.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ static C: &'static usize = &(A.a);
1717

1818
static D: [usize; 1] = [1];
1919
static E: usize = D[0];
20-
//~^ ERROR: cannot refer to other statics by value
20+
//~^ ERROR: cannot refer to the interior of another static
21+
//~^^ ERROR: cannot refer to other statics by value
2122
static F: &'static usize = &D[0];
2223
//~^ ERROR: cannot refer to the interior of another static
2324

src/test/compile-fail/issue-17718-const-bad-values.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010

1111
const C1: &'static mut [usize] = &mut [];
1212
//~^ ERROR: references in constants may only refer to immutable values
13+
//~| ERROR: references in constants may only refer to immutable values
1314

1415
static mut S: usize = 3;
15-
const C2: &'static mut usize = &mut S;
16-
//~^ ERROR: constants cannot refer to other statics
17-
//~^^ ERROR: references in constants may only refer to immutable values
16+
const C2: &'static mut usize = unsafe { &mut S };
17+
//~^ ERROR: constants cannot refer to statics
18+
//~| ERROR: references in constants may only refer to immutable values
19+
//~| ERROR: references in constants may only refer to immutable values
20+
//~| ERROR: references in constants may only refer to immutable values
1821

1922
fn main() {}

src/test/compile-fail/issue-17718-references.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ const C: usize = 1;
1414
static S: usize = 1;
1515

1616
const T1: &'static usize = &C;
17-
const T2: &'static usize = &S; //~ ERROR: constants cannot refer to other statics
17+
const T2: &'static usize = &S; //~ ERROR: constants cannot refer to statics
1818
static T3: &'static usize = &C;
1919
static T4: &'static usize = &S;
2020

2121
const T5: usize = C;
22-
const T6: usize = S; //~ ERROR: constants cannot refer to other statics
23-
//~^ cannot refer to other statics
22+
const T6: usize = S; //~ ERROR: constants cannot refer to statics
23+
//~^ cannot refer to statics
2424
static T7: usize = C;
2525
static T8: usize = S; //~ ERROR: cannot refer to other statics by value
2626

2727
const T9: Struct = Struct { a: C };
28-
const T10: Struct = Struct { a: S }; //~ ERROR: cannot refer to other statics by value
29-
//~^ ERROR: constants cannot refer to other statics
28+
const T10: Struct = Struct { a: S }; //~ ERROR: cannot refer to statics by value
29+
//~^ ERROR: constants cannot refer to statics
3030
static T11: Struct = Struct { a: C };
3131
static T12: Struct = Struct { a: S }; //~ ERROR: cannot refer to other statics by value
3232

src/test/compile-fail/issue-18118-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ pub fn main() {
1212
const z: &'static isize = {
1313
static p: isize = 3;
1414
&p
15-
//~^ ERROR constants cannot refer to other statics, insert an intermediate constant instead
15+
//~^ ERROR constants cannot refer to statics, use a constant instead
1616
};
1717
}

src/test/compile-fail/issue-18118.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
pub fn main() {
1212
const z: &'static isize = {
13+
//~^ ERROR blocks in constants are limited to items and tail expressions
1314
let p = 3;
1415
//~^ ERROR blocks in constants are limited to items and tail expressions
1516
&p

src/test/compile-fail/issue-25901.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
struct A;
1212
struct B;
1313

14-
static S: &'static B = &A; //~ ERROR user-defined dereference operators
14+
static S: &'static B = &A;
15+
//~^ ERROR calls in statics are limited to constant functions
1516

1617
use std::ops::Deref;
1718

src/test/compile-fail/issue-27895.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ fn main() {
1414

1515
match i {
1616
0...index => println!("winner"),
17-
//~^ ERROR paths in constants may only refer to constants or functions
18-
//~| ERROR non-constant path in constant expression
17+
//~^ ERROR non-constant path in constant expression
1918
_ => println!("hello"),
2019
}
2120
}

src/test/compile-fail/issue-28113.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// except according to those terms.
1010

1111
const X: u8 =
12-
|| -> u8 { 5 }() //~ ERROR function calls in constants are limited
12+
|| -> u8 { 5 }()
13+
//~^ ERROR calls in constants are limited to constant functions
1314
;
1415

1516
fn main() {}

src/test/compile-fail/non-constant-in-const-path.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fn main() {
1212
let x = 0;
1313
match 1 {
1414
0 ... x => {}
15-
//~^ ERROR non-constant path in constant expr
16-
//~| ERROR paths in constants may only refer to constants or functions
15+
//~^ ERROR non-constant path in constant expression
1716
};
1817
}

src/test/compile-fail/static-array-across-crate.rs

+7
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,11 @@ use array::ARRAY;
1717
static X: &'static u8 = &ARRAY[0];
1818
//~^ ERROR: cannot refer to the interior of another static, use a constant
1919

20+
static Y: &'static u8 = &(&ARRAY)[0];
21+
//~^ ERROR: cannot refer to the interior of another static, use a constant
22+
23+
static Z: u8 = (&ARRAY)[0];
24+
//~^ ERROR: cannot refer to the interior of another static, use a constant
25+
//~^^ ERROR: cannot refer to other statics by value
26+
2027
pub fn main() {}

src/test/run-pass/const-str-ptr.rs

-5
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(rustc_attrs)]
12-
13-
// ignore-pretty : (#23623) problems when ending with // comments
14-
1511
use std::{str, string};
1612

1713
const A: [u8; 2] = ['h' as u8, 'i' as u8];
1814
const B: &'static [u8; 2] = &A;
1915
const C: *const u8 = B as *const u8;
2016

21-
#[rustc_no_mir] // FIXME #27840 MIR can't do rvalue promotion yet.
2217
pub fn main() {
2318
unsafe {
2419
let foo = &A as *const u8;

src/test/run-pass/mir_raw_fat_ptr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ impl<T> Foo for T {
121121

122122
struct S<T:?Sized>(u32, T);
123123

124-
#[rustc_no_mir] // FIXME #27840 MIR can't do rvalue promotion yet.
125124
fn main() {
126125
let array = [0,1,2,3,4];
127126
let array2 = [5,6,7,8,9];

0 commit comments

Comments
 (0)