Remove "static item recursion checking" in favor of relying on cycle checks in the query engine
This commit is contained in:
parent
3bcda48a30
commit
ae46434b79
14 changed files with 84 additions and 374 deletions
|
|
@ -8,12 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const FOO: usize = FOO; //~ ERROR recursive constant
|
||||
const FOO: usize = FOO; //~ ERROR E0391
|
||||
|
||||
fn main() {
|
||||
let _x: [u8; FOO]; // caused stack overflow prior to fix
|
||||
let _y: usize = 1 + {
|
||||
const BAR: usize = BAR; //~ ERROR recursive constant
|
||||
const BAR: usize = BAR;
|
||||
let _z: [u8; BAR]; // caused stack overflow prior to fix
|
||||
1
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,18 +11,7 @@
|
|||
// Check that an enum with recursion in the discriminant throws
|
||||
// the appropriate error (rather than, say, blowing the stack).
|
||||
enum X {
|
||||
A = X::A as isize, //~ ERROR E0265
|
||||
A = X::A as isize, //~ ERROR E0391
|
||||
}
|
||||
|
||||
// Since `Y::B` here defaults to `Y::A+1`, this is also a
|
||||
// recursive definition.
|
||||
enum Y {
|
||||
A = Y::B as isize, //~ ERROR E0265
|
||||
B,
|
||||
}
|
||||
|
||||
const A: i32 = B; //~ ERROR E0265
|
||||
|
||||
const B: i32 = A; //~ ERROR E0265
|
||||
|
||||
fn main() { }
|
||||
15
src/test/ui/issue-23302-1.stderr
Normal file
15
src/test/ui/issue-23302-1.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
error[E0391]: unsupported cyclic reference between types/traits detected
|
||||
--> $DIR/issue-23302-1.rs:14:9
|
||||
|
|
||||
14 | A = X::A as isize, //~ ERROR E0391
|
||||
| ^^^^^^^^^^^^^ cyclic reference
|
||||
|
|
||||
note: the cycle begins when const-evaluating `X::A::{{initializer}}`...
|
||||
--> $DIR/issue-23302-1.rs:14:5
|
||||
|
|
||||
14 | A = X::A as isize, //~ ERROR E0391
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
= note: ...which then again requires const-evaluating `X::A::{{initializer}}`, completing the cycle.
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
|
|
@ -8,7 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const A: usize = B; //~ ERROR: recursive constant
|
||||
const B: usize = A; //~ ERROR: recursive constant
|
||||
// Since `Y::B` here defaults to `Y::A+1`, this is also a
|
||||
// recursive definition.
|
||||
enum Y {
|
||||
A = Y::B as isize, //~ ERROR E0391
|
||||
B,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn main() { }
|
||||
15
src/test/ui/issue-23302-2.stderr
Normal file
15
src/test/ui/issue-23302-2.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
error[E0391]: unsupported cyclic reference between types/traits detected
|
||||
--> $DIR/issue-23302-2.rs:14:9
|
||||
|
|
||||
14 | A = Y::B as isize, //~ ERROR E0391
|
||||
| ^^^^^^^^^^^^^ cyclic reference
|
||||
|
|
||||
note: the cycle begins when const-evaluating `Y::A::{{initializer}}`...
|
||||
--> $DIR/issue-23302-2.rs:14:5
|
||||
|
|
||||
14 | A = Y::B as isize, //~ ERROR E0391
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
= note: ...which then again requires const-evaluating `Y::A::{{initializer}}`, completing the cycle.
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const a: isize = b; //~ ERROR recursive constant
|
||||
const b: isize = a; //~ ERROR recursive constant
|
||||
const A: i32 = B; //~ ERROR E0391
|
||||
|
||||
fn main() {
|
||||
}
|
||||
const B: i32 = A;
|
||||
|
||||
fn main() { }
|
||||
20
src/test/ui/issue-23302-3.stderr
Normal file
20
src/test/ui/issue-23302-3.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error[E0391]: unsupported cyclic reference between types/traits detected
|
||||
--> $DIR/issue-23302-3.rs:11:16
|
||||
|
|
||||
11 | const A: i32 = B; //~ ERROR E0391
|
||||
| ^ cyclic reference
|
||||
|
|
||||
note: the cycle begins when processing `B`...
|
||||
--> $DIR/issue-23302-3.rs:13:1
|
||||
|
|
||||
13 | const B: i32 = A;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
note: ...which then requires processing `A`...
|
||||
--> $DIR/issue-23302-3.rs:13:16
|
||||
|
|
||||
13 | const B: i32 = A;
|
||||
| ^
|
||||
= note: ...which then again requires processing `B`, completing the cycle.
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
error[E0265]: recursive constant
|
||||
--> $DIR/issue-23302.rs:14:9
|
||||
|
|
||||
14 | A = X::A as isize, //~ ERROR E0265
|
||||
| ^^^^^^^^^^^^^ recursion not allowed in constant
|
||||
|
||||
error[E0265]: recursive constant
|
||||
--> $DIR/issue-23302.rs:20:9
|
||||
|
|
||||
20 | A = Y::B as isize, //~ ERROR E0265
|
||||
| ^^^^^^^^^^^^^ recursion not allowed in constant
|
||||
|
||||
error[E0265]: recursive constant
|
||||
--> $DIR/issue-23302.rs:24:1
|
||||
|
|
||||
24 | const A: i32 = B; //~ ERROR E0265
|
||||
| ^^^^^^^^^^^^^^^^^ recursion not allowed in constant
|
||||
|
||||
error[E0265]: recursive constant
|
||||
--> $DIR/issue-23302.rs:26:1
|
||||
|
|
||||
26 | const B: i32 = A; //~ ERROR E0265
|
||||
| ^^^^^^^^^^^^^^^^^ recursion not allowed in constant
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
@ -8,16 +8,10 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const A: i32 = Foo::B; //~ ERROR E0265
|
||||
const A: isize = Foo::B as isize;
|
||||
|
||||
enum Foo {
|
||||
B = A, //~ ERROR E0265
|
||||
B = A, //~ ERROR E0391
|
||||
}
|
||||
|
||||
enum Bar {
|
||||
C = Bar::C, //~ ERROR E0265
|
||||
}
|
||||
|
||||
const D: i32 = A;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
error[E0265]: recursive constant
|
||||
--> $DIR/issue-36163.rs:11:1
|
||||
|
|
||||
11 | const A: i32 = Foo::B; //~ ERROR E0265
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ recursion not allowed in constant
|
||||
|
||||
error[E0265]: recursive constant
|
||||
error[E0391]: unsupported cyclic reference between types/traits detected
|
||||
--> $DIR/issue-36163.rs:14:9
|
||||
|
|
||||
14 | B = A, //~ ERROR E0265
|
||||
| ^ recursion not allowed in constant
|
||||
|
||||
error[E0265]: recursive constant
|
||||
--> $DIR/issue-36163.rs:18:9
|
||||
14 | B = A, //~ ERROR E0391
|
||||
| ^ cyclic reference
|
||||
|
|
||||
18 | C = Bar::C, //~ ERROR E0265
|
||||
| ^^^^^^ recursion not allowed in constant
|
||||
note: the cycle begins when const-evaluating `Foo::B::{{initializer}}`...
|
||||
--> $DIR/issue-36163.rs:14:5
|
||||
|
|
||||
14 | B = A, //~ ERROR E0391
|
||||
| ^^^^^
|
||||
note: ...which then requires const-evaluating `A`...
|
||||
--> $DIR/issue-36163.rs:14:9
|
||||
|
|
||||
14 | B = A, //~ ERROR E0391
|
||||
| ^
|
||||
= note: ...which then again requires const-evaluating `Foo::B::{{initializer}}`, completing the cycle.
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue