about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-02-28 01:55:45 +0100
committerGitHub <noreply@github.com>2020-02-28 01:55:45 +0100
commit5b32dd034ef2799c0ea648c6f55e6aa14ce444f4 (patch)
tree1702cb40dd41b524b83447b7c85ee51f82a39541 /src
parentb19e822b9b513c16a8643f8157d8e3c20d6405f6 (diff)
parent896a0814427827e0e0346544c92e5ddc390ad29f (diff)
downloadrust-5b32dd034ef2799c0ea648c6f55e6aa14ce444f4.tar.gz
rust-5b32dd034ef2799c0ea648c6f55e6aa14ce444f4.zip
Rollup merge of #69496 - matthiaskrgr:filter_next, r=ecstatic-morse
use find(x) instead of filter(x).next()
Diffstat (limited to 'src')
-rw-r--r--src/librustc/ty/print/pretty.rs2
-rw-r--r--src/librustc_infer/traits/coherence.rs3
-rw-r--r--src/librustc_infer/traits/error_reporting/mod.rs2
-rw-r--r--src/librustc_parse/lexer/tokentrees.rs7
-rw-r--r--src/librustc_parse/parser/expr.rs8
-rw-r--r--src/librustdoc/clean/types.rs3
6 files changed, 8 insertions, 17 deletions
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs
index 0726bf30d3b..3512b24ec48 100644
--- a/src/librustc/ty/print/pretty.rs
+++ b/src/librustc/ty/print/pretty.rs
@@ -136,7 +136,7 @@ impl RegionHighlightMode {
     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));
diff --git a/src/librustc_infer/traits/coherence.rs b/src/librustc_infer/traits/coherence.rs
index 43c0fbc27e6..d94231653ab 100644
--- a/src/librustc_infer/traits/coherence.rs
+++ b/src/librustc_infer/traits/coherence.rs
@@ -399,8 +399,7 @@ fn orphan_check_trait_ref<'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);
 
diff --git a/src/librustc_infer/traits/error_reporting/mod.rs b/src/librustc_infer/traits/error_reporting/mod.rs
index 2fc7c178977..9bfa2196950 100644
--- a/src/librustc_infer/traits/error_reporting/mod.rs
+++ b/src/librustc_infer/traits/error_reporting/mod.rs
@@ -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
diff --git a/src/librustc_parse/lexer/tokentrees.rs b/src/librustc_parse/lexer/tokentrees.rs
index c28b59a7908..20a7fcb650a 100644
--- a/src/librustc_parse/lexer/tokentrees.rs
+++ b/src/librustc_parse/lexer/tokentrees.rs
@@ -93,10 +93,8 @@ impl<'a> TokenTreesReader<'a> {
                 }
 
                 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 @@ impl<'a> TokenTreesReader<'a> {
                             }
                             false
                         })
-                        .next()
                     // these are in reverse order as they get inserted on close, but
                     {
                         // we want the last open/first close
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs
index 3ae97ed5f88..b8f67e73bc3 100644
--- a/src/librustc_parse/parser/expr.rs
+++ b/src/librustc_parse/parser/expr.rs
@@ -225,12 +225,8 @@ impl<'a> Parser<'a> {
 
             // 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
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 2f220cbc9be..4f58116e4fe 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -565,8 +565,7 @@ impl Attributes {
 
         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 {