From a507b8ec3ea83a2500a8d355c4e17e10f70332d0 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Sat, 3 Apr 2021 14:02:09 +0300 Subject: [PATCH] Fix cfail tests in const generics --- cfail/ui/freeze.rs | 2 +- cfail/ui/freeze.stderr | 22 +++++------ cfail/ui/not-send.rs | 6 +-- cfail/ui/not-send.stderr | 79 ++++++++++++++++++++++------------------ 4 files changed, 57 insertions(+), 52 deletions(-) diff --git a/cfail/ui/freeze.rs b/cfail/ui/freeze.rs index b5e5ace6..b9701892 100644 --- a/cfail/ui/freeze.rs +++ b/cfail/ui/freeze.rs @@ -1,7 +1,7 @@ use heapless::{spsc::Queue}; fn main() { - let mut q: Queue = Queue::new(); + let mut q: Queue = Queue::new(); let (_p, mut _c) = q.split(); q.enqueue(0).unwrap(); diff --git a/cfail/ui/freeze.stderr b/cfail/ui/freeze.stderr index 40eabe48..56c116e3 100644 --- a/cfail/ui/freeze.stderr +++ b/cfail/ui/freeze.stderr @@ -1,13 +1,9 @@ -error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied - --> $DIR/freeze.rs:4:16 - | -4 | let mut q: Queue = Queue::new(); - | ^^^^^ --- help: remove this generic argument - | | - | expected 3 generic arguments - | -note: struct defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/mod.rs:151:12 - | -151 | pub struct Queue - | ^^^^^ - - - +error[E0499]: cannot borrow `q` as mutable more than once at a time + --> $DIR/freeze.rs:7:5 + | +6 | let (_p, mut _c) = q.split(); + | - first mutable borrow occurs here +7 | q.enqueue(0).unwrap(); + | ^ second mutable borrow occurs here +8 | _c.dequeue(); + | -- first borrow later used here diff --git a/cfail/ui/not-send.rs b/cfail/ui/not-send.rs index f5ea87c6..6912f2ac 100644 --- a/cfail/ui/not-send.rs +++ b/cfail/ui/not-send.rs @@ -15,8 +15,8 @@ where } fn main() { - is_send::>(); - is_send::>(); - is_send::>(); + is_send::>(); + is_send::>(); + is_send::>(); is_send::>(); } diff --git a/cfail/ui/not-send.stderr b/cfail/ui/not-send.stderr index 544fc8cc..c09e4468 100644 --- a/cfail/ui/not-send.stderr +++ b/cfail/ui/not-send.stderr @@ -1,44 +1,53 @@ -error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied - --> $DIR/not-send.rs:18:15 +error[E0277]: `*const ()` cannot be sent between threads safely + --> $DIR/not-send.rs:18:5 | -18 | is_send::>(); - | ^^^^^^^^ --- help: remove this generic argument - | | - | expected 3 generic arguments +11 | fn is_send() + | ------- required by a bound in this +12 | where +13 | T: Send, + | ---- required by this bound in `is_send` +... +18 | is_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | -note: struct defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/split.rs:26:12 - | -26 | pub struct Consumer<'a, T, U, const N: usize> - | ^^^^^^^^ - - - + = help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()` + = note: required because it appears within the type `PhantomData<*const ()>` + = note: required because of the requirements on the impl of `Send` for `Consumer<'_, PhantomData<*const ()>, _, 4_usize>` -error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied - --> $DIR/not-send.rs:19:15 +error[E0277]: `*const ()` cannot be sent between threads safely + --> $DIR/not-send.rs:19:5 | -19 | is_send::>(); - | ^^^^^^^^ --- help: remove this generic argument - | | - | expected 3 generic arguments +11 | fn is_send() + | ------- required by a bound in this +12 | where +13 | T: Send, + | ---- required by this bound in `is_send` +... +19 | is_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | -note: struct defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/split.rs:43:12 - | -43 | pub struct Producer<'a, T, U, const N: usize> - | ^^^^^^^^ - - - + = help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()` + = note: required because it appears within the type `PhantomData<*const ()>` + = note: required because of the requirements on the impl of `Send` for `Producer<'_, PhantomData<*const ()>, _, 4_usize>` -error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied - --> $DIR/not-send.rs:20:15 - | -20 | is_send::>(); - | ^^^^^ --- help: remove this generic argument - | | - | expected 3 generic arguments - | -note: struct defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/mod.rs:151:12 - | -151 | pub struct Queue - | ^^^^^ - - - +error[E0277]: `*const ()` cannot be sent between threads safely + --> $DIR/not-send.rs:20:5 + | +11 | fn is_send() + | ------- required by a bound in this +12 | where +13 | T: Send, + | ---- required by this bound in `is_send` +... +20 | is_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely + | + = help: within `Queue, _, 4_usize>`, the trait `Send` is not implemented for `*const ()` + = note: required because it appears within the type `PhantomData<*const ()>` + = note: required because it appears within the type `[PhantomData<*const ()>; 4]` + = note: required because it appears within the type `ManuallyDrop<[PhantomData<*const ()>; 4]>` + = note: required because it appears within the type `MaybeUninit<[PhantomData<*const ()>; 4]>` + = note: required because it appears within the type `Queue, _, 4_usize>` error[E0277]: `*const ()` cannot be sent between threads safely --> $DIR/not-send.rs:21:5