Skip to content
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

feat(macros): Add TopLevelItem and Type types for quoting top-level definitions and types #5267

Merged
merged 6 commits into from
Jun 18, 2024

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Jun 17, 2024

Description

Problem*

Resolves

Summary*

Adds a TopLevelItem and Type keywords & types for quoting type definitions, functions, trait impls, etc. and types respectively. The former is needed to identify items which can be unquoted at the top-level of a file - e.g. to prevent random expressions from being unquoted at the top level and to prevent trait impls from being unquoted in the middle of a function.

Additional Context

There is no way currently to create a TopLevelItem. The intended method is to be able to specify the type you want to quote in a quote expression: quote TopLevelItem { ... } but our current parser makes this very difficult since the top level statement parser would need to become recursive and be passed down through each function. For now I'm planning to have compiler API function's as a work around - e.g:

impl TopLevelItem {
    #[builtin(new_trait_impl)]
    pub fn new_trait_impl(generics: Vec<String>, trait: Type, typ: Type, methods: Vec<TopLevelItem>) -> TopLevelItem { }
}

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@jfecher jfecher requested review from TomAFrench and a team June 17, 2024 18:09
@jfecher jfecher changed the base branch from master to jf/annotations June 17, 2024 18:10
@jfecher jfecher merged commit 7fe9ced into jf/annotations Jun 18, 2024
19 of 20 checks passed
@jfecher jfecher deleted the jf/top-level-item branch June 18, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants