]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_hir/src/hir.rs
Rollup merge of #101690 - kadiwa4:avoid_iterator_last, r=oli-obk
[rust.git] / compiler / rustc_hir / src / hir.rs
index c0f93b7c3382a32d3aa4cdbd4cd7085dc8c0313e..1d62caef9b7a312cca3e7962680da0ece84bb87a 100644 (file)
@@ -576,8 +576,7 @@ pub fn tail_span_for_predicate_suggestion(&self) -> Span {
         if self.has_where_clause_predicates {
             self.predicates
                 .iter()
-                .filter(|p| p.in_where_clause())
-                .last()
+                .rfind(|&p| p.in_where_clause())
                 .map_or(end, |p| p.span())
                 .shrink_to_hi()
                 .to(end)
@@ -835,7 +834,16 @@ pub fn node(&self) -> OwnerNode<'tcx> {
 impl fmt::Debug for OwnerNodes<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_struct("OwnerNodes")
+            // Do not print all the pointers to all the nodes, as it would be unreadable.
             .field("node", &self.nodes[ItemLocalId::from_u32(0)])
+            .field(
+                "parents",
+                &self
+                    .nodes
+                    .iter_enumerated()
+                    .map(|(id, parented_node)| (id, parented_node.as_ref().map(|node| node.parent)))
+                    .collect::<Vec<_>>(),
+            )
             .field("bodies", &self.bodies)
             .field("local_id_to_def_id", &self.local_id_to_def_id)
             .field("hash_without_bodies", &self.hash_without_bodies)