Skip to content

Conversation

zeenix
Copy link
Contributor

@zeenix zeenix commented Feb 27, 2025

I was happily writing some code that needs to support no_std and no_alloc only to find out that it's not possible through the compilation simply failing:

error[E0433]: failed to resolve: could not find `ContentRefDeserializer` in `de`
   --> zarlink/src/connection/mod.rs:136:36
    |
136 |         #[derive(Debug, Serialize, Deserialize)]
    |                                    ^^^^^^^^^^^ could not find `ContentRefDeserializer` in `de`
    |
note: found an item that was configured out
   --> /home/zeenix/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.218/src/private/de.rs:14:35
    |
14  |     Content, ContentDeserializer, ContentRefDeserializer, EnumDeserializer,
    |                                   ^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
   --> /home/zeenix/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.218/src/private/de.rs:12:1
    |
12  | #[cfg(any(feature = "std", feature = "alloc"))]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0412]: cannot find type `Content` in module `_serde::__private::de`
   --> zarlink/src/connection/mod.rs:136:36
    |
136 |         #[derive(Debug, Serialize, Deserialize)]
    |                                    ^^^^^^^^^^^ not found in `_serde::__private::de`
    |
note: found an item that was configured out
   --> /home/zeenix/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.218/src/private/de.rs:14:5
    |
14  |     Content, ContentDeserializer, ContentRefDeserializer, EnumDeserializer,
    |     ^^^^^^^
note: the item is gated here
   --> /home/zeenix/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.218/src/private/de.rs:12:1
    |
12  | #[cfg(any(feature = "std", feature = "alloc"))]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

Fixes serde-rs/serde#2668.

@zeenix zeenix changed the title Document that untagged enums equire std or alloc features Document that most enums representations require std or alloc features Mar 5, 2025
…tures

I was happily writing some code that needs to support no_std and no_alloc
only to find out that it's not possible through the compilation simply
failing:

```rust
error[E0433]: failed to resolve: could not find `ContentRefDeserializer` in `de`
   --> zarlink/src/connection/mod.rs:136:36
    |
136 |         #[derive(Debug, Serialize, Deserialize)]
    |                                    ^^^^^^^^^^^ could not find `ContentRefDeserializer` in `de`
    |
note: found an item that was configured out
   --> /home/zeenix/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.218/src/private/de.rs:14:35
    |
14  |     Content, ContentDeserializer, ContentRefDeserializer, EnumDeserializer,
    |                                   ^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
   --> /home/zeenix/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.218/src/private/de.rs:12:1
    |
12  | #[cfg(any(feature = "std", feature = "alloc"))]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0412]: cannot find type `Content` in module `_serde::__private::de`
   --> zarlink/src/connection/mod.rs:136:36
    |
136 |         #[derive(Debug, Serialize, Deserialize)]
    |                                    ^^^^^^^^^^^ not found in `_serde::__private::de`
    |
note: found an item that was configured out
   --> /home/zeenix/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.218/src/private/de.rs:14:5
    |
14  |     Content, ContentDeserializer, ContentRefDeserializer, EnumDeserializer,
    |     ^^^^^^^
note: the item is gated here
   --> /home/zeenix/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.218/src/private/de.rs:12:1
    |
12  | #[cfg(any(feature = "std", feature = "alloc"))]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
```

Fixes serde-rs/serde#2668.
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 6af4d0d into serde-rs:master Mar 10, 2025
2 checks passed
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.

Enum with tag does not work in #[no_std] environment
2 participants