]> git.lizzy.rs Git - rust.git/commitdiff
Simplify `NodeItem`
authorJonas Schievink <jonasschievink@gmail.com>
Sat, 28 Mar 2020 20:15:45 +0000 (21:15 +0100)
committerJonas Schievink <jonasschievink@gmail.com>
Mon, 30 Mar 2020 17:38:26 +0000 (19:38 +0200)
The generic parameter is unused, and so is `map`

src/librustc_middle/traits/specialization_graph.rs
src/librustc_trait_selection/traits/project.rs

index 1847326a742eb7897b2c83726ad84114da3c91c6..b09f1e66f17740c7682f4320e12acd325053d12c 100644 (file)
@@ -154,15 +154,9 @@ fn next(&mut self) -> Option<Node> {
     }
 }
 
-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 @@ pub fn leaf_def(
         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 @@ pub fn leaf_def(
 }
 
 /// 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,
index 2eb63b8f59030c85e78604f0efc9932af1710772..1e26b62c75951495d4ab529eb69bfaf1cfe57038 100644 (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;