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
Note: the paths in this issue assume that #33370 is merged
Problem
external_data::StructData contains a ctor_id field that represents the Id of the struct constructor. However, this adds no value to the client of the API, since decl_id is enough to identify a struct.
Currently, some type references contain a ref_id that corresponds to the ctor_id of the type, instead of the decl_id. This forces clients of the API to keep a hashtable mapping from ctor_id to decl_id in case they want to get the original struct declaration.
Note: I have observed this only in tuple structs. It seems like normal structs don't even have a valid ctor_id
Example
Imagine you want to get all references to MyStruct in the following program:
structMyStruct;// decl_id: 1, ctor_id: 2fnmain(){let x = foo();}fnfoo() -> MyStruct{// Here, the reference to MyStruct has ref_id: 1MyStruct// Here, the reference to MyStruct has ref_id: 2 (the constructor)}
Ideally, both references should have ref_id = 1
Solution
Remove the ctor_id field and modify the save code in such a way that references always point to a decl_id instead of a ctor_id.
Note: the paths in this issue assume that #33370 is merged
Problem
external_data::StructData
contains actor_id
field that represents theId
of the struct constructor. However, this adds no value to the client of the API, sincedecl_id
is enough to identify a struct.Currently, some type references contain a
ref_id
that corresponds to thector_id
of the type, instead of thedecl_id
. This forces clients of the API to keep a hashtable mapping fromctor_id
todecl_id
in case they want to get the original struct declaration.Note: I have observed this only in tuple structs. It seems like normal structs don't even have a valid
ctor_id
Example
Imagine you want to get all references to
MyStruct
in the following program:Ideally, both references should have
ref_id = 1
Solution
Remove the
ctor_id
field and modify the save code in such a way that references always point to adecl_id
instead of actor_id
.cc @nrc do you think this makes sense?
The text was updated successfully, but these errors were encountered: