Skip to content

Parser: represent generic parameters in the AST #63

Description

@StreamDemon

Summary

Generic parameter lists are skipped to the balanced <…> (maybe_generic_params) and not stored in the AST, so fn f<T: Bound>(), struct S<T>, etc. lose their type parameters. Bounds and where-clauses (maybe_where_clause) are likewise discarded.

Part of the v0.6.x parser-completeness work (see crates/AGENTS.md "Implemented subset").

Spec

  • §3.5–3.6 generics, supertraits, struct bounds; §16 generic_params / where_clause.

Scope

  • AST node(s) for generic params (name + bounds) and where-clauses.
  • Parse and attach to fn, struct, enum, trait, impl, type.
  • Corpus + unit tests incl. bounded params and a where-clause.

Notes

needs-design: settle the AST shape for bounds (single vs. multiple bounds, lifetime vs. type params, defaults) before implementing — it has long-tail implications for the eventual type checker. Coordinate with the trait/impl-body issue so impl<T> / trait T<U> params are captured consistently.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions