File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed
rustc_mir/src/transform/coverage Expand file tree Collapse file tree 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> {
611611 outer_exclusive_binder : ty:: DebruijnIndex ,
612612}
613613
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+
614626// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
615627#[ cfg( target_arch = "x86_64" ) ]
616628static_assert_size ! ( TyS <' _>, 32 ) ;
Original file line number Diff line number Diff line change @@ -7,18 +7,19 @@ use rustc_data_structures::graph::WithNumNodes;
77use rustc_data_structures:: graph:: WithSuccessors ;
88use rustc_index:: vec:: { Idx , IndexVec } ;
99use rustc_middle:: mir:: * ;
10- use rustc_middle:: ty:: { self , TyS } ;
10+ use rustc_middle:: ty:: { self , DebruijnIndex , TyS , TypeFlags } ;
1111use rustc_span:: DUMMY_SP ;
1212
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+ }
1721
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)
2223}
2324
2425struct MockBlocks < ' tcx > {
You can’t perform that action at this time.
0 commit comments