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

Trait name lost with Derive(Deserialize) generated in remote crate. #1306

Closed
rphmeier opened this issue Jun 3, 2018 · 1 comment
Closed

Comments

@rphmeier
Copy link

rphmeier commented Jun 3, 2018

Remote crate ("test-macro"):

// lib.rs
pub trait Dispatch {
    type Call;
}

#[macro_export]
macro_rules! decl_issue_two {
    (
        $( #[$attr:meta] )*
        pub enum $name: ident {
            $(
                $call_name: ident,
            )+
        }
    ) => {
        $( #[$attr] )*
        pub enum $name {
            $(
                $call_name(<$call_name as $crate::Dispatch>::Call),
            )+
        }
    }
}

Local crate

// main.rs
#[macro_use]
extern crate test_macro;

#[macro_use]
extern crate serde_derive;

struct MyDispatch;

impl ::the_macro::Dispatch for MyDispatch {
    type Call = ();
}

decl_issue_two! {
    #[derive(Deserialize)]
    pub enum TheEnum2 {
        MyDispatch,
    }
}

fn main() { }

The generated code for TheEnum2 attempts to use the path <MyDispatch as ::test_macro>::Call instead of <MyDispatch as ::test_macro::Dispatch>::Call.
See https://github.com/rphmeier/serde_derive_issues

@dtolnay
Copy link
Member

dtolnay commented Jun 3, 2018

Thanks! This is a compiler bug, I filed rust-lang/rust#51331 to follow up.

@dtolnay dtolnay closed this as completed Jun 3, 2018
@dtolnay dtolnay added the bug label Jun 3, 2018
@dtolnay dtolnay added compiler bug and removed bug labels Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants