You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the bevy::ecs::bundle::Bundle derive macro with a struct that used a where macro. Example code below and in test.tar.gz.
#[cfg(feature = "broken")]
#[derive(bevy::ecs::bundle::Bundle)]
struct Test<T>
where
T: bevy::ecs::component::Component,
{
i: T,
}
#[cfg(feature = "working")]
#[derive(bevy::ecs::bundle::Bundle)]
struct Test<T: bevy::ecs::component::Component> {
i: T,
}
fn main() {
let t = Test { i: 10 };
println!("hello world, {}", t.i);
}
What you expected to happen
Both versions of this code should compile. It shouldn't matter whether I declare a type bound in the brackets or in a where clause.
What actually happened
The code listed under working compiles without problems. But the code listed under broken fails to compile with many copies of this error:
error[E0277]: `T` cannot be shared between threads safely
--> src/main.rs:2:10
|
2 | #[derive(bevy::ecs::bundle::Bundle)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be shared between threads safely
|
::: /home/daniel/.cargo/git/checkouts/bevy-f7ffde730c324c74/94c4184/crates/bevy_ecs/src/bundle.rs:45:33
|
45 | pub unsafe trait Bundle: Send + Sync + 'static {
| ---- required by this bound in `Bundle`
|
= note: required because it appears within the type `Test<T>`
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `T`
|
3 | struct Test<T: Sync>
| ^^^^^^
Additional information
This seems to apply to any type bound required by the struct -- bounds that were living happily in the where clause before I tried to derive Bundle are suddenly reported as "not implemented", with an error pointing at the where clause that ought to make them available. Not only is this annoying, it doesn't seem to be possible to declare bounds on associated types anywhere but in the where clause, so working around the problem would require restructuring a number of my type declarations.
The text was updated successfully, but these errors were encountered:
Bevy version
94c4184
Operating system & version
Debian GNU/Linux 10.8 "buster"
What you did
I used the
bevy::ecs::bundle::Bundle
derive macro with a struct that used awhere
macro. Example code below and in test.tar.gz.What you expected to happen
Both versions of this code should compile. It shouldn't matter whether I declare a type bound in the brackets or in a
where
clause.What actually happened
The code listed under
working
compiles without problems. But the code listed underbroken
fails to compile with many copies of this error:Additional information
This seems to apply to any type bound required by the struct -- bounds that were living happily in the
where
clause before I tried to deriveBundle
are suddenly reported as "not implemented", with an error pointing at thewhere
clause that ought to make them available. Not only is this annoying, it doesn't seem to be possible to declare bounds on associated types anywhere but in thewhere
clause, so working around the problem would require restructuring a number of my type declarations.The text was updated successfully, but these errors were encountered: