Skip to content

Implement bulitin line! macro #2205

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

Merged
merged 4 commits into from
Nov 11, 2019
Merged

Conversation

edwin0cheng
Copy link
Member

@edwin0cheng edwin0cheng commented Nov 11, 2019

This PR implements bulitin macro line! and add basic infra-structure for other bulitin macros:

  1. Extend MacroDefId to support builtin macros
  2. Add a quote! macro for simple quasi quoting.

Note that for support others builtin macros, eager macro expansion have to be supported first, this PR not try to handle it. :)


assert_eq!(quoted.to_string(), "impl Clone for Foo {fn clone (& self) -> Self {Self {name : self . name . clone () , id : self . id . clone () ,}}}");
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

I am not sure if the amount of build-in macros really requires us to have quasy-quoting, but it definitely is wort to try!

I'd also would-like to have strongly-typed quasy-quoting for assists some day...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, we would like to expand builtin derive as normal macro expansion. A quasy quoting macro should help there. (Thats why I use Clone as a test case )

@matklad
Copy link
Member

matklad commented Nov 11, 2019

bors r+

Thanks!

bors bot added a commit that referenced this pull request Nov 11, 2019
2205: Implement bulitin line! macro r=matklad a=edwin0cheng

This PR implements bulitin macro `line!` and add basic infra-structure for other bulitin macros:

1. Extend `MacroDefId` to support builtin macros
2. Add a `quote!` macro for simple quasi quoting.

Note that for support others builtin macros, eager macro expansion have to be supported first, this PR not try to handle it. :)

Co-authored-by: Edwin Cheng <[email protected]>
@bors
Copy link
Contributor

bors bot commented Nov 11, 2019

Build succeeded

@bors bors bot merged commit 4f7df2a into rust-lang:master Nov 11, 2019
@edwin0cheng edwin0cheng deleted the impl-builtin-line branch November 11, 2019 16:22
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