rustrust-cargocargo-features

The standard library is still required with `default-features = false` on bincode


I'm trying to use the bincode crate. As it's default features, it uses the standard library, but I'm working in a no_std environment. I've added default-features = false to my Cargo.toml, but it still doesn't compile.

My dependencies:

[package]
name = "fsys"
version = "0.1.0"
edition = "2021"

[dependencies]
bincode = { version = "1.3.3", default-features = false}

This doesn't make any sense to me. The std feature of bincode is disabled, yet it still tries to build it's dependencies with the standard library.

Here's the shorter version of the error message:

   Compiling serde v1.0.182
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-cos` target may not support the standard library
  = note: `std` is required by `serde` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

The original error message is this, but followed by 20K lines of failed std imports.


Solution

  • bincode does not have the std feature flag in version 1.3.3, as can be seen here.

    You probably want to use version 2.0.0 which is only available as a release candidate at the moment, but offers support for #![no_std].