File tree 2 files changed +22
-9
lines changed
rustc_mir/src/transform/coverage
2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -611,6 +611,18 @@ pub struct TyS<'tcx> {
611
611
outer_exclusive_binder : ty:: DebruijnIndex ,
612
612
}
613
613
614
+ impl < ' tcx > TyS < ' tcx > {
615
+ /// A constructor used only for internal testing.
616
+ #[ allow( rustc:: usage_of_ty_tykind) ]
617
+ pub fn make_for_test (
618
+ kind : TyKind < ' tcx > ,
619
+ flags : TypeFlags ,
620
+ outer_exclusive_binder : ty:: DebruijnIndex ,
621
+ ) -> TyS < ' tcx > {
622
+ TyS { kind, flags, outer_exclusive_binder }
623
+ }
624
+ }
625
+
614
626
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
615
627
#[ cfg( target_arch = "x86_64" ) ]
616
628
static_assert_size ! ( TyS <' _>, 32 ) ;
Original file line number Diff line number Diff line change @@ -7,18 +7,19 @@ use rustc_data_structures::graph::WithNumNodes;
7
7
use rustc_data_structures:: graph:: WithSuccessors ;
8
8
use rustc_index:: vec:: { Idx , IndexVec } ;
9
9
use rustc_middle:: mir:: * ;
10
- use rustc_middle:: ty:: { self , TyS } ;
10
+ use rustc_middle:: ty:: { self , DebruijnIndex , TyS , TypeFlags } ;
11
11
use rustc_span:: DUMMY_SP ;
12
12
13
- use std:: lazy:: SyncOnceCell ;
14
-
15
- fn dummy_ty < ' tcx > ( ) -> & ' static TyS < ' tcx > {
16
- static DUMMY_TYS : SyncOnceCell < TyS < ' _ > > = SyncOnceCell :: new ( ) ;
13
+ fn dummy_ty ( ) -> & ' static TyS < ' static > {
14
+ thread_local ! {
15
+ static DUMMY_TYS : & ' static TyS <' static > = Box :: leak( box TyS :: make_for_test(
16
+ ty:: Bool ,
17
+ TypeFlags :: empty( ) ,
18
+ DebruijnIndex :: from_usize( 0 ) ,
19
+ ) ) ;
20
+ }
17
21
18
- & DUMMY_TYS . get_or_init ( || {
19
- let fake_type_bytes = vec ! [ 0 as u8 ; std:: mem:: size_of:: <TyS <' _>>( ) ] ;
20
- unsafe { std:: ptr:: read_unaligned :: < TyS < ' _ > > ( fake_type_bytes. as_ptr ( ) as * const TyS < ' _ > ) }
21
- } )
22
+ & DUMMY_TYS . with ( |tys| * tys)
22
23
}
23
24
24
25
struct MockBlocks < ' tcx > {
You can’t perform that action at this time.
0 commit comments