Skip to content

Commit

Permalink
Address edition 2024 UI test failures
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 4ca8521)
  • Loading branch information
csnover committed Oct 13, 2024
1 parent 5cef1de commit 6a8fc2d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions binrw/tests/ui/invalid_map_fn.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(dependency_on_unit_never_type_fallback)]
use binrw::BinRead;

#[derive(BinRead)]
Expand Down
4 changes: 2 additions & 2 deletions binrw/tests/ui/invalid_map_fn.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0425]: cannot find value `does_not_exist` in this scope
--> $DIR/invalid_map_fn.rs:5:16
--> tests/ui/invalid_map_fn.rs:6:16
|
5 | #[br(map = does_not_exist)]
6 | #[br(map = does_not_exist)]
| ^^^^^^^^^^^^^^ not found in this scope
2 changes: 1 addition & 1 deletion binrw/tests/ui/invalid_map_return_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use binrw::BinRead;

#[derive(BinRead)]
struct Foo {
#[br(map = |_| 0u8)]
#[br(map = |_: ()| 0u8)]
a: i32,
}

Expand Down
10 changes: 5 additions & 5 deletions binrw/tests/ui/invalid_map_return_type.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0308]: mismatched types
--> $DIR/invalid_map_return_type.rs:5:20
--> tests/ui/invalid_map_return_type.rs:5:24
|
5 | #[br(map = |_| 0u8)]
| ^^^ expected `i32`, found `u8`
5 | #[br(map = |_: ()| 0u8)]
| ^^^ expected `i32`, found `u8`
|
help: change the type of the numeric literal from `u8` to `i32`
|
5 | #[br(map = |_| 0i32)]
| ~~~
5 | #[br(map = |_: ()| 0i32)]
| ~~~
2 changes: 1 addition & 1 deletion binrw/tests/ui/invalid_try_map_return_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use binrw::BinRead;

#[derive(BinRead)]
struct Foo {
#[br(try_map = |_| 0)]
#[br(try_map = |_: ()| 0)]
a: i32,
}

Expand Down
14 changes: 7 additions & 7 deletions binrw/tests/ui/invalid_try_map_return_type.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
error[E0308]: mismatched types
--> tests/ui/invalid_try_map_return_type.rs:5:24
--> tests/ui/invalid_try_map_return_type.rs:5:28
|
5 | #[br(try_map = |_| 0)]
| ^ expected `Result<i32, _>`, found integer
5 | #[br(try_map = |_: ()| 0)]
| ^ expected `Result<i32, _>`, found integer
|
= note: expected enum `Result<i32, _>`
found type `{integer}`
help: try wrapping the expression in a variant of `Result`
|
5 | #[br(try_map = |_| Ok(0))]
| +++ +
5 | #[br(try_map = |_| Err(0))]
| ++++ +
5 | #[br(try_map = |_: ()| Ok(0))]
| +++ +
5 | #[br(try_map = |_: ()| Err(0))]
| ++++ +

0 comments on commit 6a8fc2d

Please sign in to comment.