diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index e1f6e1caeae..6adfaa53946 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -141,15 +141,8 @@ pub mod util { pub mod bug; } -// A private module so that macro-expanded idents like -// `::rustc::lint::Lint` will also work in `rustc` itself. -// -// `libstd` uses the same trick. -#[doc(hidden)] -mod rustc { - pub use crate::lint; - pub use crate::ich; -} +// Allows macros to refer to this crate as `::rustc` +extern crate self as rustc; // FIXME(#27438): right now the unit tests of librustc don't refer to any actual // functions generated in librustc_data_structures (all diff --git a/src/librustc_macros/Cargo.toml b/src/librustc_macros/Cargo.toml index c5e01e9e0a7..2fe51a22fb4 100644 --- a/src/librustc_macros/Cargo.toml +++ b/src/librustc_macros/Cargo.toml @@ -2,6 +2,7 @@ name = "rustc_macros" version = "0.1.0" authors = ["The Rust Project Developers"] +edition = "2018" [lib] proc-macro = true @@ -10,4 +11,4 @@ proc-macro = true synstructure = "0.10.1" syn = { version = "0.15.22", features = ["full"] } proc-macro2 = "0.4.24" -quote = "0.6.10" \ No newline at end of file +quote = "0.6.10" diff --git a/src/librustc_macros/src/hash_stable.rs b/src/librustc_macros/src/hash_stable.rs index 13899d68cd2..6d7590c7d1c 100644 --- a/src/librustc_macros/src/hash_stable.rs +++ b/src/librustc_macros/src/hash_stable.rs @@ -1,6 +1,7 @@ use synstructure; -use syn::{self, Meta, NestedMeta}; +use syn::{self, Meta, NestedMeta, parse_quote}; use proc_macro2::{self, Ident}; +use quote::quote; struct Attributes { ignore: bool, @@ -46,7 +47,7 @@ fn parse_attributes(field: &syn::Field) -> Attributes { attrs } -pub fn hash_stable_derive(mut s: synstructure::Structure) -> proc_macro2::TokenStream { +pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { let generic: syn::GenericParam = parse_quote!('__ctx); s.add_bounds(synstructure::AddBounds::Generics); s.add_impl_generic(generic); diff --git a/src/librustc_macros/src/lib.rs b/src/librustc_macros/src/lib.rs index 460b415c537..cad31264b05 100644 --- a/src/librustc_macros/src/lib.rs +++ b/src/librustc_macros/src/lib.rs @@ -1,13 +1,7 @@ #![feature(proc_macro_hygiene)] +#![deny(rust_2018_idioms)] -#[macro_use] -extern crate syn; -#[macro_use] -extern crate synstructure; -#[macro_use] -extern crate quote; -extern crate proc_macro; -extern crate proc_macro2; +use synstructure::decl_derive; mod hash_stable;