Skip to content

Commit 5d294a7

Browse files
authored
Merge pull request #202 from kpp/fix_cfail
Fix cfail tests in const generics
2 parents fbf8c4d + a507b8e commit 5d294a7

File tree

4 files changed

+57
-52
lines changed

4 files changed

+57
-52
lines changed

cfail/ui/freeze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use heapless::{spsc::Queue};
22

33
fn main() {
4-
let mut q: Queue<u8, _, _, 4> = Queue::new();
4+
let mut q: Queue<u8, _, 4> = Queue::new();
55

66
let (_p, mut _c) = q.split();
77
q.enqueue(0).unwrap();

cfail/ui/freeze.stderr

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

cfail/ui/not-send.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ where
1515
}
1616

1717
fn main() {
18-
is_send::<Consumer<NotSend, _, _, 4>>();
19-
is_send::<Producer<NotSend, _, _, 4>>();
20-
is_send::<Queue<NotSend, _, _, 4>>();
18+
is_send::<Consumer<NotSend, _, 4>>();
19+
is_send::<Producer<NotSend, _, 4>>();
20+
is_send::<Queue<NotSend, _, 4>>();
2121
is_send::<heapless::Vec<NotSend, 4>>();
2222
}

cfail/ui/not-send.stderr

+44-35
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
1-
error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied
2-
--> $DIR/not-send.rs:18:15
3-
|
4-
18 | is_send::<Consumer<NotSend, _, _, 4>>();
5-
| ^^^^^^^^ --- help: remove this generic argument
6-
| |
7-
| expected 3 generic arguments
1+
error[E0277]: `*const ()` cannot be sent between threads safely
2+
--> $DIR/not-send.rs:18:5
83
|
9-
note: struct defined here, with 3 generic parameters: `T`, `U`, `N`
10-
--> $DIR/split.rs:26:12
4+
11 | fn is_send<T>()
5+
| ------- required by a bound in this
6+
12 | where
7+
13 | T: Send,
8+
| ---- required by this bound in `is_send`
9+
...
10+
18 | is_send::<Consumer<NotSend, _, 4>>();
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
1112
|
12-
26 | pub struct Consumer<'a, T, U, const N: usize>
13-
| ^^^^^^^^ - - -
13+
= help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()`
14+
= note: required because it appears within the type `PhantomData<*const ()>`
15+
= note: required because of the requirements on the impl of `Send` for `Consumer<'_, PhantomData<*const ()>, _, 4_usize>`
1416

15-
error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied
16-
--> $DIR/not-send.rs:19:15
17-
|
18-
19 | is_send::<Producer<NotSend, _, _, 4>>();
19-
| ^^^^^^^^ --- help: remove this generic argument
20-
| |
21-
| expected 3 generic arguments
17+
error[E0277]: `*const ()` cannot be sent between threads safely
18+
--> $DIR/not-send.rs:19:5
2219
|
23-
note: struct defined here, with 3 generic parameters: `T`, `U`, `N`
24-
--> $DIR/split.rs:43:12
20+
11 | fn is_send<T>()
21+
| ------- required by a bound in this
22+
12 | where
23+
13 | T: Send,
24+
| ---- required by this bound in `is_send`
25+
...
26+
19 | is_send::<Producer<NotSend, _, 4>>();
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
2528
|
26-
43 | pub struct Producer<'a, T, U, const N: usize>
27-
| ^^^^^^^^ - - -
29+
= help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()`
30+
= note: required because it appears within the type `PhantomData<*const ()>`
31+
= note: required because of the requirements on the impl of `Send` for `Producer<'_, PhantomData<*const ()>, _, 4_usize>`
2832

29-
error[E0107]: this struct takes 3 generic arguments but 4 generic arguments were supplied
30-
--> $DIR/not-send.rs:20:15
31-
|
32-
20 | is_send::<Queue<NotSend, _, _, 4>>();
33-
| ^^^^^ --- help: remove this generic argument
34-
| |
35-
| expected 3 generic arguments
36-
|
37-
note: struct defined here, with 3 generic parameters: `T`, `U`, `N`
38-
--> $DIR/mod.rs:151:12
39-
|
40-
151 | pub struct Queue<T, U, const N: usize>
41-
| ^^^^^ - - -
33+
error[E0277]: `*const ()` cannot be sent between threads safely
34+
--> $DIR/not-send.rs:20:5
35+
|
36+
11 | fn is_send<T>()
37+
| ------- required by a bound in this
38+
12 | where
39+
13 | T: Send,
40+
| ---- required by this bound in `is_send`
41+
...
42+
20 | is_send::<Queue<NotSend, _, 4>>();
43+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
44+
|
45+
= help: within `Queue<PhantomData<*const ()>, _, 4_usize>`, the trait `Send` is not implemented for `*const ()`
46+
= note: required because it appears within the type `PhantomData<*const ()>`
47+
= note: required because it appears within the type `[PhantomData<*const ()>; 4]`
48+
= note: required because it appears within the type `ManuallyDrop<[PhantomData<*const ()>; 4]>`
49+
= note: required because it appears within the type `MaybeUninit<[PhantomData<*const ()>; 4]>`
50+
= note: required because it appears within the type `Queue<PhantomData<*const ()>, _, 4_usize>`
4251

4352
error[E0277]: `*const ()` cannot be sent between threads safely
4453
--> $DIR/not-send.rs:21:5

0 commit comments

Comments
 (0)