@@ -103,6 +103,75 @@ pub(super) struct JobOwner<'a, 'tcx: 'a, Q: QueryDescription<'tcx> + 'a> {
103103 layout_depth : usize ,
104104}
105105
106+ use std:: mem:: MaybeUninit ;
107+ #[ inline( never) ]
108+ pub fn may_panic < ' tcx > ( job : Lrc < QueryJob < ' tcx > > ) {
109+ Box :: new ( job) ;
110+ }
111+
112+ #[ inline( never) ]
113+ pub fn test_space ( ) {
114+ }
115+
116+ #[ no_mangle]
117+ fn test_moves2 < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
118+ key : & :: hir:: def_id:: DefId , key_hash : u64 ,
119+ span : Span ,
120+ parent : & Option < Lrc < QueryJob < ' tcx > > > ,
121+ mut job_storage : MoveSlot < ' a , JobOwner < ' a , ' tcx , :: ty:: query:: queries:: type_of < ' tcx > > > ,
122+ ) -> TryGetJob < ' a , ' tcx , :: ty:: query:: queries:: type_of < ' tcx > > {
123+ use ty:: query:: config:: QueryAccessors ;
124+ let mut job = Lrc :: new ( MaybeUninit :: uninitialized ( ) ) ;
125+ let parent = parent. clone ( ) ;
126+ let info = QueryInfo {
127+ span,
128+ query : :: ty:: query:: queries:: type_of:: query ( * key) ,
129+ } ;
130+ * Lrc :: get_mut ( & mut job) . unwrap ( ) =
131+ MaybeUninit :: new ( QueryJob :: new ( info, parent) ) ;
132+ let job: Lrc < QueryJob < ' tcx > > = unsafe { std:: mem:: transmute ( job) } ;
133+ let job_clone = job. clone ( ) ;
134+ may_panic ( job) ;
135+ let owner = job_storage. init ( JobOwner {
136+ cache : :: ty:: query:: queries:: type_of:: query_cache ( tcx) ,
137+ job : job_clone,
138+ key : ( * key) . clone ( ) ,
139+ key_hash,
140+ layout_depth : 83952 ,
141+ } ) ;
142+ TryGetJob :: NotYetStarted ( owner)
143+ }
144+
145+ #[ no_mangle]
146+ fn test_moves < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
147+ key : & :: hir:: def_id:: DefId , key_hash : u64 ,
148+ span : Span ,
149+ mut job_storage : MoveSlot < ' a , JobOwner < ' a , ' tcx , :: ty:: query:: queries:: type_of < ' tcx > > > ,
150+ ) -> TryGetJob < ' a , ' tcx , :: ty:: query:: queries:: type_of < ' tcx > > {
151+ use ty:: query:: config:: QueryAccessors ;
152+ tls:: with_related_context ( tcx, |icx| {
153+ let mut job = Lrc :: new ( MaybeUninit :: uninitialized ( ) ) ;
154+ let parent = icx. query . clone ( ) ;
155+ let info = QueryInfo {
156+ span,
157+ query : :: ty:: query:: queries:: type_of:: query ( * key) ,
158+ } ;
159+ * Lrc :: get_mut ( & mut job) . unwrap ( ) =
160+ MaybeUninit :: new ( QueryJob :: new ( info, parent) ) ;
161+ let job: Lrc < QueryJob < ' tcx > > = unsafe { std:: mem:: transmute ( job) } ;
162+ let job_clone = job. clone ( ) ;
163+ may_panic ( job) ;
164+ let owner = job_storage. init ( JobOwner {
165+ cache : :: ty:: query:: queries:: type_of:: query_cache ( tcx) ,
166+ job : job_clone,
167+ key : ( * key) . clone ( ) ,
168+ key_hash,
169+ layout_depth : icx. layout_depth ,
170+ } ) ;
171+ TryGetJob :: NotYetStarted ( owner)
172+ } )
173+ }
174+
106175impl < ' a , ' tcx , Q : QueryDescription < ' tcx > > JobOwner < ' a , ' tcx , Q > {
107176 /// Either gets a JobOwner corresponding the query, allowing us to
108177 /// start executing the query, or it returns with the result of the query.
0 commit comments