Skip to content

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

Closed
@rphmeier

Description

@rphmeier

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions