Skip to content

Commit 1cf55c1

Browse files
committed
Reproduce issue
1 parent b857763 commit 1cf55c1

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Diff for: compiler/rustc_hir_analysis/src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
172172
}
173173
});
174174

175+
// Make sure we actually have a value for static items, as they aren't cached in incremental.
176+
// While we could just wait for codegen to invoke this, the definitions freeze below will cause
177+
// that to ICE, because evaluating statics can create more items.
178+
tcx.hir().par_body_owners(|item_def_id| {
179+
if let DefKind::Static { .. } = tcx.def_kind(item_def_id) {
180+
let _ = tcx.eval_static_initializer(item_def_id);
181+
}
182+
});
183+
175184
// FIXME: Remove this when we implement creating `DefId`s
176185
// for anon constants during their parents' typeck.
177186
// Typeck all body owners in parallel will produce queries

Diff for: compiler/rustc_middle/src/query/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,6 @@ rustc_queries! {
11161116
"evaluating initializer of static `{}`",
11171117
tcx.def_path_str(key)
11181118
}
1119-
cache_on_disk_if { key.is_local() }
11201119
separate_provide_extern
11211120
feedable
11221121
}

Diff for: tests/incremental/static_cycle/feed_nested.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@ revisions:rpass1 rpass2
2+
3+
//! Test that the following order of instructions will not create duplicate
4+
//! `DefId`s for the nested static items.
5+
// ensure(eval_static_initializer(FOO))
6+
// -> try_mark_green(eval_static_initializer(FOO))
7+
// -> green
8+
// -> replay side effects
9+
// -> create some definitions.
10+
//
11+
// get(eval_static_initializer(FOO))
12+
// -> graph in place
13+
// -> replay
14+
// -> eval_static_initializer.compute
15+
// -> how do we skip re-creating the same definitions ?
16+
17+
#![feature(const_mut_refs)]
18+
#![cfg_attr(rpass2, warn(dead_code))]
19+
20+
pub static mut FOO: &mut i32 = &mut 42;
21+
22+
pub static mut BAR: &mut i32 = unsafe { FOO };
23+
24+
fn main() {
25+
unsafe {
26+
assert_eq!(BAR as *mut i32, FOO as *mut i32);
27+
}
28+
}

0 commit comments

Comments
 (0)