Question => op!('?'),
SingleQuote => op!('\''),
+ Ident(ident, false) if ident.name == keywords::DollarCrate.name() =>
+ tt!(Ident::dollar_crate()),
Ident(ident, is_raw) => tt!(Ident::new(ident.name, is_raw)),
Lifetime(ident) => {
let ident = ident.without_first_quote();
}
Ident { sym, is_raw, span }
}
+ fn dollar_crate(span: Span) -> Ident {
+ // `$crate` is accepted as an ident only if it comes from the compiler.
+ Ident { sym: keywords::DollarCrate.name(), is_raw: false, span }
+ }
}
// FIXME(eddyb) `Literal` should not expose internal `Debug` impls.
--- /dev/null
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+use proc_macro::TokenStream;
+
+#[proc_macro]
+pub fn normalize(input: TokenStream) -> TokenStream {
+ input.into_iter().collect()
+}
--- /dev/null
+// compile-pass
+// aux-build:dollar-crate.rs
+
+extern crate dollar_crate;
+
+type S = u8;
+
+macro_rules! check { () => {
+ dollar_crate::normalize! {
+ type A = $crate::S;
+ }
+}}
+
+check!();
+
+fn main() {}