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 }}
This repository was archived by the owner on Apr 15, 2022. It is now read-only.
TypeName is intended to uniquely identify a fully-resolved type, such that it can be used to reliably relate type references within a schema. However, a generic type will have the same type name for all concrete instantiations, violating this requirement.
The correct solution here is to take generic parameters into account in some way. A simple solution would be to include an additional list of the type TypeName values for each generic parameter. This would allow TypeName to be as deeply-nested as needed in order to fully identify the type. For example, TypeName would change to something like:
My only reservation with this approach is that getting the TypeName for a type would no longer be a const-compatible operation, since it requires populating a Vec. In practice, though, I don't think we need creating a TypeName value to be a const operation, and none of the places where we currently create a TypeName value would be broken by the change.
In making this change, we will probably need to add a type_name method on the Describe trait. In order to get the fully-resolved name and module for type parameters, we can't just use the type_name! macro since it can't resolve the module of external types.
The text was updated successfully, but these errors were encountered:
Thinking about it some, we could probably have the type params be a Cow<'static, [TypeName]>. I think the list of type names should be statically known, so we can possibly get away without allocating inside Describe::describe. This would definitely be the case if we added a NAME const member to the Describe trait.
I've got an initial version of this implemented using a type_name associated function. I tried using the Cow<[TypeName]> approach, however it appears that rust-lang/rust#47032 is preventing structs with that contain a Cow<[Self]> field to not compile. For now we'll have to stick with Vec<TypeName> and an associated function. Once that compiler issue is fixed, we can switch to using an associated constant instead.
randomPoison
added
blocked
The ticket is blocked on another ticket or an external dependency
and removed
blocked
The ticket is blocked on another ticket or an external dependency
labels
May 15, 2020
TypeName
is intended to uniquely identify a fully-resolved type, such that it can be used to reliably relate type references within a schema. However, a generic type will have the same type name for all concrete instantiations, violating this requirement.The correct solution here is to take generic parameters into account in some way. A simple solution would be to include an additional list of the type
TypeName
values for each generic parameter. This would allowTypeName
to be as deeply-nested as needed in order to fully identify the type. For example,TypeName
would change to something like:My only reservation with this approach is that getting the
TypeName
for a type would no longer be a const-compatible operation, since it requires populating aVec
. In practice, though, I don't think we need creating aTypeName
value to be a const operation, and none of the places where we currently create aTypeName
value would be broken by the change.In making this change, we will probably need to add a
type_name
method on theDescribe
trait. In order to get the fully-resolved name and module for type parameters, we can't just use thetype_name!
macro since it can't resolve the module of external types.The text was updated successfully, but these errors were encountered: