Repository navigation
Regression: spurious "error: expected ," in serde::Serialize on macro_rules-variable path enum discriminant #72608
Copy link
Copy link
Closed
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleP-criticalCritical priorityCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Somewhat minimized test case: (still involves serde_derive and syn)
[dependencies]
serde = {version = "1", features = ["derive"]}
syn = { version = "1", features = ["full"] }mod gl {
pub const DEPTH_COMPONENT: isize = 0;
}
macro_rules! gl_enums {
($mod:ident) => {
#[derive(serde::Serialize)]
pub enum TexFormat {
DepthComponent = $mod::DEPTH_COMPONENT
}
}
}
gl_enums!(gl);Compiles in nightly-2020-05-24, errors in nightly-2020-05-25:
$ cargo +nightly-2020-05-25 rustc -- -Z macro-backtrace
Compiling proc-macro2 v1.0.17
Compiling unicode-xid v0.2.0
Compiling syn v1.0.25
Compiling serde v1.0.110
Compiling quote v1.0.6
Compiling serde_derive v1.0.110
Compiling aa v0.1.0 (/tmp/aa)
error: expected `,`
--> src/lib.rs:9:34
|
5 | / macro_rules! gl_enums {
6 | | ($mod:ident) => {
7 | | #[derive(serde::Serialize)]
8 | | pub enum TexFormat {
9 | | DepthComponent = $mod::DEPTH_COMPONENT
| | ^^
10 | | }
11 | | }
12 | | }
| |_- in this expansion of `gl_enums!`
13 |
14 | gl_enums!(gl);
| -------------- in this macro invocation
error: aborting due to previous errorAny of these changes makes compilation succeed:
- Removing use of
serde::Serialize - Disabling the
syn/fullfeature - Replacing
$modwith a non-variable module name - Replacing the path expression with a
{ use $mod::DEPTH_COMPONENT; DEPTH_COMPONENT }block
Regression range: 8970e8b...46e85b4. Merges:
- Auto merge of Rollup of 5 pull requests #72539 - RalfJung:rollup-8yfidi8, r=RalfJung
- Rollup merge of Use sort_unstable_by in its own docs #72535 - saschanaz:patch-1, r=jonas-schievink
- Rollup merge of Use
dyntrait syntax in more comments and docs #72532 - ratijas:dyn-trait-object-doc, r=jonas-schievink - Rollup merge of Clean up E0602 explanation #72530 - GuillaumeGomez:cleanup-e0602, r=Dylan-DPC
- Rollup merge of bootstrap: propagate test-args to miri and clippy test suites #72527 - RalfJung:miri-clippy-test-args, r=Mark-Simulacrum
- Rollup merge of Remove all uses of
NodeIdinResolverOutputs#72402 - marmeladema:resolver-outputs-def-id, r=ecstatic-morse - Auto merge of bump Miri #72531 - RalfJung:miri-upd, r=RalfJung
- Auto merge of Rollup of 3 pull requests #72529 - RalfJung:rollup-ydthv90, r=RalfJung
- Rollup merge of Fix typo in doc comment. #72528 - emosenkis:patch-1, r=dtolnay
- Rollup merge of Rewrite
Parser::collect_tokens#72393 - Aaron1011:feature/rewrite-collect-tokens, r=petrochenkov - Rollup merge of Remove
macro_defsmap #72284 - Aaron1011:feature/inline-macro-did, r=petrochenkov - Auto merge of Rollup of 2 pull requests #72524 - RalfJung:rollup-s9f1pcc, r=RalfJung
- Rollup merge of small select cleanup #72517 - lcnr:refactor-winnowing, r=jonas-schievink
- Rollup merge of Recursively expand
TokenKind::Interpolatedinprobably_equal_for_proc_macro#72388 - Aaron1011:fix/deep-tokenstream-equality, r=petrochenkov - Auto merge of Remove ReScope #72362 - matthewjasper:remove-rescope, r=nikomatsakis
- Auto merge of Rollup of 5 pull requests #72516 - Dylan-DPC:rollup-cc4w96z, r=Dylan-DPC
- Rollup merge of fix discriminant type in generator transform #72502 - RalfJung:generator-discr-ty, r=jonas-schievink
- Rollup merge of Fix ice-72487 #72489 - nbdd0121:issue-72487, r=Amanieu
- Rollup merge of Add missing ASM arena declarations to librustc_middle #72400 - Aaron1011:fix/asm-incr-ice, r=Amanieu
- Rollup merge of Unblock font loading in rustdoc.css #72092 - workingjubilee:patch-2, r=GuillaumeGomez
- Rollup merge of Preserve substitutions when making trait obligations for suggestions #71618 - ecstatic-morse:issue-71394, r=nikomatsakis
- Auto merge of Revert MSYS2 CI workaround #72474 - mati865:ci-fix, r=pietroalbini
Excluding those that seem unrelated to me leaves:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleP-criticalCritical priorityCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Activity
LeSeulArtichaut commentedon May 26, 2020
Let’s see if we can minimize the example and bisect further to find the culprit PR?
SimonSapin commentedon May 26, 2020
https://blog.rust-lang.org/inside-rust/2019/12/18/bisecting-rust-compiler.html worked pretty well:
searched nightlies: from nightly-2020-05-24 to nightly-2020-05-26
regressed nightly: nightly-2020-05-25
searched commits: from 8970e8b to 46e85b4
regressed commit: 7726070
bisected with cargo-bisect-rustc v0.5.1
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
The regression commit is a rollup merge of #72388 and #72517 . The former looks more related. CC @Aaron1011
SimonSapin commentedon May 26, 2020
Replacing
serde_derivewith this proc macro still reproduces the same error:SimonSapin commentedon May 26, 2020
SimonSapin commentedon May 26, 2020
Output of
dbg!(&input):And with
$modreplaced by a hard-codedglpath:SimonSapin commentedon May 26, 2020
This might be a false lead? The error is identical but it also happen with older rustc where serde succeeds. So I don’t understand what’s going on here.
syn::parse_macro_input!(input as syn::DeriveInput)is the first thing thatserde::Serializedoes: https://github.com/serde-rs/serde/blob/v1.0.110/serde_derive/src/lib.rs#L78LeSeulArtichaut commentedon May 26, 2020
Could this be a duplicate of or a bug related to #72545? cc @dtolnay
SimonSapin commentedon May 26, 2020
It does look very similar. I suspect that a change in
synsimilar to the one discussed at #72545 (comment) inproc-macro-hackcould solve this. I tried to find the relevant source code insynbut https://github.com/dtolnay/syn/blob/6d5c90ddf790342947cad5737051f34e715c58af/src/path.rs#L35 only has a definition that aPathSegmentcontains anIdent. Is the parsing code macro-generated? CC @dtolnaydtolnay commentedon May 26, 2020
I released a fix to parse
$mod::DEPTH_COMPONENTin syn 1.0.26.spastorino commentedon May 27, 2020
Assigning
P-criticalas discussed as part of the Prioritization Working Group process and removingI-prioritize.This seems to be the same issue as #72545 ?. And the culprit being #72388 or am I wrong?
dtolnay commentedon May 27, 2020
Yeah I think we can close in favor of #72545, it's the same underlying change.
Update Rust crate syn to v2 (#396)
fix(deps): update rust crate syn to v2 (#2512)