]> git.lizzy.rs Git - rust.git/commitdiff
use find(x) instead of filter(x).next()
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 26 Feb 2020 22:03:45 +0000 (23:03 +0100)
committerMatthias Krüger <matthias.krueger@famsik.de>
Thu, 27 Feb 2020 13:50:54 +0000 (14:50 +0100)
src/librustc/ty/print/pretty.rs
src/librustc_infer/traits/coherence.rs
src/librustc_infer/traits/error_reporting/mod.rs
src/librustc_parse/lexer/tokentrees.rs
src/librustc_parse/parser/expr.rs
src/librustdoc/clean/types.rs

index 0726bf30d3b3485c18c6e3e50e5510606c43d578..3512b24ec487778124597a7a7bef16cf876a9ca6 100644 (file)
@@ -136,7 +136,7 @@ pub fn maybe_highlighting_region(
     pub fn highlighting_region(&mut self, region: ty::Region<'_>, number: usize) {
         let num_slots = self.highlight_regions.len();
         let first_avail_slot =
-            self.highlight_regions.iter_mut().filter(|s| s.is_none()).next().unwrap_or_else(|| {
+            self.highlight_regions.iter_mut().find(|s| s.is_none()).unwrap_or_else(|| {
                 bug!("can only highlight {} placeholders at a time", num_slots,)
             });
         *first_avail_slot = Some((*region, number));
index 43c0fbc27e620f597757360c930b5ebb44dc9000..d94231653abd49eab7bca9dd4486c247b2e57f2e 100644 (file)
@@ -399,8 +399,7 @@ fn uncover_fundamental_ty<'tcx>(
             let local_type = trait_ref
                 .input_types()
                 .flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
-                .filter(|ty| ty_is_non_local_constructor(ty, in_crate).is_none())
-                .next();
+                .find(|ty| ty_is_non_local_constructor(ty, in_crate).is_none());
 
             debug!("orphan_check_trait_ref: uncovered ty local_type: `{:?}`", local_type);
 
index 2fc7c17897739f1a4befce0912ab0e32c946b9ee..9bfa2196950963577f18aa4d4b4d41b4f729d360 100644 (file)
@@ -1442,7 +1442,7 @@ pub fn suggest_constraining_type_param(
     const MSG_RESTRICT_TYPE: &str = "consider restricting this type parameter with";
     const MSG_RESTRICT_TYPE_FURTHER: &str = "consider further restricting this type parameter with";
 
-    let param = generics.params.iter().filter(|p| p.name.ident().as_str() == param_name).next();
+    let param = generics.params.iter().find(|p| p.name.ident().as_str() == param_name);
 
     let param = if let Some(param) = param {
         param
index c28b59a7908015572cce6e33c3d1858a8536cf88..20a7fcb650a2e17ba3fa8d62dd17b5aa37dc3265 100644 (file)
@@ -93,10 +93,8 @@ fn parse_token_tree(&mut self) -> PResult<'a, TreeAndJoint> {
                 }
 
                 if let Some((delim, _)) = self.open_braces.last() {
-                    if let Some((_, open_sp, close_sp)) = self
-                        .matching_delim_spans
-                        .iter()
-                        .filter(|(d, open_sp, close_sp)| {
+                    if let Some((_, open_sp, close_sp)) =
+                        self.matching_delim_spans.iter().find(|(d, open_sp, close_sp)| {
                             if let Some(close_padding) = sm.span_to_margin(*close_sp) {
                                 if let Some(open_padding) = sm.span_to_margin(*open_sp) {
                                     return delim == d && close_padding != open_padding;
@@ -104,7 +102,6 @@ fn parse_token_tree(&mut self) -> PResult<'a, TreeAndJoint> {
                             }
                             false
                         })
-                        .next()
                     // these are in reverse order as they get inserted on close, but
                     {
                         // we want the last open/first close
index 3ae97ed5f88229331505f2b2d5087f648d8c6f44..b8f67e73bc3f72897b9aa593cf1864ccde73f38c 100644 (file)
@@ -225,12 +225,8 @@ pub(super) fn parse_assoc_expr_with(
 
             // Make sure that the span of the parent node is larger than the span of lhs and rhs,
             // including the attributes.
-            let lhs_span = lhs
-                .attrs
-                .iter()
-                .filter(|a| a.style == AttrStyle::Outer)
-                .next()
-                .map_or(lhs_span, |a| a.span);
+            let lhs_span =
+                lhs.attrs.iter().find(|a| a.style == AttrStyle::Outer).map_or(lhs_span, |a| a.span);
             let span = lhs_span.to(rhs.span);
             lhs = match op {
                 AssocOp::Add
index 2f220cbc9be8cf56e25f25194362274857a24da9..4f58116e4fea8167ff4f6c27cedbf7c3f8088e83 100644 (file)
@@ -565,8 +565,7 @@ pub fn from_ast(diagnostic: &::rustc_errors::Handler, attrs: &[ast::Attribute])
 
         let inner_docs = attrs
             .iter()
-            .filter(|a| a.doc_str().is_some())
-            .next()
+            .find(|a| a.doc_str().is_some())
             .map_or(true, |a| a.style == AttrStyle::Inner);
 
         Attributes {