summaryrefslogtreecommitdiffstats
path: root/vendor/rayon-core/src/compile_fail
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/rayon-core/src/compile_fail/mod.rs7
-rw-r--r--vendor/rayon-core/src/compile_fail/quicksort_race1.rs28
-rw-r--r--vendor/rayon-core/src/compile_fail/quicksort_race2.rs28
-rw-r--r--vendor/rayon-core/src/compile_fail/quicksort_race3.rs28
-rw-r--r--vendor/rayon-core/src/compile_fail/rc_return.rs21
-rw-r--r--vendor/rayon-core/src/compile_fail/rc_upvar.rs11
-rw-r--r--vendor/rayon-core/src/compile_fail/scope_join_bad.rs24
7 files changed, 147 insertions, 0 deletions
diff --git a/vendor/rayon-core/src/compile_fail/mod.rs b/vendor/rayon-core/src/compile_fail/mod.rs
new file mode 100644
index 000000000..f2ec646a4
--- /dev/null
+++ b/vendor/rayon-core/src/compile_fail/mod.rs
@@ -0,0 +1,7 @@
+// These modules contain `compile_fail` doc tests.
+mod quicksort_race1;
+mod quicksort_race2;
+mod quicksort_race3;
+mod rc_return;
+mod rc_upvar;
+mod scope_join_bad;
diff --git a/vendor/rayon-core/src/compile_fail/quicksort_race1.rs b/vendor/rayon-core/src/compile_fail/quicksort_race1.rs
new file mode 100644
index 000000000..561503389
--- /dev/null
+++ b/vendor/rayon-core/src/compile_fail/quicksort_race1.rs
@@ -0,0 +1,28 @@
+/*! ```compile_fail,E0524
+
+fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
+ if v.len() <= 1 {
+ return;
+ }
+
+ let mid = partition(v);
+ let (lo, _hi) = v.split_at_mut(mid);
+ rayon_core::join(|| quick_sort(lo), || quick_sort(lo)); //~ ERROR
+}
+
+fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
+ let pivot = v.len() - 1;
+ let mut i = 0;
+ for j in 0..pivot {
+ if v[j] <= v[pivot] {
+ v.swap(i, j);
+ i += 1;
+ }
+ }
+ v.swap(i, pivot);
+ i
+}
+
+fn main() { }
+
+``` */
diff --git a/vendor/rayon-core/src/compile_fail/quicksort_race2.rs b/vendor/rayon-core/src/compile_fail/quicksort_race2.rs
new file mode 100644
index 000000000..020589c29
--- /dev/null
+++ b/vendor/rayon-core/src/compile_fail/quicksort_race2.rs
@@ -0,0 +1,28 @@
+/*! ```compile_fail,E0500
+
+fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
+ if v.len() <= 1 {
+ return;
+ }
+
+ let mid = partition(v);
+ let (lo, _hi) = v.split_at_mut(mid);
+ rayon_core::join(|| quick_sort(lo), || quick_sort(v)); //~ ERROR
+}
+
+fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
+ let pivot = v.len() - 1;
+ let mut i = 0;
+ for j in 0..pivot {
+ if v[j] <= v[pivot] {
+ v.swap(i, j);
+ i += 1;
+ }
+ }
+ v.swap(i, pivot);
+ i
+}
+
+fn main() { }
+
+``` */
diff --git a/vendor/rayon-core/src/compile_fail/quicksort_race3.rs b/vendor/rayon-core/src/compile_fail/quicksort_race3.rs
new file mode 100644
index 000000000..16fbf3b82
--- /dev/null
+++ b/vendor/rayon-core/src/compile_fail/quicksort_race3.rs
@@ -0,0 +1,28 @@
+/*! ```compile_fail,E0524
+
+fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
+ if v.len() <= 1 {
+ return;
+ }
+
+ let mid = partition(v);
+ let (_lo, hi) = v.split_at_mut(mid);
+ rayon_core::join(|| quick_sort(hi), || quick_sort(hi)); //~ ERROR
+}
+
+fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
+ let pivot = v.len() - 1;
+ let mut i = 0;
+ for j in 0..pivot {
+ if v[j] <= v[pivot] {
+ v.swap(i, j);
+ i += 1;
+ }
+ }
+ v.swap(i, pivot);
+ i
+}
+
+fn main() { }
+
+``` */
diff --git a/vendor/rayon-core/src/compile_fail/rc_return.rs b/vendor/rayon-core/src/compile_fail/rc_return.rs
new file mode 100644
index 000000000..164f8ce5e
--- /dev/null
+++ b/vendor/rayon-core/src/compile_fail/rc_return.rs
@@ -0,0 +1,21 @@
+/** ```compile_fail,E0277
+
+use std::rc::Rc;
+
+fn main() {
+ rayon_core::join(|| Rc::new(22), || ()); //~ ERROR
+}
+
+``` */
+mod left {}
+
+/** ```compile_fail,E0277
+
+use std::rc::Rc;
+
+fn main() {
+ rayon_core::join(|| (), || Rc::new(23)); //~ ERROR
+}
+
+``` */
+mod right {}
diff --git a/vendor/rayon-core/src/compile_fail/rc_upvar.rs b/vendor/rayon-core/src/compile_fail/rc_upvar.rs
new file mode 100644
index 000000000..62895bf22
--- /dev/null
+++ b/vendor/rayon-core/src/compile_fail/rc_upvar.rs
@@ -0,0 +1,11 @@
+/*! ```compile_fail,E0277
+
+use std::rc::Rc;
+
+fn main() {
+ let r = Rc::new(22);
+ rayon_core::join(|| r.clone(), || r.clone());
+ //~^ ERROR
+}
+
+``` */
diff --git a/vendor/rayon-core/src/compile_fail/scope_join_bad.rs b/vendor/rayon-core/src/compile_fail/scope_join_bad.rs
new file mode 100644
index 000000000..75e4c5ca6
--- /dev/null
+++ b/vendor/rayon-core/src/compile_fail/scope_join_bad.rs
@@ -0,0 +1,24 @@
+/*! ```compile_fail,E0373
+
+fn bad_scope<F>(f: F)
+ where F: FnOnce(&i32) + Send,
+{
+ rayon_core::scope(|s| {
+ let x = 22;
+ s.spawn(|_| f(&x)); //~ ERROR `x` does not live long enough
+ });
+}
+
+fn good_scope<F>(f: F)
+ where F: FnOnce(&i32) + Send,
+{
+ let x = 22;
+ rayon_core::scope(|s| {
+ s.spawn(|_| f(&x));
+ });
+}
+
+fn main() {
+}
+
+``` */