Skip to content

Commit 12a491f

Browse files
committed
Make rustc_macro a Rust 2018 crate
1 parent 1675212 commit 12a491f

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

src/librustc/lib.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,8 @@ pub mod util {
141141
pub mod bug;
142142
}
143143

144-
// A private module so that macro-expanded idents like
145-
// `::rustc::lint::Lint` will also work in `rustc` itself.
146-
//
147-
// `libstd` uses the same trick.
148-
#[doc(hidden)]
149-
mod rustc {
150-
pub use crate::lint;
151-
pub use crate::ich;
152-
}
144+
// Allows macros to refer to this crate as `::rustc`
145+
extern crate self as rustc;
153146

154147
// FIXME(#27438): right now the unit tests of librustc don't refer to any actual
155148
// functions generated in librustc_data_structures (all

src/librustc_macros/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "rustc_macros"
33
version = "0.1.0"
44
authors = ["The Rust Project Developers"]
5+
edition = "2018"
56

67
[lib]
78
proc-macro = true
@@ -10,4 +11,4 @@ proc-macro = true
1011
synstructure = "0.10.1"
1112
syn = { version = "0.15.22", features = ["full"] }
1213
proc-macro2 = "0.4.24"
13-
quote = "0.6.10"
14+
quote = "0.6.10"

src/librustc_macros/src/hash_stable.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use synstructure;
2-
use syn::{self, Meta, NestedMeta};
2+
use syn::{self, Meta, NestedMeta, parse_quote};
33
use proc_macro2::{self, Ident};
4+
use quote::quote;
45

56
struct Attributes {
67
ignore: bool,
@@ -46,7 +47,7 @@ fn parse_attributes(field: &syn::Field) -> Attributes {
4647
attrs
4748
}
4849

49-
pub fn hash_stable_derive(mut s: synstructure::Structure) -> proc_macro2::TokenStream {
50+
pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
5051
let generic: syn::GenericParam = parse_quote!('__ctx);
5152
s.add_bounds(synstructure::AddBounds::Generics);
5253
s.add_impl_generic(generic);

src/librustc_macros/src/lib.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
#![feature(proc_macro_hygiene)]
2+
#![deny(rust_2018_idioms)]
23

3-
#[macro_use]
4-
extern crate syn;
5-
#[macro_use]
6-
extern crate synstructure;
7-
#[macro_use]
8-
extern crate quote;
9-
extern crate proc_macro;
10-
extern crate proc_macro2;
4+
use synstructure::decl_derive;
115

126
mod hash_stable;
137

0 commit comments

Comments
 (0)