Skip to content

Commit d05b7be

Browse files
authored
Add fn main to UI test files (#157)
This removes one source of errors which clutters the `.stderr` files and is a source of noise when the compiler's error output changes.
1 parent 6b23d21 commit d05b7be

File tree

4 files changed

+61
-77
lines changed

4 files changed

+61
-77
lines changed
Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
error[E0601]: `main` function not found in crate `$CRATE`
2-
--> tests/ui-msrv/transmute-illegal.rs:8:76
3-
|
4-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
5-
| ^ consider adding a `main` function to `$DIR/tests/ui-msrv/transmute-illegal.rs`
6-
71
error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
8-
--> tests/ui-msrv/transmute-illegal.rs:8:30
9-
|
10-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
12-
|
13-
= help: the following implementations were found:
14-
<usize as AsBytes>
15-
<f32 as AsBytes>
16-
<f64 as AsBytes>
17-
<i128 as AsBytes>
18-
and 10 others
2+
--> tests/ui-msrv/transmute-illegal.rs:10:30
3+
|
4+
10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
6+
|
7+
= help: the following implementations were found:
8+
<usize as AsBytes>
9+
<f32 as AsBytes>
10+
<f64 as AsBytes>
11+
<i128 as AsBytes>
12+
and $N others
1913
note: required by a bound in `POINTER_VALUE::transmute`
20-
--> tests/ui-msrv/transmute-illegal.rs:8:30
21-
|
22-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `POINTER_VALUE::transmute`
24-
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
14+
--> tests/ui-msrv/transmute-illegal.rs:10:30
15+
|
16+
10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `POINTER_VALUE::transmute`
18+
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1-
error[E0601]: `main` function not found in crate `$CRATE`
2-
--> tests/ui-stable/transmute-illegal.rs:8:76
3-
|
4-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
5-
| ^ consider adding a `main` function to `$DIR/tests/ui-stable/transmute-illegal.rs`
6-
71
error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
8-
--> tests/ui-stable/transmute-illegal.rs:8:30
9-
|
10-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
12-
|
13-
= help: the following other types implement trait `AsBytes`:
14-
f32
15-
f64
16-
i128
17-
i16
18-
i32
19-
i64
20-
i8
21-
isize
22-
and 6 others
2+
--> tests/ui-stable/transmute-illegal.rs:10:30
3+
|
4+
10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
6+
|
7+
= help: the following other types implement trait `AsBytes`:
8+
f32
9+
f64
10+
i128
11+
i16
12+
i32
13+
i64
14+
i8
15+
isize
16+
and $N others
2317
note: required by a bound in `POINTER_VALUE::transmute`
24-
--> tests/ui-stable/transmute-illegal.rs:8:30
25-
|
26-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
27-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `POINTER_VALUE::transmute`
28-
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
18+
--> tests/ui-stable/transmute-illegal.rs:10:30
19+
|
20+
10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `POINTER_VALUE::transmute`
22+
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/ui/transmute-illegal.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44

55
extern crate zerocopy;
66

7+
fn main() {}
8+
79
// It is unsound to inspect the usize value of a pointer during const eval.
810
const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);

tests/ui/transmute-illegal.stderr

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
error[E0601]: `main` function not found in crate `$CRATE`
2-
--> tests/ui/transmute-illegal.rs:8:76
3-
|
4-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
5-
| ^ consider adding a `main` function to `$DIR/tests/ui/transmute-illegal.rs`
6-
71
error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
8-
--> tests/ui/transmute-illegal.rs:8:30
9-
|
10-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
| |
13-
| the trait `AsBytes` is not implemented for `*const usize`
14-
| required by a bound introduced by this call
15-
|
16-
= help: the following other types implement trait `AsBytes`:
17-
f32
18-
f64
19-
i128
20-
i16
21-
i32
22-
i64
23-
i8
24-
isize
25-
and 6 others
2+
--> tests/ui/transmute-illegal.rs:10:30
3+
|
4+
10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| the trait `AsBytes` is not implemented for `*const usize`
8+
| required by a bound introduced by this call
9+
|
10+
= help: the following other types implement trait `AsBytes`:
11+
f32
12+
f64
13+
i128
14+
i16
15+
i32
16+
i64
17+
i8
18+
isize
19+
and $N others
2620
note: required by a bound in `POINTER_VALUE::transmute`
27-
--> tests/ui/transmute-illegal.rs:8:30
28-
|
29-
8 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
30-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `POINTER_VALUE::transmute`
31-
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
21+
--> tests/ui/transmute-illegal.rs:10:30
22+
|
23+
10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `POINTER_VALUE::transmute`
25+
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)