SoftbearStudios / SoftbearStudios/bitcode
Implement Encode/Decode for CString
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 671
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
I've updated bitcode, and if you try and build the musli test suite right now like this:
cargo build -p tests --no-default-features --features no-rt,std,alloc,bitcode-derive
You get the following errors
error[E0277]: the trait bound `CString: Encode` is not satisfied in `AllocatedEncoder`
--> crates\tests\src\models.rs:144:47
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^ within `AllocatedEncoder`, the trait `Encode` is not implemented for `CString`, which is required by `<Allocated as Encode>::Encoder: Encoder<Allocated>`
|
= help: the following other types implement trait `Encode`:
bool
char
isize
i8
i16
i32
i64
i128
and 63 others
note: required because it appears within the type `AllocatedEncoder`
--> crates\tests\src\models.rs:144:47
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^
= note: required for `<Allocated as Encode>::Encoder` to implement `Encoder<Allocated>`
note: required by a bound in `bitcode::Encode::Encoder`
--> C:\Users\udoprog\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bitcode-0.6.0\src\derive\mod.rs:33:19
|
33 | type Encoder: Encoder<Self>;
| ^^^^^^^^^^^^^ required by this bound in `Encode::Encoder`
= note: this error originates in the derive macro `bitcode::Encode` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `CString: Encode` is not satisfied
--> crates\tests\src\models.rs:144:47
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `CString`
|
= help: the following other types implement trait `Encode`:
bool
char
isize
i8
i16
i32
i64
i128
and 63 others
= note: this error originates in the derive macro `bitcode::Encode` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `CString: Encode` is not satisfied in `AllocatedEncoder`
--> crates\tests\src\models.rs:144:47
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^ within `AllocatedEncoder`, the trait `Encode` is not implemented for `CString`, which is required by `AllocatedEncoder: Sized`
|
= help: the following other types implement trait `Encode`:
bool
char
isize
i8
i16
i32
i64
i128
and 63 others
note: required because it appears within the type `AllocatedEncoder`
--> crates\tests\src\models.rs:144:47
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^
note: required by a bound in `Default`
--> C:\Users\udoprog\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\default.rs:102:20
|
102 | pub trait Default: Sized {
| ^^^^^ required by this bound in `Default`
= note: this error originates in the derive macro `bitcode::Encode` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `CString: Encode` is not satisfied in `AllocatedEncoder`
--> crates\tests\src\models.rs:144:47
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^ within `AllocatedEncoder`, the trait `Encode` is not implemented for `CString`, which is required by `AllocatedEncoder: Sync`
|
= help: the following other types implement trait `Encode`:
bool
char
isize
i8
i16
i32
i64
i128
and 63 others
note: required because it appears within the type `AllocatedEncoder`
--> crates\tests\src\models.rs:144:47
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^
note: required by a bound in `Encoder`
--> C:\Users\udoprog\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bitcode-0.6.0\src\coder.rs:27:57
|
27 | pub trait Encoder<T: ?Sized>: Buffer + Default + Send + Sync {
| ^^^^ required by this bound in `Encoder`
= note: this error originates in the derive macro `bitcode::Encode` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `CString: Decode<'__de>` is not satisfied in `AllocatedDecoder<'__de>`
--> crates\tests\src\models.rs:144:64
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^ within `AllocatedDecoder<'__de>`, the trait `Decode<'__de>` is not implemented for `CString`, which is required by
`<Allocated as Decode<'__de>>::Decoder: Decoder<'__de, Allocated>`
|
= help: the following other types implement trait `Decode<'a>`:
<bool as Decode<'a>>
<char as Decode<'a>>
<isize as Decode<'a>>
<i8 as Decode<'a>>
<i16 as Decode<'a>>
<i32 as Decode<'a>>
<i64 as Decode<'a>>
<i128 as Decode<'a>>
and 66 others
note: required because it appears within the type `AllocatedDecoder<'__de>`
--> crates\tests\src\models.rs:144:64
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^
= note: required for `<Allocated as Decode<'__de>>::Decoder` to implement `Decoder<'__de, Allocated>`
note: required by a bound in `bitcode::Decode::Decoder`
--> C:\Users\udoprog\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bitcode-0.6.0\src\derive\mod.rs:41:19
|
41 | type Decoder: Decoder<'a, Self>;
| ^^^^^^^^^^^^^^^^^ required by this bound in `Decode::Decoder`
= note: this error originates in the derive macro `bitcode::Decode` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `CString: Decode<'__de>` is not satisfied
--> crates\tests\src\models.rs:144:64
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^ the trait `Decode<'__de>` is not implemented for `CString`
|
= help: the following other types implement trait `Decode<'a>`:
<bool as Decode<'a>>
<char as Decode<'a>>
<isize as Decode<'a>>
<i8 as Decode<'a>>
<i16 as Decode<'a>>
<i32 as Decode<'a>>
<i64 as Decode<'a>>
<i128 as Decode<'a>>
and 66 others
= note: this error originates in the derive macro `bitcode::Decode` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `CString: Decode<'__de>` is not satisfied in `AllocatedDecoder<'__de>`
--> crates\tests\src\models.rs:144:64
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^ within `AllocatedDecoder<'__de>`, the trait `Decode<'__de>` is not implemented for `CString`, which is required by
`AllocatedDecoder<'__de>: Sized`
|
= help: the following other types implement trait `Decode<'a>`:
<bool as Decode<'a>>
<char as Decode<'a>>
<isize as Decode<'a>>
<i8 as Decode<'a>>
<i16 as Decode<'a>>
<i32 as Decode<'a>>
<i64 as Decode<'a>>
<i128 as Decode<'a>>
and 66 others
note: required because it appears within the type `AllocatedDecoder<'__de>`
--> crates\tests\src\models.rs:144:64
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^
note: required by a bound in `Default`
--> C:\Users\udoprog\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\default.rs:102:20
|
102 | pub trait Default: Sized {
| ^^^^^ required by this bound in `Default`
= note: this error originates in the derive macro `bitcode::Decode` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `CString: Decode<'__de>` is not satisfied in `AllocatedDecoder<'__de>`
--> crates\tests\src\models.rs:144:64
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^ within `AllocatedDecoder<'__de>`, the trait `Decode<'__de>` is not implemented for `CString`, which is required by
`AllocatedDecoder<'__de>: Sync`
|
= help: the following other types implement trait `Decode<'a>`:
<bool as Decode<'a>>
<char as Decode<'a>>
<isize as Decode<'a>>
<i8 as Decode<'a>>
<i16 as Decode<'a>>
<i32 as Decode<'a>>
<i64 as Decode<'a>>
<i128 as Decode<'a>>
and 66 others
note: required because it appears within the type `AllocatedDecoder<'__de>`
--> crates\tests\src\models.rs:144:64
|
144 | #[cfg_attr(feature = "bitcode-derive", derive(bitcode::Encode, bitcode::Decode))]
| ^^^^^^^^^^^^^^^
note: required by a bound in `Decoder`
--> C:\Users\udoprog\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bitcode-0.6.0\src\coder.rs:69:55
|
69 | pub trait Decoder<'a, T>: View<'a> + Default + Send + Sync {
| ^^^^ required by this bound in `Decoder`
= note: this error originates in the derive macro `bitcode::Decode` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0277`.
error: could not compile `tests` (lib) due to 8 previous errors
Overall the errors are a bit of a red herring, but first it seems like CString just isn't supported. Second it seems like you might be imposing a Send + Sync bound which might not be necessary (or at least I don't see why it should be!).
If you don't want to add CString support I can carve out a separate category for bitcode derive in my tests.
Thank you!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with cargo build -p tests --no-default-features --features no-rt,std,alloc,bitcode-derive and inspect crates/tests/src/models.rs around line 144. Trace the bitcode::Encode and bitcode::Decode derive errors for CString, including the reported Send and Sync bounds. Done means the test suite builds with CString support, or the issue's requested scope is explicitly resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100