Merge pull request #202 from kpp/fix_cfail

Fix cfail tests in const generics
This commit is contained in:
Emil Fresk 2021-04-03 14:01:10 +02:00 committed by GitHub
commit 5d294a700f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 52 deletions

View File

@ -1,7 +1,7 @@
use heapless::{spsc::Queue}; use heapless::{spsc::Queue};
fn main() { fn main() {
let mut q: Queue<u8, _, _, 4> = Queue::new(); let mut q: Queue<u8, _, 4> = Queue::new();
let (_p, mut _c) = q.split(); let (_p, mut _c) = q.split();
q.enqueue(0).unwrap(); q.enqueue(0).unwrap();

View File

@ -1,13 +1,9 @@
error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied error[E0499]: cannot borrow `q` as mutable more than once at a time
--> $DIR/freeze.rs:4:16 --> $DIR/freeze.rs:7:5
| |
4 | let mut q: Queue<u8, _, _, 4> = Queue::new(); 6 | let (_p, mut _c) = q.split();
| ^^^^^ --- help: remove this generic argument | - first mutable borrow occurs here
| | 7 | q.enqueue(0).unwrap();
| expected 3 generic arguments | ^ second mutable borrow occurs here
| 8 | _c.dequeue();
note: struct defined here, with 3 generic parameters: `T`, `U`, `N` | -- first borrow later used here
--> $DIR/mod.rs:151:12
|
151 | pub struct Queue<T, U, const N: usize>
| ^^^^^ - - -

View File

@ -15,8 +15,8 @@ where
} }
fn main() { fn main() {
is_send::<Consumer<NotSend, _, _, 4>>(); is_send::<Consumer<NotSend, _, 4>>();
is_send::<Producer<NotSend, _, _, 4>>(); is_send::<Producer<NotSend, _, 4>>();
is_send::<Queue<NotSend, _, _, 4>>(); is_send::<Queue<NotSend, _, 4>>();
is_send::<heapless::Vec<NotSend, 4>>(); is_send::<heapless::Vec<NotSend, 4>>();
} }

View File

@ -1,44 +1,53 @@
error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied error[E0277]: `*const ()` cannot be sent between threads safely
--> $DIR/not-send.rs:18:15 --> $DIR/not-send.rs:18:5
| |
18 | is_send::<Consumer<NotSend, _, _, 4>>(); 11 | fn is_send<T>()
| ^^^^^^^^ --- help: remove this generic argument | ------- required by a bound in this
| | 12 | where
| expected 3 generic arguments 13 | T: Send,
| ---- required by this bound in `is_send`
...
18 | is_send::<Consumer<NotSend, _, 4>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
| |
note: struct defined here, with 3 generic parameters: `T`, `U`, `N` = help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()`
--> $DIR/split.rs:26:12 = 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>`
26 | pub struct Consumer<'a, T, U, const N: usize>
| ^^^^^^^^ - - -
error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied error[E0277]: `*const ()` cannot be sent between threads safely
--> $DIR/not-send.rs:19:15 --> $DIR/not-send.rs:19:5
| |
19 | is_send::<Producer<NotSend, _, _, 4>>(); 11 | fn is_send<T>()
| ^^^^^^^^ --- help: remove this generic argument | ------- required by a bound in this
| | 12 | where
| expected 3 generic arguments 13 | T: Send,
| ---- required by this bound in `is_send`
...
19 | is_send::<Producer<NotSend, _, 4>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
| |
note: struct defined here, with 3 generic parameters: `T`, `U`, `N` = help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()`
--> $DIR/split.rs:43:12 = 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>`
43 | pub struct Producer<'a, T, U, const N: usize>
| ^^^^^^^^ - - -
error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied error[E0277]: `*const ()` cannot be sent between threads safely
--> $DIR/not-send.rs:20:15 --> $DIR/not-send.rs:20:5
| |
20 | is_send::<Queue<NotSend, _, _, 4>>(); 11 | fn is_send<T>()
| ^^^^^ --- help: remove this generic argument | ------- required by a bound in this
| | 12 | where
| expected 3 generic arguments 13 | T: Send,
| ---- required by this bound in `is_send`
...
20 | is_send::<Queue<NotSend, _, 4>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
| |
note: struct defined here, with 3 generic parameters: `T`, `U`, `N` = help: within `Queue<PhantomData<*const ()>, _, 4_usize>`, the trait `Send` is not implemented for `*const ()`
--> $DIR/mod.rs:151:12 = note: required because it appears within the type `PhantomData<*const ()>`
| = note: required because it appears within the type `[PhantomData<*const ()>; 4]`
151 | pub struct Queue<T, U, const N: usize> = 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<PhantomData<*const ()>, _, 4_usize>`
error[E0277]: `*const ()` cannot be sent between threads safely error[E0277]: `*const ()` cannot be sent between threads safely
--> $DIR/not-send.rs:21:5 --> $DIR/not-send.rs:21:5