Skip to content

Commit ae46434

Browse files
committed
Remove "static item recursion checking" in favor of relying on cycle checks in the query engine
1 parent 3bcda48 commit ae46434

14 files changed

+84
-374
lines changed

src/librustc_driver/driver.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use rustc_typeck as typeck;
3636
use rustc_privacy;
3737
use rustc_plugin::registry::Registry;
3838
use rustc_plugin as plugin;
39-
use rustc_passes::{self, ast_validation, loops, consts, static_recursion, hir_stats};
39+
use rustc_passes::{self, ast_validation, loops, consts, hir_stats};
4040
use rustc_const_eval::{self, check_match};
4141
use super::Compilation;
4242

@@ -972,10 +972,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
972972
"loop checking",
973973
|| loops::check_crate(sess, &hir_map));
974974

975-
time(time_passes,
976-
"static item recursion checking",
977-
|| static_recursion::check_crate(sess, &hir_map))?;
978-
979975
let mut local_providers = ty::maps::Providers::default();
980976
default_provide(&mut local_providers);
981977
trans.provide(&mut local_providers);

src/librustc_passes/diagnostics.rs

-16
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,6 @@ impl !Enterprise for Foo { }
128128
Please note that negative impls are only allowed for auto traits.
129129
"##,
130130

131-
E0265: r##"
132-
This error indicates that a static or constant references itself.
133-
All statics and constants need to resolve to a value in an acyclic manner.
134-
135-
For example, neither of the following can be sensibly compiled:
136-
137-
```compile_fail,E0265
138-
const X: u32 = X;
139-
```
140-
141-
```compile_fail,E0265
142-
const X: u32 = Y;
143-
const Y: u32 = X;
144-
```
145-
"##,
146-
147131
E0267: r##"
148132
This error indicates the use of a loop keyword (`break` or `continue`) inside a
149133
closure but outside of any loop. Erroneous code example:

src/librustc_passes/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ pub mod consts;
4242
pub mod hir_stats;
4343
pub mod loops;
4444
mod mir_stats;
45-
pub mod static_recursion;
4645

4746
#[cfg(not(stage0))] // remove after the next snapshot
4847
__build_diagnostic_array! { librustc_passes, DIAGNOSTICS }

src/librustc_passes/static_recursion.rs

-280
This file was deleted.

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

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

11-
const FOO: usize = FOO; //~ ERROR recursive constant
11+
const FOO: usize = FOO; //~ ERROR E0391
1212

1313
fn main() {
1414
let _x: [u8; FOO]; // caused stack overflow prior to fix
1515
let _y: usize = 1 + {
16-
const BAR: usize = BAR; //~ ERROR recursive constant
16+
const BAR: usize = BAR;
1717
let _z: [u8; BAR]; // caused stack overflow prior to fix
1818
1
1919
};

src/test/ui/issue-23302.rs renamed to src/test/ui/issue-23302-1.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,7 @@
1111
// Check that an enum with recursion in the discriminant throws
1212
// the appropriate error (rather than, say, blowing the stack).
1313
enum X {
14-
A = X::A as isize, //~ ERROR E0265
14+
A = X::A as isize, //~ ERROR E0391
1515
}
1616

17-
// Since `Y::B` here defaults to `Y::A+1`, this is also a
18-
// recursive definition.
19-
enum Y {
20-
A = Y::B as isize, //~ ERROR E0265
21-
B,
22-
}
23-
24-
const A: i32 = B; //~ ERROR E0265
25-
26-
const B: i32 = A; //~ ERROR E0265
27-
2817
fn main() { }

src/test/ui/issue-23302-1.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0391]: unsupported cyclic reference between types/traits detected
2+
--> $DIR/issue-23302-1.rs:14:9
3+
|
4+
14 | A = X::A as isize, //~ ERROR E0391
5+
| ^^^^^^^^^^^^^ cyclic reference
6+
|
7+
note: the cycle begins when const-evaluating `X::A::{{initializer}}`...
8+
--> $DIR/issue-23302-1.rs:14:5
9+
|
10+
14 | A = X::A as isize, //~ ERROR E0391
11+
| ^^^^^^^^^^^^^^^^^
12+
= note: ...which then again requires const-evaluating `X::A::{{initializer}}`, completing the cycle.
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)