-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Introduce DeclRef
and remove excessive clones to DeclId
#4037
Conversation
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.
Makes sense.
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 guess this is fine, if we're keeping the same design.
But since you're working on this area again, do we really need to keep the span and ident on a DeclRef
/DeclId
?
If I remember correctly that span is only used for a diagnostic which I've never even seen before. And can't we get the name from the declaration linked by the ID anyway?
I would ask that Spans and Idents be included wherever possible as they are the primary type that we rely on in the language server for doing anything. |
Also the |
Pull request was converted to draft
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.
utACK. Can see most of it is DeclId
-> DeclRef
, LGTM.
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.
Nice, looks good!
Description
This PR is a subset of #3744. It introduces
DeclRef
, which is a smart wrapper type aroundDeclId
and contains additional information aside from theDeclId
. This allows us to makeDeclId
a copy type and remove excessive clones ofDeclId
andDeclRef
.This PR is a subset of #3744, so while not explicitly necessary right now on
master
, there will be additional fields added toDeclRef
in #3744.In detail, this PR:
DeclId
to a copy type defined as:DeclRef
type which is a handle to a use of a declaration: (there will be more fields added to this in Perform monomorphization and constraint solving after type checking #3744)TyDeclaration::FunctionDeclaration
variant to contain additional fields: (there will be more fields added to this in Perform monomorphization and constraint solving after type checking #3744)TyExpressionVariant::FunctionApplication
variant to contain aDeclRef
instead of just the previousDeclId
. TheTyExpressionVariant::FunctionApplication
variant gets aDeclRef
becauseDeclRef
is a handle to a declaration usage, while theTyDeclaration::FunctionDeclaration
variant does not get aDeclRef
because it is simply an AST node for the function declaration. This distinction will be more clear/necessary in Perform monomorphization and constraint solving after type checking #3744.TyDeclaration::FunctionDeclaration
andTyExpressionVariant::FunctionApplication
.DeclEngine
API to take&T where ...
, allowing us to remove more unnecessary instances of.clone()
.Checklist
Breaking*
orNew Feature
labels where relevant.