Don't use queries::try_get() in assoc_ty projection
This commit is contained in:
parent
742ebc17ff
commit
d731b04af1
@ -29,7 +29,6 @@ use infer::type_variable::TypeVariableOrigin;
|
|||||||
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
|
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
use syntax_pos::DUMMY_SP;
|
|
||||||
use ty::subst::Subst;
|
use ty::subst::Subst;
|
||||||
use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
|
use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
|
||||||
use ty::fold::{TypeFoldable, TypeFolder};
|
use ty::fold::{TypeFoldable, TypeFolder};
|
||||||
@ -1324,32 +1323,24 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>(
|
|||||||
|
|
||||||
// This function may be called while we are still building the
|
// This function may be called while we are still building the
|
||||||
// specialization graph that is queried below (via TraidDef::ancestors()),
|
// specialization graph that is queried below (via TraidDef::ancestors()),
|
||||||
// so, in order to avoid infinite recursion, we detect this case by
|
// so, in order to avoid unnecessary infinite recursion, we manually look
|
||||||
// seeing if a query of the specialization graph fails with a cycle error.
|
// for the associated item at the given impl.
|
||||||
// If we are in cycle, and thus still building the graph, we perform a
|
// If there is no such item in that impl, this function will fail with a
|
||||||
// reduced version of the associated item lookup that does not need the
|
// cycle error if the specialization graph is currently being built.
|
||||||
// specialization graph.
|
let impl_node = specialization_graph::Node::Impl(impl_def_id);
|
||||||
let specialization_graph_complete =
|
for item in impl_node.items(tcx) {
|
||||||
ty::queries::specialization_graph_of::try_get(tcx,
|
if item.kind == ty::AssociatedKind::Type && item.name == assoc_ty_name {
|
||||||
DUMMY_SP,
|
return Some(specialization_graph::NodeItem {
|
||||||
trait_def_id).is_ok();
|
node: specialization_graph::Node::Impl(impl_def_id),
|
||||||
if !specialization_graph_complete {
|
item: item,
|
||||||
let impl_node = specialization_graph::Node::Impl(impl_def_id);
|
});
|
||||||
for item in impl_node.items(tcx) {
|
|
||||||
if item.kind == ty::AssociatedKind::Type && item.name == assoc_ty_name {
|
|
||||||
return Some(specialization_graph::NodeItem {
|
|
||||||
node: specialization_graph::Node::Impl(impl_def_id),
|
|
||||||
item: item,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None
|
|
||||||
} else {
|
|
||||||
trait_def
|
|
||||||
.ancestors(tcx, impl_def_id)
|
|
||||||
.defs(tcx, assoc_ty_name, ty::AssociatedKind::Type)
|
|
||||||
.next()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait_def
|
||||||
|
.ancestors(tcx, impl_def_id)
|
||||||
|
.defs(tcx, assoc_ty_name, ty::AssociatedKind::Type)
|
||||||
|
.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// # Cache
|
// # Cache
|
||||||
|
Loading…
Reference in New Issue
Block a user