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

include! should allow inner doc comments and directives #66920

Open
joshtriplett opened this issue Dec 1, 2019 · 3 comments
Open

include! should allow inner doc comments and directives #66920

joshtriplett opened this issue Dec 1, 2019 · 3 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@joshtriplett
Copy link
Member

Currently, include! cannot include a file that contains inner doc comments (//! ...) or directives (#![...]). That creates a challenge when trying to generate a crate's top-level contents with a build script.

See https://internals.rust-lang.org/t/include-raw-directive-for-raw-textual-inclusion-of-generated-code/11405 for discussion. @dtolnay pointed out that we can fix this backwards-compatibly, as it would just turn an error into a non-error.

@Centril Centril added C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Dec 1, 2019
@Centril
Copy link
Contributor

Centril commented Dec 1, 2019

cc @petrochenkov @matklad

@Xaeroxe
Copy link
Contributor

Xaeroxe commented Aug 12, 2024

This has been a constant source of pain for me during my time with Rust, both professionally and personally. I'd like to put an end to it. Is there any ongoing work for this that I should be aware of before I start working on it?

@fmease
Copy link
Member

fmease commented Aug 12, 2024

I don't remember anybody working on it.l, so go for it! :)

You want to look at expand_include in rustc_builtin_macros and nominate the future PR for T-lang discussion with the label I-lang-nominated Nominated for discussion during a lang team meeting. .

This might be obvious, but please make sure that we continue to reject inner attributes originating from the expansion of includes that are preceded by items.

Furthermore, it might be worthwhile to add the following question to the future nomination for T-lang to think about:

Should we (eventually) expand this behavior / feature to all macros (which "expand to items")? If so, should we relax the grammar and classify inner attributes as items? Again, if so, should inner attributes following (then) non-inner-attribute items become a semantic error or stay a syntactic one?

@fmease fmease marked this as a duplicate of #134621 Dec 21, 2024
@tgross35 tgross35 added E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. labels Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants