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

edition idioms: Trickiness with $crate in local macros #56683

Closed
alexcrichton opened this issue Dec 10, 2018 · 3 comments
Closed

edition idioms: Trickiness with $crate in local macros #56683

alexcrichton opened this issue Dec 10, 2018 · 3 comments
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@alexcrichton
Copy link
Member

Originally reported with Cargo this code:

#![warn(rust_2018_compatibility)]
extern crate serde;
#[macro_use]
extern crate serde_derive;

use serde::{Deserialize, Deserializer};

macro_rules! event {
    (
        pub struct $name:ident() {}
    ) => {
        #[derive(Deserialize)]
        pub struct $name {
            pub event_type: $crate::EventType,
        }
    }
}

pub enum EventType {}

event! {
    pub struct CustomEvent() {}
}

impl<'de> Deserialize<'de> for EventType {
    fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
    where
        D: Deserializer<'de>,
    {
        unimplemented!()
    }
}

gives an erroneous suggestion

which causes it to fail to be migrated by cargo fix

@alexcrichton
Copy link
Member Author

@ehuss also notes that #56622 may have an impact on the severity of this

@ehuss
Copy link
Contributor

ehuss commented Jan 1, 2019

This appears to be fixed now, presumably by #57155.

@alexcrichton
Copy link
Member Author

Yay!

@fmease fmease added A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-edition-2018-lints labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants