summaryrefslogtreecommitdiff
path: root/vendor/rayon/src/compile_fail
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rayon/src/compile_fail')
-rw-r--r--vendor/rayon/src/compile_fail/cannot_collect_filtermap_data.rs14
-rw-r--r--vendor/rayon/src/compile_fail/cannot_zip_filtered_data.rs14
-rw-r--r--vendor/rayon/src/compile_fail/cell_par_iter.rs13
-rw-r--r--vendor/rayon/src/compile_fail/mod.rs7
-rw-r--r--vendor/rayon/src/compile_fail/must_use.rs69
-rw-r--r--vendor/rayon/src/compile_fail/no_send_par_iter.rs58
-rw-r--r--vendor/rayon/src/compile_fail/rc_par_iter.rs15
7 files changed, 190 insertions, 0 deletions
diff --git a/vendor/rayon/src/compile_fail/cannot_collect_filtermap_data.rs b/vendor/rayon/src/compile_fail/cannot_collect_filtermap_data.rs
new file mode 100644
index 0000000..bb62ce0
--- /dev/null
+++ b/vendor/rayon/src/compile_fail/cannot_collect_filtermap_data.rs
@@ -0,0 +1,14 @@
+/*! ```compile_fail,E0599
+
+use rayon::prelude::*;
+
+// zip requires data of exact size, but filter yields only bounded
+// size, so check that we cannot apply it.
+
+let a: Vec<usize> = (0..1024).collect();
+let mut v = vec![];
+a.par_iter()
+ .filter_map(|&x| Some(x as f32))
+ .collect_into_vec(&mut v); //~ ERROR no method
+
+``` */
diff --git a/vendor/rayon/src/compile_fail/cannot_zip_filtered_data.rs b/vendor/rayon/src/compile_fail/cannot_zip_filtered_data.rs
new file mode 100644
index 0000000..54fd50d
--- /dev/null
+++ b/vendor/rayon/src/compile_fail/cannot_zip_filtered_data.rs
@@ -0,0 +1,14 @@
+/*! ```compile_fail,E0277
+
+use rayon::prelude::*;
+
+// zip requires data of exact size, but filter yields only bounded
+// size, so check that we cannot apply it.
+
+let mut a: Vec<usize> = (0..1024).rev().collect();
+let b: Vec<usize> = (0..1024).collect();
+
+a.par_iter()
+ .zip(b.par_iter().filter(|&&x| x > 3)); //~ ERROR
+
+``` */
diff --git a/vendor/rayon/src/compile_fail/cell_par_iter.rs b/vendor/rayon/src/compile_fail/cell_par_iter.rs
new file mode 100644
index 0000000..98a1cf9
--- /dev/null
+++ b/vendor/rayon/src/compile_fail/cell_par_iter.rs
@@ -0,0 +1,13 @@
+/*! ```compile_fail,E0277
+
+// Check that we can't use the par-iter API to access contents of a `Cell`.
+
+use rayon::prelude::*;
+use std::cell::Cell;
+
+let c = Cell::new(42_i32);
+(0_i32..1024).into_par_iter()
+ .map(|_| c.get()) //~ ERROR E0277
+ .min();
+
+``` */
diff --git a/vendor/rayon/src/compile_fail/mod.rs b/vendor/rayon/src/compile_fail/mod.rs
new file mode 100644
index 0000000..13209a4
--- /dev/null
+++ b/vendor/rayon/src/compile_fail/mod.rs
@@ -0,0 +1,7 @@
+// These modules contain `compile_fail` doc tests.
+mod cannot_collect_filtermap_data;
+mod cannot_zip_filtered_data;
+mod cell_par_iter;
+mod must_use;
+mod no_send_par_iter;
+mod rc_par_iter;
diff --git a/vendor/rayon/src/compile_fail/must_use.rs b/vendor/rayon/src/compile_fail/must_use.rs
new file mode 100644
index 0000000..b4b3d77
--- /dev/null
+++ b/vendor/rayon/src/compile_fail/must_use.rs
@@ -0,0 +1,69 @@
+// Check that we are flagged for ignoring `must_use` parallel adaptors.
+// (unfortunately there's no error code for `unused_must_use`)
+
+macro_rules! must_use {
+ ($( $name:ident #[$expr:meta] )*) => {$(
+ /// First sanity check that the expression is OK.
+ ///
+ /// ```
+ /// #![deny(unused_must_use)]
+ ///
+ /// use rayon::prelude::*;
+ ///
+ /// let v: Vec<_> = (0..100).map(Some).collect();
+ /// let _ =
+ #[$expr]
+ /// ```
+ ///
+ /// Now trigger the `must_use`.
+ ///
+ /// ```compile_fail
+ /// #![deny(unused_must_use)]
+ ///
+ /// use rayon::prelude::*;
+ ///
+ /// let v: Vec<_> = (0..100).map(Some).collect();
+ #[$expr]
+ /// ```
+ mod $name {}
+ )*}
+}
+
+must_use! {
+ step_by /** v.par_iter().step_by(2); */
+ chain /** v.par_iter().chain(&v); */
+ chunks /** v.par_iter().chunks(2); */
+ fold_chunks /** v.par_iter().fold_chunks(2, || 0, |x, _| x); */
+ fold_chunks_with /** v.par_iter().fold_chunks_with(2, 0, |x, _| x); */
+ cloned /** v.par_iter().cloned(); */
+ copied /** v.par_iter().copied(); */
+ enumerate /** v.par_iter().enumerate(); */
+ filter /** v.par_iter().filter(|_| true); */
+ filter_map /** v.par_iter().filter_map(|x| *x); */
+ flat_map /** v.par_iter().flat_map(|x| *x); */
+ flat_map_iter /** v.par_iter().flat_map_iter(|x| *x); */
+ flatten /** v.par_iter().flatten(); */
+ flatten_iter /** v.par_iter().flatten_iter(); */
+ fold /** v.par_iter().fold(|| 0, |x, _| x); */
+ fold_with /** v.par_iter().fold_with(0, |x, _| x); */
+ try_fold /** v.par_iter().try_fold(|| 0, |x, _| Some(x)); */
+ try_fold_with /** v.par_iter().try_fold_with(0, |x, _| Some(x)); */
+ inspect /** v.par_iter().inspect(|_| {}); */
+ interleave /** v.par_iter().interleave(&v); */
+ interleave_shortest /** v.par_iter().interleave_shortest(&v); */
+ intersperse /** v.par_iter().intersperse(&None); */
+ map /** v.par_iter().map(|x| x); */
+ map_with /** v.par_iter().map_with(0, |_, x| x); */
+ map_init /** v.par_iter().map_init(|| 0, |_, x| x); */
+ panic_fuse /** v.par_iter().panic_fuse(); */
+ positions /** v.par_iter().positions(|_| true); */
+ rev /** v.par_iter().rev(); */
+ skip /** v.par_iter().skip(1); */
+ take /** v.par_iter().take(1); */
+ update /** v.par_iter().update(|_| {}); */
+ while_some /** v.par_iter().cloned().while_some(); */
+ with_max_len /** v.par_iter().with_max_len(1); */
+ with_min_len /** v.par_iter().with_min_len(1); */
+ zip /** v.par_iter().zip(&v); */
+ zip_eq /** v.par_iter().zip_eq(&v); */
+}
diff --git a/vendor/rayon/src/compile_fail/no_send_par_iter.rs b/vendor/rayon/src/compile_fail/no_send_par_iter.rs
new file mode 100644
index 0000000..7573c03
--- /dev/null
+++ b/vendor/rayon/src/compile_fail/no_send_par_iter.rs
@@ -0,0 +1,58 @@
+// Check that `!Send` types fail early.
+
+/** ```compile_fail,E0277
+
+use rayon::prelude::*;
+use std::ptr::null;
+
+#[derive(Copy, Clone)]
+struct NoSend(*const ());
+
+unsafe impl Sync for NoSend {}
+
+let x = Some(NoSend(null()));
+
+x.par_iter()
+ .map(|&x| x) //~ ERROR
+ .count(); //~ ERROR
+
+``` */
+mod map {}
+
+/** ```compile_fail,E0277
+
+use rayon::prelude::*;
+use std::ptr::null;
+
+#[derive(Copy, Clone)]
+struct NoSend(*const ());
+
+unsafe impl Sync for NoSend {}
+
+let x = Some(NoSend(null()));
+
+x.par_iter()
+ .filter_map(|&x| Some(x)) //~ ERROR
+ .count(); //~ ERROR
+
+``` */
+mod filter_map {}
+
+/** ```compile_fail,E0277
+
+use rayon::prelude::*;
+use std::ptr::null;
+
+#[derive(Copy, Clone)]
+struct NoSend(*const ());
+
+unsafe impl Sync for NoSend {}
+
+let x = Some(NoSend(null()));
+
+x.par_iter()
+ .cloned() //~ ERROR
+ .count(); //~ ERROR
+
+``` */
+mod cloned {}
diff --git a/vendor/rayon/src/compile_fail/rc_par_iter.rs b/vendor/rayon/src/compile_fail/rc_par_iter.rs
new file mode 100644
index 0000000..aca63e7
--- /dev/null
+++ b/vendor/rayon/src/compile_fail/rc_par_iter.rs
@@ -0,0 +1,15 @@
+/*! ```compile_fail,E0599
+
+// Check that we can't use the par-iter API to access contents of an
+// `Rc`.
+
+use rayon::prelude::*;
+use std::rc::Rc;
+
+let x = vec![Rc::new(22), Rc::new(23)];
+let mut y = vec![];
+x.into_par_iter() //~ ERROR no method named `into_par_iter`
+ .map(|rc| *rc)
+ .collect_into_vec(&mut y);
+
+``` */