-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
#![crate_name = EXPR]
semantically allows EXPR
to be a macro call but otherwise mostly ignores it
#122001
Comments
#![crate_name = EXPR]
lacks several semantic checks#![crate_name = EXPR]
semantically allows EXPR
to be a macro call but otherwise ignores the result of the expansion (apart from errors)
#![crate_name = EXPR]
semantically allows EXPR
to be a macro call but otherwise ignores the result of the expansion (apart from errors)#![crate_name = EXPR]
semantically allows EXPR
to be a macro call, eagerly expands it but otherwise ignores the result of the expansion apart from errors
#![crate_name = EXPR]
semantically allows EXPR
to be a macro call, eagerly expands it but otherwise ignores the result of the expansion apart from errors#![crate_name = EXPR]
semantically allows EXPR
to be a macro call but otherwise mostly ignores it
|
😦 Not sure how I missed this one in #88680. |
@ehuss Don't beat yourself up, nobody else noticed it either ^^. Oh, I've just double-checked the dates, your validation PR was merged Sep 26, 2021 which is after the aforementioned stabilization PR, merged May 19, 2021. I've only skimmed the thread but it seems to have been FCP'ed because it was a breaking change? Maybe we can even get away with making macro calls inside AFAIK, crater only supports Cargo projects (makes sense), so we can't use it to look for breakages. |
This comment was marked as outdated.
This comment was marked as outdated.
I haven't checked the code yet but I don't know if rustc's current architecture permits macro expansion for Well, we could theoretically expand macros for
|
Hm, I'm not getting the same result. When I compile A with 1.75, it generates a binary
Oh, that's interesting. Yea, |
Oh 🤦, I tested this with |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-high |
I nominate this for T-compiler discussion since I wonder if it was ever intentional to (correctly) support Possibly relevant to the discussion:
This might be a T-lang question at its core but I figure it makes sense for T-compiler to chime in first since its members might have more background information on this (compiler stages / passes, architectural limitations, when to expand when not to for simplicity of implementation). Footnotes
|
@rustbot label: +I-lang-nominated I think the question of whether we ever intended to support |
There's a list of attributes that need to be used very early, before macro expansion - #108221 (comment) (also see uses of There are also some proposals that may reduce the number of attributes in this list, like rust-lang/compiler-team#726. |
I think that intentionally-breaking this, so that it works like @rfcbot fcp merge |
Team member @scottmcm has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
@rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@rfcbot reviewed |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Contrary to
#![crate_type = EXPR]
,#![crate_name = EXPR]
does not semantically reject macro calls insideEXPR
.Instead, it eagerly expands them but otherwise ignores the result (apart from errors).
I presume this regressed when #78835 ( F-extended_key_value_attributes`#![feature(extended_key_value_attributes)]
) was stabilized.If so, this is a 1.53→1.54 stable-to-stable regression.
Update: It's a 1.75→1.76 stable-to-stable regression. Regressing PR: #117584.
Thanks ehuss, for the investigation! The result of the expansion used to be used!
Examples
The following examples all pass compilation and rustc completely ignores the crate name that comes from the expansion. This can be observed by for example running
rustc file.rs --print=crate-name
printsfile
(the file name is assumed to befile.rs
).(A)
(B)
where
crate_name.txt
exists and consists ofalias
.(C)
where we compile
file.rs
with--extern=dep -L. --edition=2021
and wheredep.rs
is:The text was updated successfully, but these errors were encountered: