Skip to content

Commit cc24e41

Browse files
Write migration guide for 2024 edition panicking closure inference regression (#2092)
Co-authored-by: JaySpruce <[email protected]>
1 parent 4a084e1 commit cc24e41

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

release-content/0.16/migration-guides/_guides.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,4 +1017,10 @@ file_name = "18326_Use_4byte_LightmapSlabIndex_for_batching_instead_of_16byte.md
10171017
title = "Use `target_abi = \"sim\"` instead of `ios_simulator` feature"
10181018
prs = [17702]
10191019
areas = []
1020-
file_name = "17702_Use_target_abi__sim_instead_of_ios_simulator_feature.md"
1020+
file_name = "17702_Use_target_abi__sim_instead_of_ios_simulator_feature.md"
1021+
1022+
[[guides]]
1023+
title = "Closures which panic now need to explicitly specify a `()` return type"
1024+
prs = [17967]
1025+
areas = ["ECS"]
1026+
file_name = "panicking_closures.md"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
As a result of changes to [Never type fallback] in Rust 2024, closures which panic now have an inferred return type of `!`, rather than `()`. This might occur if you're using `panic!`, `todo!`, `unimplemented!`, `unreachable!` or other means of panicking.
2+
3+
This affects Bevy users as our blanket implementations for `Command`, `IntoSystem` and `IntoObserverSystem`, which operate on all matching functions with the correct type signature, no longer cover closures of this sort.
4+
5+
While this may be fixable on Bevy's end (see [#18778]), for now, you can work around this issue by either:
6+
7+
1. Converting your closures to ordinary named functions, whose return type is not inferred.
8+
2. Explicitly specifying the return type of your closure as `()`.
9+
10+
[Never type fallback]: https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html
11+
[#18778]: https://github.com/bevyengine/bevy/issues/18778

0 commit comments

Comments
 (0)