-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Compile Time Query checking and System Parameters #17837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MalekiRe
wants to merge
22
commits into
bevyengine:main
Choose a base branch
from
MalekiRe:malek-ecs-cursed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b374ef0
working but not with query filters
MalekiRe 20f086a
query filters work
MalekiRe f2d8a31
got stuff more working
MalekiRe 214e84c
good error messages
MalekiRe a99b68c
progress
MalekiRe 7b1e737
made component diagonostic names a configurable feature
MalekiRe 747b881
more doc comments
MalekiRe e9866ad
finished comments
MalekiRe c81744b
fixed typo
MalekiRe 44aa6fb
removed un-needed dependancies
MalekiRe d00b235
reverted change_detection example
MalekiRe a556045
okay now ACTUALLY reverted change detection
MalekiRe e1a20c6
made the name feature actually work yay
MalekiRe 7517ac8
formatting
MalekiRe 47e4414
made the code way more succinct and understandable
MalekiRe bd6b324
cleaned up macro code and made systems go to 16 not 15
MalekiRe 1cd9270
some docs and foramtting
MalekiRe ad0b84e
doc comments
MalekiRe 148a1f3
ported over some of the runtime tests to compile time
MalekiRe 5d2cb10
forgot to format the macro crate
MalekiRe 8f798a4
saving this here, swtiching to another branch
MalekiRe 48a92ac
uwu
MalekiRe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() -> compile_fail_utils::ui_test::Result<()> { | ||
compile_fail_utils::test("ecs_system_params", "tests/system_params") | ||
} |
9 changes: 9 additions & 0 deletions
9
crates/bevy_ecs/compile_fail/tests/system_params/any_of_with_conflicting.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, bevy_ecs::query::AnyOf<(&mut A, &mut A)>>))), {closure@tests/system_params/any_of_with_conflicting.rs:8:37: 8:72}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<AnyOf<(&mut A, &mut A)>>| {}); | ||
} |
9 changes: 9 additions & 0 deletions
9
crates/bevy_ecs/compile_fail/tests/system_params/any_of_with_mut_and_option.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, bevy_ecs::query::AnyOf<(&mut A, std::option::Option<&A>)>>))), {closure@tests/system_params/any_of_with_mut_and_option.rs:8:37: 8:76}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<AnyOf<(&mut A, Option<&A>)>>| {}); | ||
} |
9 changes: 9 additions & 0 deletions
9
crates/bevy_ecs/compile_fail/tests/system_params/any_of_with_mut_and_ref.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, bevy_ecs::query::AnyOf<(&mut A, &A)>>))), {closure@tests/system_params/any_of_with_mut_and_ref.rs:8:37: 8:68}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<AnyOf<(&mut A, &A)>>| {}); | ||
} |
9 changes: 9 additions & 0 deletions
9
crates/bevy_ecs/compile_fail/tests/system_params/any_of_with_ref_and_mut.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, bevy_ecs::query::AnyOf<(&A, &mut A)>>))), {closure@tests/system_params/any_of_with_ref_and_mut.rs:8:37: 8:68}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<AnyOf<(&A, &mut A)>>| {}); | ||
} |
21 changes: 21 additions & 0 deletions
21
crates/bevy_ecs/compile_fail/tests/system_params/changed_trackers_or_conflict.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &A>, bevy_ecs::system::Query<'_, '_, &mut A>))), {closure@tests/system_params/conflicting_query_immut_system.rs:20:37: 20:69}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
#[derive(Component)] | ||
pub struct C; | ||
|
||
#[derive(Component)] | ||
pub struct D; | ||
|
||
#[derive(Component)] | ||
pub struct E; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<&mut A>, _: Query<(), Or<(Changed<A>,)>>| {}); | ||
} |
21 changes: 21 additions & 0 deletions
21
crates/bevy_ecs/compile_fail/tests/system_params/conflicting_query_immut_system.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &A>, bevy_ecs::system::Query<'_, '_, &mut A>))), {closure@tests/system_params/conflicting_query_immut_system.rs:20:37: 20:69}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
#[derive(Component)] | ||
pub struct C; | ||
|
||
#[derive(Component)] | ||
pub struct D; | ||
|
||
#[derive(Component)] | ||
pub struct E; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<&A>, _: Query<&mut A>| {}); | ||
} |
21 changes: 21 additions & 0 deletions
21
crates/bevy_ecs/compile_fail/tests/system_params/conflicting_query_mut_system.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &mut A>, bevy_ecs::system::Query<'_, '_, &mut A>))), {closure@tests/system_params/conflicting_query_mut_system.rs:20:37: 20:73}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
#[derive(Component)] | ||
pub struct C; | ||
|
||
#[derive(Component)] | ||
pub struct D; | ||
|
||
#[derive(Component)] | ||
pub struct E; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<&mut A>, _: Query<&mut A>| {}); | ||
} |
24 changes: 24 additions & 0 deletions
24
...y_ecs/compile_fail/tests/system_params/or_expanded_nested_or_with_and_disjoint_without.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &mut D, bevy_ecs::query::Or<(bevy_ecs::query::Or<(bevy_ecs::query::With<A>, bevy_ecs::query::With<B>)>, bevy_ecs::query::Or<(bevy_ecs::query::With<A>, bevy_ecs::query::With<C>)>)>>, bevy_ecs::system::Query<'_, '_, &mut D, bevy_ecs::query::Without<A>>))), {closure@tests/system_params/or_expanded_nested_or_with_and_disjoint_without.rs:20:37: 23:6}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
#[derive(Component)] | ||
pub struct C; | ||
|
||
#[derive(Component)] | ||
pub struct D; | ||
|
||
#[derive(Component)] | ||
pub struct E; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(| | ||
_: Query<&mut D, Or<(Or<(With<A>, With<B>)>, Or<(With<A>, With<C>)>)>>, | ||
_: Query<&mut D, Without<A>>, | ||
| {}); | ||
} |
24 changes: 24 additions & 0 deletions
24
...s/compile_fail/tests/system_params/or_expanded_nested_with_and_disjoint_nested_without.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &mut D, bevy_ecs::query::Or<((bevy_ecs::query::With<A>, bevy_ecs::query::With<B>), (bevy_ecs::query::With<B>, bevy_ecs::query::With<C>))>>, bevy_ecs::system::Query<'_, '_, &mut D, bevy_ecs::query::Or<(bevy_ecs::query::Without<A>, bevy_ecs::query::Without<B>)>>))), {closure@tests/system_params/or_expanded_nested_with_and_disjoint_nested_without.rs:20:37: 23:6}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
#[derive(Component)] | ||
pub struct C; | ||
|
||
#[derive(Component)] | ||
pub struct D; | ||
|
||
#[derive(Component)] | ||
pub struct E; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(| | ||
_: Query<&mut D, Or<((With<A>, With<B>), (With<B>, With<C>))>>, | ||
_: Query<&mut D, Or<(Without<A>, Without<B>)>>, | ||
| {}); | ||
} |
23 changes: 23 additions & 0 deletions
23
...bevy_ecs/compile_fail/tests/system_params/or_expanded_nested_with_and_disjoint_without.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &mut E, (bevy_ecs::query::Or<((bevy_ecs::query::With<B>, bevy_ecs::query::With<C>), (bevy_ecs::query::With<C>, bevy_ecs::query::With<D>))>, bevy_ecs::query::With<A>)>, bevy_ecs::system::Query<'_, '_, &mut E, bevy_ecs::query::Without<D>>))), {closure@tests/system_params/or_expanded_nested_with_and_disjoint_without.rs:20:37: 22:38}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
#[derive(Component)] | ||
pub struct C; | ||
|
||
#[derive(Component)] | ||
pub struct D; | ||
|
||
#[derive(Component)] | ||
pub struct E; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(| | ||
_: Query<&mut E, (Or<((With<B>, With<C>), (With<C>, With<D>))>, With<A>)>, | ||
_: Query<&mut E, Without<D>>| {}); | ||
} |
24 changes: 24 additions & 0 deletions
24
...bevy_ecs/compile_fail/tests/system_params/or_expanded_with_and_disjoint_nested_without.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &mut D, bevy_ecs::query::Or<(bevy_ecs::query::With<A>, bevy_ecs::query::With<B>)>>, bevy_ecs::system::Query<'_, '_, &mut D, bevy_ecs::query::Or<(bevy_ecs::query::Without<A>, bevy_ecs::query::Without<B>)>>))), {closure@tests/system_params/or_expanded_with_and_disjoint_nested_without.rs:20:37: 23:6}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
#[derive(Component)] | ||
pub struct C; | ||
|
||
#[derive(Component)] | ||
pub struct D; | ||
|
||
#[derive(Component)] | ||
pub struct E; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(| | ||
_: Query<&mut D, Or<(With<A>, With<B>)>>, | ||
_: Query<&mut D, Or<(Without<A>, Without<B>)>>, | ||
| {}); | ||
} |
12 changes: 12 additions & 0 deletions
12
crates/bevy_ecs/compile_fail/tests/system_params/or_has_no_filter_with.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &mut B, bevy_ecs::query::Or<(bevy_ecs::query::With<A>, bevy_ecs::query::With<B>)>>, bevy_ecs::system::Query<'_, '_, &mut B, bevy_ecs::query::Without<A>>))), {closure@tests/system_params/or_has_no_filter_with.rs:11:37: 11:109}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<&mut B, Or<(With<A>, With<B>)>>, _: Query<&mut B, Without<A>>| {}); | ||
} |
21 changes: 21 additions & 0 deletions
21
crates/bevy_ecs/compile_fail/tests/system_params/with_and_disjoint_or_empty_without.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@error-in-other-file: evaluation of `bevy_ecs::schedule::Schedule::add_systems::<(bevy_ecs::schedule::Infallible, (bevy_ecs::system::IsFunctionSystem, fn(bevy_ecs::system::Query<'_, '_, &mut B, bevy_ecs::query::With<A>>, bevy_ecs::system::Query<'_, '_, &mut B, bevy_ecs::query::Or<((), bevy_ecs::query::Without<A>)>>))), {closure@tests/system_params/with_and_disjoint_or_empty_without.rs:20:37: 20:104}>::{constant#0}` failed | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct A; | ||
|
||
#[derive(Component)] | ||
pub struct B; | ||
|
||
#[derive(Component)] | ||
pub struct C; | ||
|
||
#[derive(Component)] | ||
pub struct D; | ||
|
||
#[derive(Component)] | ||
pub struct E; | ||
|
||
fn main() { | ||
Schedule::default().add_systems(|_: Query<&mut B, With<A>>, _: Query<&mut B, Or<((), Without<A>)>>| {}); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make this value deterministic? I think that's preferable from it randomly changing whenever
cargo clean && cargo build
is ran.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Using something like
type_id::<Self>()
would be ideal, but you'd need a nightly feature flag to make it const.I guess you could do some sort of hashing that takes for input the component's ast, but that still probably isn't enough to avoid collisions with other components. It would also drastically increase the complexity of this pr.
I agree it'd be preferable, but what benefits are there to making it deterministic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah using type_id:: would be ideal, but we don't want to use any sort of deterministic count because I've heard from the grape vine that rustc might mess with things so we could end up with UB. Unless I have a guarantee that IDs are never going to repeat I would rather safely stick with a random u128.