@@ -29,7 +29,6 @@ use infer::type_variable::TypeVariableOrigin;
29
29
use rustc_data_structures:: snapshot_map:: { Snapshot , SnapshotMap } ;
30
30
use syntax:: ast;
31
31
use syntax:: symbol:: Symbol ;
32
- use syntax_pos:: DUMMY_SP ;
33
32
use ty:: subst:: Subst ;
34
33
use ty:: { self , ToPredicate , ToPolyTraitRef , Ty , TyCtxt } ;
35
34
use ty:: fold:: { TypeFoldable , TypeFolder } ;
@@ -1324,32 +1323,24 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>(
1324
1323
1325
1324
// This function may be called while we are still building the
1326
1325
// specialization graph that is queried below (via TraidDef::ancestors()),
1327
- // so, in order to avoid infinite recursion, we detect this case by
1328
- // seeing if a query of the specialization graph fails with a cycle error.
1329
- // If we are in cycle, and thus still building the graph, we perform a
1330
- // reduced version of the associated item lookup that does not need the
1331
- // specialization graph.
1332
- let specialization_graph_complete =
1333
- ty:: queries:: specialization_graph_of:: try_get ( tcx,
1334
- DUMMY_SP ,
1335
- trait_def_id) . is_ok ( ) ;
1336
- if !specialization_graph_complete {
1337
- let impl_node = specialization_graph:: Node :: Impl ( impl_def_id) ;
1338
- for item in impl_node. items ( tcx) {
1339
- if item. kind == ty:: AssociatedKind :: Type && item. name == assoc_ty_name {
1340
- return Some ( specialization_graph:: NodeItem {
1341
- node : specialization_graph:: Node :: Impl ( impl_def_id) ,
1342
- item : item,
1343
- } ) ;
1344
- }
1326
+ // so, in order to avoid unnecessary infinite recursion, we manually look
1327
+ // for the associated item at the given impl.
1328
+ // If there is no such item in that impl, this function will fail with a
1329
+ // cycle error if the specialization graph is currently being built.
1330
+ let impl_node = specialization_graph:: Node :: Impl ( impl_def_id) ;
1331
+ for item in impl_node. items ( tcx) {
1332
+ if item. kind == ty:: AssociatedKind :: Type && item. name == assoc_ty_name {
1333
+ return Some ( specialization_graph:: NodeItem {
1334
+ node : specialization_graph:: Node :: Impl ( impl_def_id) ,
1335
+ item : item,
1336
+ } ) ;
1345
1337
}
1346
- None
1347
- } else {
1348
- trait_def
1349
- . ancestors ( tcx, impl_def_id)
1350
- . defs ( tcx, assoc_ty_name, ty:: AssociatedKind :: Type )
1351
- . next ( )
1352
1338
}
1339
+
1340
+ trait_def
1341
+ . ancestors ( tcx, impl_def_id)
1342
+ . defs ( tcx, assoc_ty_name, ty:: AssociatedKind :: Type )
1343
+ . next ( )
1353
1344
}
1354
1345
1355
1346
// # Cache
0 commit comments