Skip to content

Add support for stringify! builtin macro #2348

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 1 commit into from
Nov 22, 2019
Merged

Conversation

pszpetkowski
Copy link
Contributor

Refs #2212

First time ever contributing here, hopefully it's ok.

@pszpetkowski pszpetkowski changed the title Add support for Stringify builtin macro Add support for stringify builtin macro Nov 22, 2019
@pszpetkowski pszpetkowski changed the title Add support for stringify builtin macro Add support for stringify! builtin macro Nov 22, 2019
let macro_call = loc.ast_id.to_node(db);

let macro_content = {
let arg = macro_call.token_tree().ok_or_else(|| mbe::ExpandError::UnexpectedToken)?;
Copy link
Member

Choose a reason for hiding this comment

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

Might be a stupid question, but is this the same as _tt?

Copy link
Member

Choose a reason for hiding this comment

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

There is no spacing information in _tt but I agree it is more accurate to use _tt directly here :

Playground Link

The builtin stringify! macro do not preserve space too.

Copy link
Member

Choose a reason for hiding this comment

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

Might be worth adding a test.

Copy link
Member

Choose a reason for hiding this comment

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

I think either solution is fine. It's also a shame that we can't easily add a test here, because there's no testing infra in hir_expand, but I think it makes sense to merge this without blocking on the said infra

Copy link
Member

@matklad matklad left a comment

Choose a reason for hiding this comment

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

bors r+

let macro_call = loc.ast_id.to_node(db);

let macro_content = {
let arg = macro_call.token_tree().ok_or_else(|| mbe::ExpandError::UnexpectedToken)?;
Copy link
Member

Choose a reason for hiding this comment

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

I think either solution is fine. It's also a shame that we can't easily add a test here, because there's no testing infra in hir_expand, but I think it makes sense to merge this without blocking on the said infra

bors bot added a commit that referenced this pull request Nov 22, 2019
2348: Add support for stringify! builtin macro r=matklad a=piotr-szpetkowski

Refs #2212

First time ever contributing here, hopefully it's ok.

2352: Move TypeAlias to hir_def r=matklad a=matklad



Co-authored-by: Piotr Szpetkowski <[email protected]>
Co-authored-by: Aleksey Kladov <[email protected]>
@bors
Copy link
Contributor

bors bot commented Nov 22, 2019

Canceled (will resume)

bors bot added a commit that referenced this pull request Nov 22, 2019
2348: Add support for stringify! builtin macro r=matklad a=piotr-szpetkowski

Refs #2212

First time ever contributing here, hopefully it's ok.

2352: Move TypeAlias to hir_def r=matklad a=matklad



Co-authored-by: Piotr Szpetkowski <[email protected]>
Co-authored-by: Aleksey Kladov <[email protected]>
@bors
Copy link
Contributor

bors bot commented Nov 22, 2019

Build succeeded

  • Rust
  • TypeScript

@bors bors bot merged commit 8ae5d6f into rust-lang:master Nov 22, 2019
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.

4 participants