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

2018 compatibility lint fires on definition of custom derive #52214

Closed
alexcrichton opened this issue Jul 10, 2018 · 0 comments
Closed

2018 compatibility lint fires on definition of custom derive #52214

alexcrichton opened this issue Jul 10, 2018 · 0 comments
Labels
A-edition-2018-lints Area: lints supporting the 2018 edition A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@alexcrichton
Copy link
Member

Originally reported as rust-lang/rustfix#121 it's reduced to:

#![crate_type = "proc-macro"]
#![warn(rust_2018_compatibility)]
#![feature(rust_2018_preview)]

extern crate proc_macro;

use proc_macro::TokenStream;

#[proc_macro_derive(Template, attributes(template))]
pub fn derive_template(input: TokenStream) -> TokenStream {
    input
}

which generates:

warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
  --> src/lib.rs:10:1
   |
10 | / pub fn derive_template(input: TokenStream) -> TokenStream {
11 | |     input
12 | | }
   | |_^
   |
note: lint level defined here
  --> src/lib.rs:2:9
   |
2  | #![warn(rust_2018_compatibility)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^
   = note: #[warn(absolute_paths_not_starting_with_crate)] implied by #[warn(rust_2018_compatibility)]
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
   = note: for more information, see issue TBD
help: use `crate`
   |
10 | crate::pub fn derive_template(input: TokenStream) -> TokenStream {
11 |     input
12 | }
   |
@alexcrichton alexcrichton added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-edition-2018-lints Area: lints supporting the 2018 edition labels Jul 10, 2018
@alexcrichton alexcrichton added this to the Rust 2018 Preview 2 milestone Jul 11, 2018
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jul 13, 2018
The syntactical expansion of `#[proc_macro]` and related attributes currently
contains absolute paths which conflicts with a lint for the 2018 edition,
causing issues like rust-lang#52214. This commit puts a band-aid on the issue by ensuring
that procedural macros can also migrate to the 2018 edition for now by tweaking
the expansion based on what features are activated. A more long-term solution
would probably tweak the edition hygiene of spans, but this should do the trick
for now.

Closes rust-lang#52214
bors added a commit that referenced this issue Jul 14, 2018
…henkov

rustc: Tweak expansion of #[proc_macro] for 2018

The syntactical expansion of `#[proc_macro]` and related attributes currently
contains absolute paths which conflicts with a lint for the 2018 edition,
causing issues like #52214. This commit puts a band-aid on the issue by ensuring
that procedural macros can also migrate to the 2018 edition for now by tweaking
the expansion based on what features are activated. A more long-term solution
would probably tweak the edition hygiene of spans, but this should do the trick
for now.

Closes #52214
bors added a commit that referenced this issue Jul 14, 2018
…henkov

rustc: Tweak expansion of #[proc_macro] for 2018

The syntactical expansion of `#[proc_macro]` and related attributes currently
contains absolute paths which conflicts with a lint for the 2018 edition,
causing issues like #52214. This commit puts a band-aid on the issue by ensuring
that procedural macros can also migrate to the 2018 edition for now by tweaking
the expansion based on what features are activated. A more long-term solution
would probably tweak the edition hygiene of spans, but this should do the trick
for now.

Closes #52214
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018-lints Area: lints supporting the 2018 edition A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

1 participant