@@ -12,10 +12,10 @@ pub use sealed::IntoQueryParam;
1212
1313use crate :: dep_graph;
1414use crate :: dep_graph:: DepKind ;
15- use crate :: query:: on_disk_cache:: { CacheEncoder , EncodedDepNodeIndex , OnDiskCache } ;
16- use crate :: query:: {
15+ use crate :: queries:: {
1716 ExternProviders , PerQueryVTables , Providers , QueryArenas , QueryCaches , QueryEngine , QueryStates ,
1817} ;
18+ use crate :: query:: on_disk_cache:: { CacheEncoder , EncodedDepNodeIndex , OnDiskCache } ;
1919use crate :: ty:: TyCtxt ;
2020
2121pub type WillCacheOnDiskForKeyFn < ' tcx , Key > = fn ( tcx : TyCtxt < ' tcx > , key : & Key ) -> bool ;
@@ -189,8 +189,8 @@ macro_rules! query_ensure_select {
189189}
190190
191191macro_rules! query_helper_param_ty {
192- ( DefId ) => { impl IntoQueryParam <DefId > } ;
193- ( LocalDefId ) => { impl IntoQueryParam <LocalDefId > } ;
192+ ( DefId ) => { impl $crate :: query :: IntoQueryParam <DefId > } ;
193+ ( LocalDefId ) => { impl $crate :: query :: IntoQueryParam <LocalDefId > } ;
194194 ( $K: ty) => { $K } ;
195195}
196196
@@ -213,7 +213,7 @@ macro_rules! local_key_if_separate_extern {
213213 $( $K) *
214214 } ;
215215 ( [ ( separate_provide_extern) $( $rest: tt) * ] $( $K: tt) * ) => {
216- <$( $K) * as AsLocalKey >:: LocalKey
216+ <$( $K) * as $crate :: query :: AsLocalKey >:: LocalKey
217217 } ;
218218 ( [ $other: tt $( $modifiers: tt) * ] $( $K: tt) * ) => {
219219 local_key_if_separate_extern!( [ $( $modifiers) * ] $( $K) * )
@@ -227,8 +227,8 @@ macro_rules! separate_provide_extern_decl {
227227 ( [ ( separate_provide_extern) $( $rest: tt) * ] [ $name: ident] ) => {
228228 for <' tcx> fn (
229229 TyCtxt <' tcx>,
230- queries :: $name:: Key <' tcx>,
231- ) -> queries :: $name:: ProvidedValue <' tcx>
230+ $name:: Key <' tcx>,
231+ ) -> $name:: ProvidedValue <' tcx>
232232 } ;
233233 ( [ $other: tt $( $modifiers: tt) * ] [ $( $args: tt) * ] ) => {
234234 separate_provide_extern_decl!( [ $( $modifiers) * ] [ $( $args) * ] )
@@ -266,94 +266,90 @@ macro_rules! define_callbacks {
266266 [ $( $modifiers: tt) * ] fn $name: ident( $( $K: tt) * ) -> $V: ty,
267267 ) *
268268 ) => {
269-
270- #[ allow( unused_lifetimes) ]
271- pub mod queries {
272- $( pub mod $name {
273- use super :: super :: * ;
274- use $crate:: query:: erase:: { self , Erased } ;
275-
276- pub type Key <' tcx> = $( $K) * ;
277- pub type Value <' tcx> = $V;
278-
279- pub type LocalKey <' tcx> = local_key_if_separate_extern!( [ $( $modifiers) * ] $( $K) * ) ;
280-
281- /// This type alias specifies the type returned from query providers and the type
282- /// used for decoding. For regular queries this is the declared returned type `V`,
283- /// but `arena_cache` will use `<V as ArenaCached>::Provided` instead.
284- pub type ProvidedValue <' tcx> = query_if_arena!(
285- [ $( $modifiers) * ]
286- ( <$V as $crate:: query:: arena_cached:: ArenaCached <' tcx>>:: Provided )
287- ( $V)
269+ $( #[ allow( unused_lifetimes) ] pub mod $name {
270+ use super :: * ;
271+ use $crate:: query:: erase:: { self , Erased } ;
272+
273+ pub type Key <' tcx> = $( $K) * ;
274+ pub type Value <' tcx> = $V;
275+
276+ pub type LocalKey <' tcx> = local_key_if_separate_extern!( [ $( $modifiers) * ] $( $K) * ) ;
277+
278+ /// This type alias specifies the type returned from query providers and the type
279+ /// used for decoding. For regular queries this is the declared returned type `V`,
280+ /// but `arena_cache` will use `<V as ArenaCached>::Provided` instead.
281+ pub type ProvidedValue <' tcx> = query_if_arena!(
282+ [ $( $modifiers) * ]
283+ ( <$V as $crate:: query:: arena_cached:: ArenaCached <' tcx>>:: Provided )
284+ ( $V)
285+ ) ;
286+
287+ /// This function takes `ProvidedValue` and converts it to an erased `Value` by
288+ /// allocating it on an arena if the query has the `arena_cache` modifier. The
289+ /// value is then erased and returned. This will happen when computing the query
290+ /// using a provider or decoding a stored result.
291+ #[ inline( always) ]
292+ pub fn provided_to_erased<' tcx>(
293+ _tcx: TyCtxt <' tcx>,
294+ provided_value: ProvidedValue <' tcx>,
295+ ) -> Erased <Value <' tcx>> {
296+ // Store the provided value in an arena and get a reference
297+ // to it, for queries with `arena_cache`.
298+ let value: Value <' tcx> = query_if_arena!( [ $( $modifiers) * ]
299+ {
300+ use $crate:: query:: arena_cached:: ArenaCached ;
301+
302+ if mem:: needs_drop:: <<$V as ArenaCached <' tcx>>:: Allocated >( ) {
303+ <$V as ArenaCached >:: alloc_in_arena(
304+ |v| _tcx. query_system. arenas. $name. alloc( v) ,
305+ provided_value,
306+ )
307+ } else {
308+ <$V as ArenaCached >:: alloc_in_arena(
309+ |v| _tcx. arena. dropless. alloc( v) ,
310+ provided_value,
311+ )
312+ }
313+ }
314+ // Otherwise, the provided value is the value.
315+ ( provided_value)
288316 ) ;
317+ erase:: erase_val( value)
318+ }
289319
290- /// This function takes `ProvidedValue` and converts it to an erased `Value` by
291- /// allocating it on an arena if the query has the `arena_cache` modifier. The
292- /// value is then erased and returned. This will happen when computing the query
293- /// using a provider or decoding a stored result.
294- #[ inline( always) ]
295- pub fn provided_to_erased<' tcx>(
296- _tcx: TyCtxt <' tcx>,
297- provided_value: ProvidedValue <' tcx>,
298- ) -> Erased <Value <' tcx>> {
299- // Store the provided value in an arena and get a reference
300- // to it, for queries with `arena_cache`.
301- let value: Value <' tcx> = query_if_arena!( [ $( $modifiers) * ]
302- {
303- use $crate:: query:: arena_cached:: ArenaCached ;
304-
305- if mem:: needs_drop:: <<$V as ArenaCached <' tcx>>:: Allocated >( ) {
306- <$V as ArenaCached >:: alloc_in_arena(
307- |v| _tcx. query_system. arenas. $name. alloc( v) ,
308- provided_value,
309- )
310- } else {
311- <$V as ArenaCached >:: alloc_in_arena(
312- |v| _tcx. arena. dropless. alloc( v) ,
313- provided_value,
314- )
315- }
316- }
317- // Otherwise, the provided value is the value.
318- ( provided_value)
319- ) ;
320- erase:: erase_val( value)
320+ pub type Storage <' tcx> = <$( $K) * as $crate:: query:: Key >:: Cache <Erased <$V>>;
321+
322+ // Ensure that keys grow no larger than 88 bytes by accident.
323+ // Increase this limit if necessary, but do try to keep the size low if possible
324+ #[ cfg( target_pointer_width = "64" ) ]
325+ const _: ( ) = {
326+ if size_of:: <Key <' static >>( ) > 88 {
327+ panic!( "{}" , concat!(
328+ "the query `" ,
329+ stringify!( $name) ,
330+ "` has a key type `" ,
331+ stringify!( $( $K) * ) ,
332+ "` that is too large"
333+ ) ) ;
321334 }
322-
323- pub type Storage <' tcx> = <$( $K) * as keys:: Key >:: Cache <Erased <$V>>;
324-
325- // Ensure that keys grow no larger than 88 bytes by accident.
326- // Increase this limit if necessary, but do try to keep the size low if possible
327- #[ cfg( target_pointer_width = "64" ) ]
328- const _: ( ) = {
329- if size_of:: <Key <' static >>( ) > 88 {
330- panic!( "{}" , concat!(
331- "the query `" ,
332- stringify!( $name) ,
333- "` has a key type `" ,
334- stringify!( $( $K) * ) ,
335- "` that is too large"
336- ) ) ;
337- }
338- } ;
339-
340- // Ensure that values grow no larger than 64 bytes by accident.
341- // Increase this limit if necessary, but do try to keep the size low if possible
342- #[ cfg( target_pointer_width = "64" ) ]
343- #[ cfg( not( feature = "rustc_randomized_layouts" ) ) ]
344- const _: ( ) = {
345- if size_of:: <Value <' static >>( ) > 64 {
346- panic!( "{}" , concat!(
347- "the query `" ,
348- stringify!( $name) ,
349- "` has a value type `" ,
350- stringify!( $V) ,
351- "` that is too large"
352- ) ) ;
353- }
354- } ;
355- } ) *
356- }
335+ } ;
336+
337+ // Ensure that values grow no larger than 64 bytes by accident.
338+ // Increase this limit if necessary, but do try to keep the size low if possible
339+ #[ cfg( target_pointer_width = "64" ) ]
340+ #[ cfg( not( feature = "rustc_randomized_layouts" ) ) ]
341+ const _: ( ) = {
342+ if size_of:: <Value <' static >>( ) > 64 {
343+ panic!( "{}" , concat!(
344+ "the query `" ,
345+ stringify!( $name) ,
346+ "` has a value type `" ,
347+ stringify!( $V) ,
348+ "` that is too large"
349+ ) ) ;
350+ }
351+ } ;
352+ } ) *
357353
358354 /// Holds per-query arenas for queries with the `arena_cache` modifier.
359355 #[ derive( Default ) ]
@@ -371,10 +367,10 @@ macro_rules! define_callbacks {
371367
372368 #[ derive( Default ) ]
373369 pub struct QueryCaches <' tcx> {
374- $( $( #[ $attr] ) * pub $name: queries :: $name:: Storage <' tcx>, ) *
370+ $( $( #[ $attr] ) * pub $name: $name:: Storage <' tcx>, ) *
375371 }
376372
377- impl <' tcx> TyCtxtEnsureOk <' tcx> {
373+ impl <' tcx> $crate :: query :: TyCtxtEnsureOk <' tcx> {
378374 $( $( #[ $attr] ) *
379375 #[ inline( always) ]
380376 pub fn $name(
@@ -386,21 +382,21 @@ macro_rules! define_callbacks {
386382 self . tcx,
387383 self . tcx. query_system. fns. engine. $name,
388384 & self . tcx. query_system. caches. $name,
389- key . into_query_param( ) ,
385+ $crate :: query :: IntoQueryParam :: into_query_param( key ) ,
390386 false ,
391387 )
392388 } ) *
393389 }
394390
395- impl <' tcx> TyCtxtEnsureDone <' tcx> {
391+ impl <' tcx> $crate :: query :: TyCtxtEnsureDone <' tcx> {
396392 $( $( #[ $attr] ) *
397393 #[ inline( always) ]
398394 pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) {
399395 crate :: query:: inner:: query_ensure(
400396 self . tcx,
401397 self . tcx. query_system. fns. engine. $name,
402398 & self . tcx. query_system. caches. $name,
403- key . into_query_param( ) ,
399+ $crate :: query :: IntoQueryParam :: into_query_param( key ) ,
404400 true ,
405401 ) ;
406402 } ) *
@@ -416,7 +412,7 @@ macro_rules! define_callbacks {
416412 } ) *
417413 }
418414
419- impl <' tcx> TyCtxtAt <' tcx> {
415+ impl <' tcx> $crate :: query :: TyCtxtAt <' tcx> {
420416 $( $( #[ $attr] ) *
421417 #[ inline( always) ]
422418 pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) -> $V
@@ -428,7 +424,7 @@ macro_rules! define_callbacks {
428424 self . tcx. query_system. fns. engine. $name,
429425 & self . tcx. query_system. caches. $name,
430426 self . span,
431- key . into_query_param( ) ,
427+ $crate :: query :: IntoQueryParam :: into_query_param( key ) ,
432428 ) )
433429 } ) *
434430 }
@@ -438,22 +434,22 @@ macro_rules! define_callbacks {
438434 /// ("Per" just makes this pluralized name more visually distinct.)
439435 pub struct PerQueryVTables <' tcx> {
440436 $(
441- pub $name: :: rustc_middle:: query:: plumbing:: QueryVTable <' tcx, queries :: $name:: Storage <' tcx>>,
437+ pub $name: :: rustc_middle:: query:: plumbing:: QueryVTable <' tcx, $name:: Storage <' tcx>>,
442438 ) *
443439 }
444440
445441 #[ derive( Default ) ]
446442 pub struct QueryStates <' tcx> {
447443 $(
448- pub $name: QueryState <' tcx, $( $K) * >,
444+ pub $name: $crate :: query :: QueryState <' tcx, $( $K) * >,
449445 ) *
450446 }
451447
452448 pub struct Providers {
453449 $( pub $name: for <' tcx> fn (
454450 TyCtxt <' tcx>,
455- queries :: $name:: LocalKey <' tcx>,
456- ) -> queries :: $name:: ProvidedValue <' tcx>, ) *
451+ $name:: LocalKey <' tcx>,
452+ ) -> $name:: ProvidedValue <' tcx>, ) *
457453 }
458454
459455 pub struct ExternProviders {
@@ -490,23 +486,23 @@ macro_rules! define_callbacks {
490486 $( pub $name: for <' tcx> fn (
491487 TyCtxt <' tcx>,
492488 Span ,
493- queries :: $name:: Key <' tcx>,
494- QueryMode ,
489+ $name:: Key <' tcx>,
490+ $crate :: query :: QueryMode ,
495491 ) -> Option <$crate:: query:: erase:: Erased <$V>>, ) *
496492 }
497493 } ;
498494}
499495
500496macro_rules! define_feedable {
501497 ( $( $( #[ $attr: meta] ) * [ $( $modifiers: tt) * ] fn $name: ident( $( $K: tt) * ) -> $V: ty, ) * ) => {
502- $( impl <' tcx, K : IntoQueryParam <$( $K) * > + Copy > TyCtxtFeed <' tcx, K > {
498+ $( impl <' tcx, K : $crate :: query :: IntoQueryParam <$( $K) * > + Copy > TyCtxtFeed <' tcx, K > {
503499 $( #[ $attr] ) *
504500 #[ inline( always) ]
505- pub fn $name( self , value: queries :: $name:: ProvidedValue <' tcx>) {
501+ pub fn $name( self , value: $name:: ProvidedValue <' tcx>) {
506502 let key = self . key( ) . into_query_param( ) ;
507503
508504 let tcx = self . tcx;
509- let erased_value = queries :: $name:: provided_to_erased( tcx, value) ;
505+ let erased_value = $name:: provided_to_erased( tcx, value) ;
510506
511507 let dep_kind: dep_graph:: DepKind = dep_graph:: dep_kinds:: $name;
512508
0 commit comments