-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Nightly rejects some macro-generated doc attribute values accepted by stable #85432
Comments
@rustbot ping cleanup |
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @h-michael @HallerPatrick @hdhoang @hellow554 @henryboisdequin @imtsuki @JamesPatrickGill @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @shekohex @sinato @smmalis37 @steffahn @Stupremee @tamuhey @turboladen @woshilapin @yerke |
Never mind, seems to be an issue with the 0.7.4 version of lexical-core. |
This code errors on nightly, but not on stable: macro_rules! with_doc_comment {
($comment:expr, $item:item) => {
#[doc = $comment]
$item
};
}
macro_rules! database_table_doc {
() => {
""
};
}
with_doc_comment! {
database_table_doc!(),
#[derive(Debug)]
struct Image {
#[cfg(test)]
_f: (),
}
}
fn main() {} I had a similar piece of code (I try to post it in the next post) that fails with the exact message on stable as well. But here's the regression: searched nightlies: from nightly-2019-10-01 to nightly-2021-05-01 cc #82608 @Aaron1011 |
This code fails on stable with the same message as on nightly: macro_rules! database_table_doc {
() => {
""
};
}
#[doc = database_table_doc!()]
#[derive(Debug)]
struct Image {
#[cfg(test)]
_f: (),
}
fn main() {} I just "inlined" the So in 58d2bad the error message changed from
to
(that's what we have today) cc #78837 #78835 @petrochenkov I think the commit message makes it very clear why the possiblity was added to use macros there
What to do on this, is above my paygrade ;) @rustbot modify labels: -E-needs-mcve |
Error: Label ICEBreaker-Cleanup-Crew can only be set by Rust team members Please let |
Funny enough, in the tracking issue #78835 @alexschrod had the same issue as in this post, so this error is somewhat known. In the paste crate it was reported at dtolnay/paste#29 and fixed in dtolnay/paste#30, so maybe that's something for you @Erutuon if you need a fix right now. |
@rustbot modify labels -E-needs-mcve |
Sorry for the spam! @rustbot modify labels -ICEBreaker-Cleanup-Crew |
@hameerabbasi you can edit your post and use the rustbot command again without creating a new post ;) |
Right, that's the reason for the
It looks like I'm using the same technique as the regression test, but on nightly now it doesn't compile in 13 out of the 22 macro calls in my code. |
This will be fixed by #85445 |
Fixes rust-lang#85432 When processing a `#[derive]` or `#[cfg_eval]` attribute, we need to re-parse our attribute target, which requires flattenting all `Nonterminals`. However, this caused us to incorrectly gate on a (flattented) nonterminal in a key-value attribute, which is supposed to be allowed. Since we already perform this gating during the initial parse, we suppress it in `capture_cfg` mode.
Assigning @rustbot modify labels +P-critical -I-prioritize |
Fixes rust-lang#85432 When processing a `#[derive]` or `#[cfg_eval]` attribute, we need to re-parse our attribute target, which requires flattenting all `Nonterminals`. However, this caused us to incorrectly gate on a (flattented) nonterminal in a key-value attribute, which is supposed to be allowed. Since we already perform this gating during the initial parse, we suppress it in `capture_cfg` mode.
A version of my crate parse-mediawiki-sql with macro-generated docs builds on stable, but errors out on nightly, where the error suggests that I fix the error by enabling
#![feature(extended_key_value_attributes)]
.Stable is cargo 1.52.0 (rust-lang/cargo@69767412a 2021-04-21), rustc 1.52.1 (9bc8c42 2021-05-09), nightly is cargo 1.54.0-nightly (rust-lang/cargo@070e459c2 2021-05-11), rustc 1.54.0-nightly (3e99439 2021-05-17).
The error occurs in a macro that generates a struct declaration with an implementation of a trait and calls another macro to take a string generated by another set of macros and put it into a doc attribute above the struct. Here are the lines containing the macro declarations.
The error looks like this:
There are 22 calls to the macro, but only 13 errors, for the calls those whose contents start with
$table_name:ident $output_type:ident<$life:lifetime>
. I tried to generate a minimal example by copying the macros and one of the failing calls, but failed: this reduced version compiled on both stable and nightly in the playground.Somehow this sequence of tokens causes the error in the crate but not in the smaller playground example. I don't know much about the internals of the compiler here so have no idea how to change the playground example to generate the error.
The text was updated successfully, but these errors were encountered: