File tree 3 files changed +37
-1
lines changed
tests/incremental/static_cycle
3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,15 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
172
172
}
173
173
} ) ;
174
174
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
+
175
184
// FIXME: Remove this when we implement creating `DefId`s
176
185
// for anon constants during their parents' typeck.
177
186
// Typeck all body owners in parallel will produce queries
Original file line number Diff line number Diff line change @@ -1116,7 +1116,6 @@ rustc_queries! {
1116
1116
"evaluating initializer of static `{}`" ,
1117
1117
tcx. def_path_str( key)
1118
1118
}
1119
- cache_on_disk_if { key. is_local( ) }
1120
1119
separate_provide_extern
1121
1120
feedable
1122
1121
}
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments