-
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
Perform monomorphization and constraint solving after type checking #3744
Conversation
7ae3fb5
to
465e696
Compare
277805d
to
2f8ac02
Compare
Do you think we can keep the parents abstraction? I am using it in #3878 The problem there is that I need to go from the monomorphized type back to the parent non-monomorph type. Or should we come up with something else for that? |
Thanks for letting me know @tritao! Currently I'm planning to remove the parents abstraction as it will no longer be necessary for monomorphization or type checking. I think we could either come up with something else clever, or in the interim we could construct a slimmed down version of the parents abstraction during monomorphization. |
…s in the `DeclEngine` (#4028) ## Description This PR is a subset of #3744. It adds a `name` field to `DeclId` which contains the name of the declaration. This is helpful in that it allows us to bypass lookups in the `DeclEngine` for trivial name info and is also a subset of #3744. This PR also removes/refactors some of these unnecessary lookups in the `DeclEngine` in light of the new `name` field. ## Checklist - [x] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
## Description This PR is a subset of #3744. It adds a `HashWithEngines` for the types required in #3744. Note---this isn't a necessary change into `master` right at this current moment, just simply a way of breaking up #3744 😄 This PR also makes a few corrections to some of the existing implementations for `HashWithEngines` which were incorrectly comparing `TypeId`s. ## Checklist - [x] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
## Description This PR is a subset of #3744. It introduces `DeclRef`, which is a smart wrapper type around `DeclId` and contains additional information aside from the `DeclId`. This allows us to make `DeclId` a copy type and remove excessive clones of `DeclId` and `DeclRef`. This PR is a subset of #3744, so while not explicitly necessary right now on `master`, there will be additional fields added to `DeclRef` in #3744. In detail, this PR: 1. Changes `DeclId` to a copy type defined as: ```rust #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] pub struct DeclId(usize); ``` 2. Creates a new `DeclRef` type which is a handle to a use of a declaration: (there will be more fields added to this in #3744) ```rust /// A reference to the use of a declaration. #[derive(Debug, Clone)] struct DeclRef { /// The name of the declaration. name: Ident, /// The index into the [DeclEngine]. id: DeclId, /// The [Span] of the entire declaration. decl_span: Span, } ``` 3. Changes the definition of the `TyDeclaration::FunctionDeclaration` variant to contain additional fields: (there will be more fields added to this in #3744) ```rust FunctionDeclaration { name: Ident, decl_id: DeclId, decl_span: Span, }, ``` 4. Changes the definiton of the `TyExpressionVariant::FunctionApplication` variant to contain a `DeclRef` instead of just the previous `DeclId`. The `TyExpressionVariant::FunctionApplication` variant gets a `DeclRef` because `DeclRef` is a handle to a declaration _usage_, while the `TyDeclaration::FunctionDeclaration` variant does not get a `DeclRef` because it is simply an AST node for the function declaration. This distinction will be more clear/necessary in #3744. 5. Changes the `DeclEngine` API to take `&T where ...`, allowing us to remove more unnecessary instances of `.clone()`. ## Checklist - [x] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
dd5f936
to
7d63d45
Compare
…ter` (#4089) ## Description This PR is a small refactor to the method call to type check a list of `TypeParameter`. This is to reduce the diff on #3744. This PR should have no practical or logical effect on `master`. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
## Description This PR is a subset of #3744. It adds a `OrdWithEngines` for the types required in #3744. Note---this isn't a necessary change into master right at this current moment, just simply a way of breaking up #3744 😄 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
…e engine threading traits.
…ng unique DeclId's out of DeclEngine and applying TypeSubstList.
8f7cb42
to
47e4e98
Compare
47e4e98
to
ba9cc72
Compare
3e75134
to
634b587
Compare
634b587
to
7dd04c7
Compare
7dd04c7
to
2e17cca
Compare
This PR:
DeclId
s unique with a 1:1 ratio for data structure definition. This means that we can compareDeclId
s directly, reduces the number ofDeclId
s that we produce, and reduces the number of times that we need to perform lookups in theDeclEngine
a. Modify
PartialEqWithEngines
to no longer compare theDeclId
s in the AST directlyb. Remove the "parents" abstraction in the
DeclEngine
a. This include trait constraint solving
Closes #3403
Closes #1267
Closes #2636
Blocked by:
OrdWithEngines
for some types #4082TypeParameter
#4089TypeInfo::SelfType
in favor of tracking the self type as a type param #3762DeclRef
for struct and enum TypeInfo #4213