Closed
Description
The script below has a macro_rules macro that expands to:
#[derive(Print)]
pub struct S(<MyDispatch as $crate::Dispatch>::Call);
But inside of the derive(Print)
custom derive the tokens received are:
pub struct S(<MyDispatch as ::repro_dispatch>::Call);
The ::Dispatch
seems to be missing.
Originally reported in serde-rs/serde#1306.
rustc 1.28.0-nightly (4ecf12b 2018-06-02)
Repro script:
#!/bin/sh
cargo new --lib repro
cargo new --lib repro_dispatch
cargo new --lib repro_derive
echo >repro/src/lib.rs '
#[macro_use]
extern crate repro_dispatch;
#[macro_use]
extern crate repro_derive;
pub struct MyDispatch;
impl repro_dispatch::Dispatch for MyDispatch {
type Call = ();
}
problem!();
'
echo >>repro/Cargo.toml '
repro_dispatch = { path = "../repro_dispatch" }
repro_derive = { path = "../repro_derive" }
'
echo >repro_dispatch/src/lib.rs '
pub trait Dispatch {
type Call;
}
#[macro_export]
macro_rules! problem {
() => {
#[derive(Print)]
pub struct S(<MyDispatch as $crate::Dispatch>::Call);
}
}
'
echo >repro_derive/src/lib.rs '
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_derive(Print)]
pub fn derive(input: TokenStream) -> TokenStream {
println!("\n\n{}\n\n", input);
"".parse().unwrap()
}
'
echo >>repro_derive/Cargo.toml '
[lib]
proc-macro = true
'
cargo build --manifest-path repro/Cargo.toml