forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#134498 - oli-obk:push-wmxynprsyxvr, r=compiler-errors Fix cycle error only occurring with -Zdump-mir fixes rust-lang#134205 During mir dumping, we evaluate static items to render their allocations. If a static item refers to itself, its own MIR will have a reference to itself, so during mir dumping we end up evaluating the static again, causing us to try to build MIR again (mir dumping happens during MIR building). Thus I disabled evaluation of statics during MIR dumps in case the MIR body isn't far enough along yet to be able to be guaranteed cycle free.
- Loading branch information
Showing
4 changed files
with
37 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#[derive(Debug)] | ||
pub struct Thing { | ||
pub next: &'static Thing, | ||
} | ||
|
||
pub static THING: Thing = Thing { next: &THING }; | ||
// CHECK: alloc{{.+}} (static: THING) | ||
|
||
const fn thing() -> &'static Thing { | ||
&MUTUALLY_RECURSIVE | ||
} | ||
|
||
pub static MUTUALLY_RECURSIVE: Thing = Thing { next: thing() }; | ||
// CHECK: alloc{{.+}} (static: MUTUALLY_RECURSIVE) | ||
|
||
fn main() { | ||
// Generate optimized MIR for the const fn, too. | ||
thing(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters