1
Fork 0

Simplify NodeItem

The generic parameter is unused, and so is `map`
This commit is contained in:
Jonas Schievink 2020-03-28 21:15:45 +01:00
commit a1e7495a41
2 changed files with 8 additions and 12 deletions

View file

@ -154,15 +154,9 @@ impl Iterator for Ancestors<'_> {
}
}
pub struct NodeItem<T> {
pub struct NodeItem {
pub node: Node,
pub item: T,
}
impl<T> NodeItem<T> {
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> NodeItem<U> {
NodeItem { node: self.node, item: f(self.item) }
}
pub item: ty::AssocItem,
}
impl<'tcx> Ancestors<'tcx> {
@ -173,7 +167,7 @@ impl<'tcx> Ancestors<'tcx> {
tcx: TyCtxt<'tcx>,
trait_item_name: Ident,
trait_item_kind: ty::AssocKind,
) -> Option<NodeItem<ty::AssocItem>> {
) -> Option<NodeItem> {
let trait_def_id = self.trait_def_id;
self.find_map(|node| {
node.item(tcx, trait_item_name, trait_item_kind, trait_def_id)
@ -183,8 +177,10 @@ impl<'tcx> Ancestors<'tcx> {
}
/// Walk up the specialization ancestors of a given impl, starting with that
/// impl itself. Returns `None` if an error was reported while building the
/// specialization graph.
/// impl itself.
///
/// Returns `Err` if an error was reported while building the specialization
/// graph.
pub fn ancestors(
tcx: TyCtxt<'tcx>,
trait_def_id: DefId,

View file

@ -1447,7 +1447,7 @@ fn assoc_ty_def(
selcx: &SelectionContext<'_, '_>,
impl_def_id: DefId,
assoc_ty_def_id: DefId,
) -> Result<specialization_graph::NodeItem<ty::AssocItem>, ErrorReported> {
) -> Result<specialization_graph::NodeItem, ErrorReported> {
let tcx = selcx.tcx();
let assoc_ty_name = tcx.associated_item(assoc_ty_def_id).ident;
let trait_def_id = tcx.impl_trait_ref(impl_def_id).unwrap().def_id;