Skip to content

Commit 4ca8521

Browse files
committed
Address edition 2024 UI test failures
The (necessary) use of function signature inference for the read function, in the absence of an actually valid function to infer from, results in the compiler generating warnings about `!` to `()` decay behaviour changing in Rust 2024, even though this code is already doomed to fail. We will see once edition 2024 is released whether the compiler emits a diagnostic about `BinRead` not being implemented for `!` or not.
1 parent b17128d commit 4ca8521

6 files changed

+17
-16
lines changed

binrw/tests/ui/invalid_map_fn.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(dependency_on_unit_never_type_fallback)]
12
use binrw::BinRead;
23

34
#[derive(BinRead)]

binrw/tests/ui/invalid_map_fn.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0425]: cannot find value `does_not_exist` in this scope
2-
--> $DIR/invalid_map_fn.rs:5:16
2+
--> tests/ui/invalid_map_fn.rs:6:16
33
|
4-
5 | #[br(map = does_not_exist)]
4+
6 | #[br(map = does_not_exist)]
55
| ^^^^^^^^^^^^^^ not found in this scope

binrw/tests/ui/invalid_map_return_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use binrw::BinRead;
22

33
#[derive(BinRead)]
44
struct Foo {
5-
#[br(map = |_| 0u8)]
5+
#[br(map = |_: ()| 0u8)]
66
a: i32,
77
}
88

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0308]: mismatched types
2-
--> $DIR/invalid_map_return_type.rs:5:20
2+
--> tests/ui/invalid_map_return_type.rs:5:24
33
|
4-
5 | #[br(map = |_| 0u8)]
5-
| ^^^ expected `i32`, found `u8`
4+
5 | #[br(map = |_: ()| 0u8)]
5+
| ^^^ expected `i32`, found `u8`
66
|
77
help: change the type of the numeric literal from `u8` to `i32`
88
|
9-
5 | #[br(map = |_| 0i32)]
10-
| ~~~
9+
5 | #[br(map = |_: ()| 0i32)]
10+
| ~~~

binrw/tests/ui/invalid_try_map_return_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use binrw::BinRead;
22

33
#[derive(BinRead)]
44
struct Foo {
5-
#[br(try_map = |_| 0)]
5+
#[br(try_map = |_: ()| 0)]
66
a: i32,
77
}
88

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0308]: mismatched types
2-
--> tests/ui/invalid_try_map_return_type.rs:5:24
2+
--> tests/ui/invalid_try_map_return_type.rs:5:28
33
|
4-
5 | #[br(try_map = |_| 0)]
5-
| ^ expected `Result<i32, _>`, found integer
4+
5 | #[br(try_map = |_: ()| 0)]
5+
| ^ expected `Result<i32, _>`, found integer
66
|
77
= note: expected enum `Result<i32, _>`
88
found type `{integer}`
99
help: try wrapping the expression in a variant of `Result`
1010
|
11-
5 | #[br(try_map = |_| Ok(0))]
12-
| +++ +
13-
5 | #[br(try_map = |_| Err(0))]
14-
| ++++ +
11+
5 | #[br(try_map = |_: ()| Ok(0))]
12+
| +++ +
13+
5 | #[br(try_map = |_: ()| Err(0))]
14+
| ++++ +

0 commit comments

Comments
 (0)