@@ -1431,7 +1431,7 @@ impl<'tcx> TyCtxt<'tcx> {
14311431#[ instrument( level = "trace" , skip( tcx) , ret) ]
14321432fn create_def_raw_provider < ' tcx > (
14331433 tcx : TyCtxt < ' tcx > ,
1434- ( parent, data, query, index) : ( LocalDefId , DefPathData , Option < DepNode > , usize ) ,
1434+ ( parent, data, query, index) : ( LocalDefId , DefPathData , DepNode , usize ) ,
14351435) -> LocalDefId {
14361436 // `query` and `index` are guaranteed to change for each successive call to
14371437 // `create_def_raw`, but in a predictable manner.
@@ -1482,31 +1482,30 @@ impl<'tcx> TyCtxt<'tcx> {
14821482 ) -> TyCtxtFeed < ' tcx , LocalDefId > {
14831483 let data = override_def_path_data. unwrap_or_else ( || def_kind. def_path_data ( name) ) ;
14841484
1485- // `create_def_raw` is a query, so it can be replayed by the dep-graph engine. However, we
1486- // may invoke it multiple times with the same `(parent, data)` pair, and we expect to
1487- // create *different* definitions from them. In order to make this compatible with the
1488- // general model of queries, we add additional information which must change at each call.
1489- let ( dep_node, query_local_index) = ty:: tls:: with_context ( |icx| match icx. task_deps {
1490- // If we are inside a query, we can only use local information, and no global
1491- // mutable state. The current query's name and the number of calls to `create_def`
1492- // are local to the current query, so are ok to use.
1485+ let def_id = ty:: tls:: with_context ( |icx| match icx. task_deps {
1486+ // `create_def_raw` is a query, so it can be replayed by the dep-graph engine.
1487+ // However, we may invoke it multiple times with the same `(parent, data)` pair,
1488+ // and we expect to create *different* definitions from them.
1489+ //
1490+ // In order to make this compatible with the general model of queries, we add
1491+ // additional information which must change at each call.
14931492 TaskDepsRef :: Allow ( deps) => {
14941493 let opt_dep_node_and_index = deps. lock ( ) . next_query_local_index ( ) ;
1495- if let Some ( ( dep_node, index) ) = opt_dep_node_and_index {
1496- ( Some ( dep_node) , index)
1497- } else {
1494+ let Some ( ( dep_node, index) ) = opt_dep_node_and_index else {
14981495 // No idea how to support this for now...
14991496 bug ! ( "trying to create a definition from an anonymous query" )
1500- }
1497+ } ;
1498+ self . create_def_raw ( ( parent, data, dep_node, index) )
15011499 }
1502- // If we are not tracking dependencies, we can use global mutable state,
1503- // so we use the total number of definitions as a proxy .
1500+
1501+ // If we are not tracking dependencies, we can use global mutable state .
15041502 TaskDepsRef :: EvalAlways | TaskDepsRef :: Forbid | TaskDepsRef :: Ignore => {
1505- let global_count = self . untracked . definitions . read ( ) . def_index_count ( ) ;
1506- ( None , global_count)
1503+ // This query is `eval_always`, so we can access untracked data.
1504+ let mut disambiguator_state = self . untracked_disambiguator_state . lock ( ) ;
1505+ let disambiguator = disambiguator_state. get_or_create ( parent) ;
1506+ self . untracked . definitions . write ( ) . create_def ( parent, data, disambiguator)
15071507 }
15081508 } ) ;
1509- let def_id = self . create_def_raw ( ( parent, data, dep_node, query_local_index) ) ;
15101509
15111510 let feed = TyCtxtFeed { tcx : self , key : def_id } ;
15121511 feed. def_kind ( def_kind) ;
0 commit comments