Conversation
c47fcbe to
8bff6c0
Compare
cba9946 to
bf655e9
Compare
1f3d8b8 to
fbbea41
Compare
|
I just rebased on the base branch (this PR is part of a long PR chain) |
jschneider-bensch
left a comment
There was a problem hiding this comment.
Looks good!
I just have some suggestions for documentation.
| pub enum ResugaredTyKind { | ||
| /// The `unit` type. | ||
| /// | ||
| /// Without resugaring: a tuple of arity zero. |
There was a problem hiding this comment.
Does it make sense to document here which backend is expected to use a specific resugared node?
There was a problem hiding this comment.
Not really part of this PR's scope, but I think it would be nice to reference codegen/README.md for details on how this module was generated in documentation at the top of this file.
| @@ -1465,7 +1465,7 @@ pub enum ItemKind { | |||
| /// A resugared item. | |||
| /// This variant is introduced before printing only. | |||
| /// Phases must not produce this variant. | |||
There was a problem hiding this comment.
| /// Phases must not produce this variant. | |
| /// Backend phases must not produce this variant. |
In the Printer documentation you also refer to "resugaring phases", so here it should be a bit more specific, no?
| fn print(self, fragment: &mut T) -> Option<(String, SourceMap)>; | ||
| } | ||
|
|
||
| macro_rules! derive_print { |
There was a problem hiding this comment.
Can you document what this macro does and if there is anything to know about how it implements Print? (e.g. I don't know what doc.render(80, ...) means and whether you'd want to know that this number means when you use the macro.
clementblaudeau
left a comment
There was a problem hiding this comment.
Looks good to me
| #[derive_group_for_ast] | ||
| #[visitable] | ||
| pub enum ResugaredTyKind {} | ||
| pub enum ResugaredTyKind { |
There was a problem hiding this comment.
Maybe also add the empty tuple as a unit expression ? It feels like only having the type will not be usable by backends
7cb712b to
7217c07
Compare
ad80607 to
d1a2f0f
Compare
d1a2f0f to
2bc7064
Compare
…ent to their parent fragment
Co-authored-by: Jonas Schneider-Bensch <124457079+jschneider-bensch@users.noreply.github.com>
Co-authored-by: Jonas Schneider-Bensch <124457079+jschneider-bensch@users.noreply.github.com>
2bc7064 to
aaa8388
Compare
24d88b5 to
0acc923
Compare
|
Closing in favor of #1528 |
Description
This PR introduces improvements and extensions to the AST representation and printer logic in the Rust engine, particularly focusing on resugaring types.
Key Changes:
AST Structure:
Tyto publicly expose its inner box (pub Box<TyKind>).ResugaredTyKindtoResugaredItemKindwithinItemKind::Resugaredto match the intended semantics.UnittoResugaredTyKindrepresenting the unit type (()), differentiating it clearly from the empty tuple.Resugaring Infrastructure:
ResugaredFragmenttrait and implementedFromconversions between resugared types and their parent fragments.derive_from!) to simplify repetitive trait implementations for AST fragment conversions.Visitor Corrections:
visit_resugared_ty_kind→visit_resugared_item_kind) to reflect the accurate naming forItemKind::Resugaredvariants, resolving naming inconsistencies across visitor implementations.Printer Enhancements:
ResugarandPrintertraits for AST printing with resugaring phases.Printtrait with automatic implementations via macro (derive_print!) to simplify printing logic for various AST fragments.UnitTyResugar) to convert zero-arity tuples into the dedicated unit type for clearer printing.Allocator Improvements:
Allocatorconstructor with a new convenience method (new) for improved ergonomics.Testing:
UnitTyResugarphase to ensure correct resugaring behavior.Fixes #1580.