Skip to content

Tracking issue for builtin declarative macros #2212

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

Closed
19 of 21 tasks
edwin0cheng opened this issue Nov 11, 2019 · 7 comments · Fixed by #10642
Closed
19 of 21 tasks

Tracking issue for builtin declarative macros #2212

edwin0cheng opened this issue Nov 11, 2019 · 7 comments · Fixed by #10642
Labels
A-macro macro expansion good first issue S-actionable Someone could pick this issue up and work on it right now

Comments

@edwin0cheng
Copy link
Member

edwin0cheng commented Nov 11, 2019

Here is the full list of builtin declarative macros current rustc supported:

@edwin0cheng
Copy link
Member Author

After #2205 is landed, some of the builtin declarative macros are:

Trivial to implement:

  • stringify, column, compile_error, etc

Trivial to implement for IDE purpose: (A dummy implementation will work here)

  • asm, global_asm, etc

Need OUTDIR metadata support:

  • env, etc

Need eager macro expansion support:
concat, include, etc

@matklad
Copy link
Member

matklad commented Nov 11, 2019

Priority wise, handling include!(concat!(env!("OUT_DIR"), "/foo.rs")) would be sweet!

@edwin0cheng
Copy link
Member Author

I will take concat! to see how to support eager expansion in current infrastructure.

But I still can't figure it out how name resolution works inside inner expansion phase 🤣

bors bot added a commit that referenced this issue 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 bot added a commit that referenced this issue 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]>
@kjeremy
Copy link
Contributor

kjeremy commented Nov 22, 2019

@edwin0cheng what does compile_error! expand to? Just a string with the error contents?

@edwin0cheng
Copy link
Member Author

Um... something as ! result type? e.g loop { "Compiler Error" } for now ? @matklad

@matklad
Copy link
Member

matklad commented Nov 22, 2019

Yeah, I think loop {} is good

@edwin0cheng edwin0cheng added the A-macro macro expansion label Mar 3, 2020
@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Jan 25, 2021
@Tehnix
Copy link

Tehnix commented Aug 3, 2021

NOTE: This might be out of scope for this issue, so feel free to let me know and I'll create a separate issue.


With Rust 1.54 recently introducing support for #[doc = include_str!("compile_fail.rs")] I was curious if the "support" that is aim for here also includes expanded these macros in the generated docs on hover?

Take for example the following code:

/// The GraphQL schema for our mock service.
///
/// ```graphql
#[doc = include_str!("schema.graphql")]
/// ```
pub struct Query;

It pulls in an external file, schema.graphql, which includes the full schema of the Query. At the moment, the tooltip in VS Code will ignore the #[doc = include_str!("schema.graphql")] part in the documentation it shows:

Screen Shot 2021-08-03 at 21 49 35

If you run cargo doc --open it does show up in the final documentation though:
Screen Shot 2021-08-03 at 21 53 19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion good first issue S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants