serde-rs / bytes

Wrapper types to enable optimized handling of &[u8] and Vec<u8>
Apache License 2.0
306 stars 37 forks source link

Tests fail with --no-default-features on published "serde_bytes" 0.11.3 crate #19

Closed kentfredric closed 4 years ago

kentfredric commented 4 years ago

This doesn't look critical, but it might be nice to fix the tests to do the right thing here, if for no purpose than to allow testing this configuration to ensure the crate works properly.

cargo +stable test --no-default-features ``` Updating crates.io index Downloaded bincode v1.2.1 Compiling proc-macro2 v1.0.8 Compiling serde v1.0.104 Compiling unicode-xid v0.2.0 Compiling byteorder v1.3.4 Compiling syn v1.0.14 Compiling quote v1.0.2 Compiling serde_derive v1.0.104 Compiling bincode v1.2.1 Compiling serde_test v1.0.104 Compiling serde_bytes v0.11.3 (/home/kent/.cpanm/work/1582251421.24569/serde_bytes-0.11.3) error[E0432]: unresolved import `serde_bytes::ByteBuf` --> tests/test_partialeq.rs:1:26 | 1 | use serde_bytes::{Bytes, ByteBuf}; | ^^^^^^^ no `ByteBuf` in the root error[E0432]: unresolved import `serde_bytes::ByteBuf` --> tests/test_derive.rs:1:19 | 1 | use serde_bytes::{ByteBuf, Bytes}; | ^^^^^^^ no `ByteBuf` in the root error[E0432]: unresolved import `serde_bytes::ByteBuf` --> tests/test_serde.rs:1:19 | 1 | use serde_bytes::{ByteBuf, Bytes}; | ^^^^^^^ no `ByteBuf` in the root error[E0425]: cannot find function `deserialize` in crate `serde_bytes` --> tests/test_derive.rs:5:21 | 5 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^^^ help: a function with a similar name exists: `serialize` error: aborting due to previous error For more information about this error, try `rustc --explain E0432`. error: aborting due to previous error For more information about this error, try `rustc --explain E0432`. error: could not compile `serde_bytes`. warning: build failed, waiting for other jobs to finish... error: could not compile `serde_bytes`. warning: build failed, waiting for other jobs to finish... error[E0277]: the trait bound `serde_bytes::bytes::Bytes: std::clone::Clone` is not satisfied --> tests/test_derive.rs:23:5 | 23 | cow_bytes: Cow<'a, Bytes>, | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `serde_bytes::bytes::Bytes` | = note: required because of the requirements on the impl of `std::borrow::ToOwned` for `serde_bytes::bytes::Bytes` = note: required because it appears within the type `std::borrow::Cow<'a, serde_bytes::bytes::Bytes>` = note: only the last field of a struct may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> tests/test_derive.rs:23:5 | 23 | cow_bytes: Cow<'a, Bytes>, | ^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `serde_bytes::bytes::Bytes`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit = note: required because it appears within the type `serde_bytes::bytes::Bytes` = note: required because of the requirements on the impl of `std::borrow::ToOwned` for `serde_bytes::bytes::Bytes` = note: required because it appears within the type `std::borrow::Cow<'a, serde_bytes::bytes::Bytes>` = note: only the last field of a struct may have a dynamically sized type error[E0277]: the trait bound `serde_bytes::bytes::Bytes: std::clone::Clone` is not satisfied --> tests/test_derive.rs:5:21 | 5 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `serde_bytes::bytes::Bytes` | = note: required because of the requirements on the impl of `std::borrow::ToOwned` for `serde_bytes::bytes::Bytes` = note: required because it appears within the type `std::borrow::Cow<'a, serde_bytes::bytes::Bytes>` = note: only the last field of a struct may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> tests/test_derive.rs:5:21 | 5 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `serde_bytes::bytes::Bytes`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit = note: required because it appears within the type `serde_bytes::bytes::Bytes` = note: required because of the requirements on the impl of `std::borrow::ToOwned` for `serde_bytes::bytes::Bytes` = note: required because it appears within the type `std::borrow::Cow<'a, serde_bytes::bytes::Bytes>` = note: only the last field of a struct may have a dynamically sized type error[E0277]: the trait bound `serde_bytes::bytes::Bytes: std::clone::Clone` is not satisfied --> tests/test_derive.rs:5:10 | 5 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `serde_bytes::bytes::Bytes` | = note: required because of the requirements on the impl of `std::borrow::ToOwned` for `serde_bytes::bytes::Bytes` = note: required by `std::borrow::Cow` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> tests/test_derive.rs:5:10 | 5 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ doesn't have a size known at compile-time | = help: within `serde_bytes::bytes::Bytes`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit = note: required because it appears within the type `serde_bytes::bytes::Bytes` = note: required because of the requirements on the impl of `std::borrow::ToOwned` for `serde_bytes::bytes::Bytes` = note: required by `std::borrow::Cow` error: aborting due to 8 previous errors Some errors have detailed explanations: E0277, E0425, E0432. For more information about an error, try `rustc --explain E0277`. error: could not compile `serde_bytes`. warning: build failed, waiting for other jobs to finish... error: build failed ```
dtolnay commented 4 years ago

I would prefer to leave it. All the cfg features we use are additive, so if the crate compiles successfully with various feature combinations and passes tests with all features enabled then it's fine. Introducing cfg gunk into the test suite would make it less likely to cover what we want.

kentfredric commented 4 years ago

That sounds reasonable. Just a follow up though, is it fair to say that this means "default-features = false" is inherently unsupported? ( Or perhaps, unsupported unless your crate intends to also demand futures specifically selected by their consumers ).

If so, it may pay to put a cfg! bomb in there so it won't build without one of a minimal set.

( Otherwise, the existence of this bug will serve its own purpose if anyone else goes looking )

dtolnay commented 4 years ago

default-features = false is supported.