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
{{ message }}
Repository navigation
The type_name of tuple-structs and their ZST function item are the same #84666
use std::any::type_name;structVelocity(f32,f32);fnshow_name<T>(_:T){dbg!(type_name::<T>());}fnmain(){show_name(Velocity);show_name(Velocity(0.0, -9.8));}
I expected to see this happen:
The two names would be different, so that in logging I'd be able to notice I passed the wrong thing.
It allows you to put an instance of anything as a component on an entity, and get it back again later by type. So passing in a struct Marker; instance is fine -- and useful for filtering -- but it can't tell the difference between useful ZSTs like that and accidental ZSTs like Velocity where they meant to pass Velocity::new(). It would be nice for that to be at least available in debug logging, as a way to see what's available, but if that shows "Velocity" then it'd be particularly confusing when the "give me a ::<Velocity>()" doesn't work.
I'm not proposing any concrete string that this should return; it'd just be nice for it to be better distinguished.
Activity
Rollup merge of rust-lang#85963 - m-ou-se:constructor-type-name, r=yaahc
Rollup merge of rust-lang#85963 - m-ou-se:constructor-type-name, r=yaahc