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 @@ -201,6 +201,15 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
201
201
}
202
202
} ) ;
203
203
204
+ // Make sure we actually have a value for static items, as they aren't cached in incremental.
205
+ // While we could just wait for codegen to invoke this, the definitions freeze below will cause
206
+ // that to ICE, because evaluating statics can create more items.
207
+ tcx. hir ( ) . par_body_owners ( |item_def_id| {
208
+ if let DefKind :: Static { .. } = tcx. def_kind ( item_def_id) {
209
+ let _ = tcx. eval_static_initializer ( item_def_id) ;
210
+ }
211
+ } ) ;
212
+
204
213
// Freeze definitions as we don't add new ones at this point. This improves performance by
205
214
// allowing lock-free access to them.
206
215
tcx. untracked ( ) . definitions . freeze ( ) ;
Original file line number Diff line number Diff line change @@ -1065,7 +1065,6 @@ rustc_queries! {
1065
1065
"evaluating initializer of static `{}`" ,
1066
1066
tcx. def_path_str( key)
1067
1067
}
1068
- cache_on_disk_if { key. is_local( ) }
1069
1068
separate_provide_extern
1070
1069
feedable
1071
1070
}
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