Closed
Description
Code
Clap has the following test at clap_derive/tests/nested.rs
:
use clap::Clap;
#[test]
fn use_option() {
macro_rules! expand_ty {
($name:ident: $ty:ty) => {
#[derive(Clap)]
struct Outer {
#[clap(short, long)]
#[allow(dead_code)]
$name: $ty,
}
};
}
expand_ty!(my_field: Option<String>);
}
As you can see from the latest master CI, it fails to compile on stable
Version it worked on
It most recently worked on: Successfully compiles and runs on 1.46.0
Version with regression
rustc --version --verbose
:
rustc 1.48.0 (7eac88abb 2020-11-16)
Metadata
Metadata
Assignees
Labels
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: Name/path resolution done by `rustc_resolve` specificallyCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
pksunkara commentedon Nov 28, 2020
Weirdly, when I use my mac to test this locally, it works.
NOTE: macos stable fails on CI, so I don't think this is an OS issue.
On EC2, it fails with the above error from the CI:
pksunkara commentedon Nov 28, 2020
Pinging @petrochenkov because I suspect this is an issue with macro expansion. I tried
cargo expand
on the EC2 instance to check the output, but the code it had generated had no issues at all and successfully compiled.Which is also the reason I couldn't generate a minimal reproducible example. I have no idea what's causing this.
jyn514 commentedon Nov 28, 2020
This works on 1.47 and breaks on 1.48.
jyn514 commentedon Nov 28, 2020
searched nightlies: from nightly-2020-07-11 to nightly-2020-11-28
regressed nightly: nightly-2020-09-12
searched commits: from a1947b3 to 9911160
regressed commit: 94b4de0
bisected with cargo-bisect-rustc v0.5.2
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
where test.sh is
jyn514 commentedon Nov 28, 2020
cc @Aaron1011 - #75800 broke clap.
Aaron1011 commentedon Nov 28, 2020
This is due to a bug in how clap uses
quote_spanned!
. When #75800 was merged, we started preserving hygiene information in more cases, exposing the bug,I've opened clap-rs/clap#2231 to fix the issue
Aaron1011 commentedon Nov 28, 2020
@pksunkara: Do you know if this test was failing on nightlies prior to the stable release that broke this?
jyn514 commentedon Nov 28, 2020
@Aaron1011 no, it was broken in #75800: #79503 (comment). That searched nightlies, not stable releases.
Aaron1011 commentedon Nov 28, 2020
I mean, did the Clap CI tests start failing on nightly after that rust PR was merged?
pksunkara commentedon Nov 28, 2020
Doesn't look like it. See this job, https://github.com/clap-rs/clap/pull/2211/checks?check_run_id=1399409188
pksunkara commentedon Nov 28, 2020
To see a passing nightly CI run, check this, https://github.com/clap-rs/clap/runs/1393825395
pksunkara commentedon Nov 28, 2020
I am closing this since the regression is not one. It looks like the original PR did a crater run, but the bugged code was in a test file. Thanks for help @Aaron1011
I am not sure why one of the nightlies wasn't failing, but that's a separate issue altogether.