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

add syn_full feature to serde_derive #2486

Closed
wants to merge 1 commit into from
Closed

add syn_full feature to serde_derive #2486

wants to merge 1 commit into from

Conversation

dimpolo
Copy link

@dimpolo dimpolo commented Jun 28, 2023

This allows users of serde_derive to transitively enable the "syn/full" feature.
While this fixes a problem I'm having I haven't put much thought into its general desirability.

Background

I'd like code like this to compile:

#[derive(serde::Deserialize)]
struct Foo<T: strum::EnumCount> {
    foo: heapless::Vec<u8, T::COUNT>,
}

However Rust currently requires us to write it like so (link)

#![feature(generic_const_exprs)]

#[derive(serde::Deserialize)]
struct Foo<T: strum::EnumCount>
where
    [(); { T::COUNT }]:,
{
    foo: heapless::Vec<u8, { T::COUNT }>,
}

The weird where clause requires the "syn/full" feature

@oli-obk
Copy link
Member

oli-obk commented Jun 28, 2023

As a work around you can make your crate depend on syn while enabling that feature (without actually using it. As long as it's in Cargo.toml, everything will work out)

@dimpolo
Copy link
Author

dimpolo commented Jun 28, 2023

As a work around you can make your crate depend on syn while enabling that feature (without actually using it. As long as it's in Cargo.toml, everything will work out)

That's something I tried. Unfortunately using this method I still get the unsupported expression; enable syn's features=["full"] error.

It seems as though features aren't unified for proc macros?

(Might be related: rust-lang/cargo#7833)

@NobodyXu
Copy link

@dimpolo I think if you put syn in build-dependencies then it should get unified with proc-macro deps.

@dimpolo
Copy link
Author

dimpolo commented Jun 29, 2023

@dimpolo I think if you put syn in build-dependencies then it should get unified with proc-macro deps.

Yes! That works! Thanks for the help! I'll close this PR

@dimpolo dimpolo closed this Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants