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

Wrong bounds for macro named the same as a type parameter #1081

Closed
dtolnay opened this issue Nov 5, 2017 · 0 comments
Closed

Wrong bounds for macro named the same as a type parameter #1081

dtolnay opened this issue Nov 5, 2017 · 0 comments

Comments

@dtolnay
Copy link
Member

dtolnay commented Nov 5, 2017

use std::marker::PhantomData;

#[macro_use]
extern crate serde_derive;

macro_rules! T {
    () => { () };
}

// generates impl<T> Serialize for A<T>
#[derive(Serialize)]
struct A<T> {
    f: (),
    t: PhantomData<T>,
}

// generates impl<T> Serialize for A<T> where T: Serialize
#[derive(Serialize)]
struct B<T> {
    f: T!(),
    t: PhantomData<T>,
}

fn main() {}

When expanding B<T> we see T being used as a "path" in the macro and mistakenly conclude that the type parameter needs to be serializable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant