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

Failed to automatically apply fixes to a procedural macro crate #6101

Closed
dtolnay opened this issue Sep 26, 2018 · 7 comments
Closed

Failed to automatically apply fixes to a procedural macro crate #6101

dtolnay opened this issue Sep 26, 2018 · 7 comments

Comments

@dtolnay
Copy link
Member

dtolnay commented Sep 26, 2018

Cargo.toml

[package]
name = "procedural"
version = "0.0.1"
authors = ["David Tolnay <[email protected]>"]
edition = "2018"

[lib]
proc-macro = true

src/lib.rs

extern crate proc_macro;
use self::proc_macro::TokenStream;

#[proc_macro]
pub fn demo(_input: TokenStream) -> TokenStream {
    TokenStream::new()
}

Running cargo fix --edition-idioms I get:

warning: failed to automatically apply fixes suggested by rustc to crate `procedural`

after fixes were automatically applied the compiler reported errors within these files:

  * src/lib.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see 
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/cargo/issues
quoting the full output of this command we'd be very appreciative!

warning: `extern crate` is not idiomatic in the new edition
 --> src/lib.rs:1:1
  |
1 | extern crate proc_macro;
  | ^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
  |
  = note: `-W unused-extern-crates` implied by `-W rust-2018-idioms`

warning: `extern crate` is not idiomatic in the new edition
 --> src/lib.rs:1:1
  |
1 | extern crate proc_macro;
  | ^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
  |
  = note: `-W unused-extern-crates` implied by `-W rust-2018-idioms`
@ehuss
Copy link
Contributor

ehuss commented Sep 26, 2018

There have been a few other reports of people having problems with the extern prelude changes. See also rust-lang/rust#54381 rust-lang/rust#53964. The original PR mentioned something about cargo growing support for --extern crate_name, but I haven't been able to find any detail about a plan on how this is supposed to work.

@alexcrichton
Copy link
Member

@eddyb sorry I may be confused, but it looks like rust-lang/rust#54116 was merged with no recourse for Cargo? Cargo can't pass --extern proc_macro because it's an unstable flag, and the edition is supposed to be in theory stable on beta?

@alexcrichton
Copy link
Member

The fix for this issue is that Cargo isn't passing --extern proc_macro, which in turn requires -Z unstable-options, which in turn means that this is simply a bug in the edition that will require more work than a patch to Cargo. We'll wait to see what the pings on the various issues come up with.

@alexcrichton
Copy link
Member

@eddyb mentions on IRC that the intention was for the lint to not fire on extern crate proc_macro;, basically continuing to consider that annotation "idiomatic for now". @eddyb will work on a patch to rustc to skip linting about extern crate proc_macro (specifically just that one crate) and that will in turn fix this issue.

@eddyb
Copy link
Member

eddyb commented Sep 28, 2018

I believe we're tracking this as rust-lang/rust#54381, right?

@alexcrichton
Copy link
Member

@eddyb I think both can be fixed in the same way, yeah, so I'd be fine tracking this there too

@ehuss
Copy link
Contributor

ehuss commented Oct 2, 2018

This appears to be fixed in the latest nightly via rust-lang/rust#54650.

@ehuss ehuss closed this as completed Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants