Skip to content

Commit d731b04

Browse files
Don't use queries::try_get() in assoc_ty projection
1 parent 742ebc1 commit d731b04

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

src/librustc/traits/project.rs

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use infer::type_variable::TypeVariableOrigin;
2929
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
3030
use syntax::ast;
3131
use syntax::symbol::Symbol;
32-
use syntax_pos::DUMMY_SP;
3332
use ty::subst::Subst;
3433
use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
3534
use ty::fold::{TypeFoldable, TypeFolder};
@@ -1324,32 +1323,24 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>(
13241323

13251324
// This function may be called while we are still building the
13261325
// 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+
});
13451337
}
1346-
None
1347-
} else {
1348-
trait_def
1349-
.ancestors(tcx, impl_def_id)
1350-
.defs(tcx, assoc_ty_name, ty::AssociatedKind::Type)
1351-
.next()
13521338
}
1339+
1340+
trait_def
1341+
.ancestors(tcx, impl_def_id)
1342+
.defs(tcx, assoc_ty_name, ty::AssociatedKind::Type)
1343+
.next()
13531344
}
13541345

13551346
// # Cache

0 commit comments

Comments
 (0)