summaryrefslogtreecommitdiff
path: root/vendor/rayon/src/compile_fail/must_use.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/rayon/src/compile_fail/must_use.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/rayon/src/compile_fail/must_use.rs')
-rw-r--r--vendor/rayon/src/compile_fail/must_use.rs69
1 files changed, 69 insertions, 0 deletions
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); */
+}