rustc-serialize icon indicating copy to clipboard operation
rustc-serialize copied to clipboard

"unimplemented!" encode/decode implementations for wasm

Open chrysn opened this issue 7 years ago • 20 comments
trafficstars

The cfg() guards around the encode/decode implementations result in the crate being unusable on wasm32-unknown-unknown.

These lines don't implement the functionality for that platform (there is file system equivalent there), which makes the crate usable again for file system unrelated tasks like encoding using the "cbor" crate.

chrysn avatar Dec 04 '17 10:12 chrysn

This implementation is wrong. If you use the emscripten target, this now compiles in both the unix implementation and the unknown implementation.

CryZe avatar Jan 16 '18 17:01 CryZe

Also, can we get this merged? At the moment the num crate doesn't compile because of rustc-serialize not compiling. Not sure why they still use it, but I guess they can't switch to serde before the next major version.

CryZe avatar Jan 16 '18 17:01 CryZe

I was unaware that emscripten sets the "unix"-cfg; is there any way to have an "else" part in the cfg variations to do this cleaner, or should I rephrase the non-implementation to be #[cfg(not(any(target_os="redox", unix, windows)))] guarded?

chrysn avatar Jan 16 '18 17:01 chrysn

You can't do else afaik, so you could either do the not(any(...)) or specify wasm32, not emscripten. I think the former makes more sense, as it automatically supports all other targets too

CryZe avatar Jan 16 '18 17:01 CryZe

We'd like this merged too, and rand version bumped 0.4, which had a wasm fix in https://github.com/rust-lang-nursery/rand/pull/197.

cdetrio avatar Jan 18 '18 10:01 cdetrio

Updated the commit to reflect CryZe's findings about wasm-emscripten; tested under unix and wasm32-unknown-unknown.

chrysn avatar Jan 18 '18 13:01 chrysn

Rust recently added CloudABI support, and this will cause encode/decode to become unimplemented! for target_os = "cloudabi", which I don't think is correct.

kennytm avatar Jan 22 '18 16:01 kennytm

The CI fails to compile this because the latest rand doesn't compile on 1.0 anymore. So this PR itself compiles just fine. It'd be nice if someone could tell us what we should do about this (maybe just remove the 1.0 compilation?) or just merge the PR regardless.

CryZe avatar Jan 22 '18 16:01 CryZe

@kennytm well that didn't compile before at all then. But I guess we can fix it in this PR too.

CryZe avatar Jan 22 '18 16:01 CryZe

Instead of removing 1.0.0, better just restrict the rand dependency to a version which 1.0.0 can work, something like:

[dev-dependencies]
rand = ">=0.3.0, <=0.3.20"

(Note: I haven't checked which rand version does work on 1.0.0. The last successful build uses 0.3.16)

kennytm avatar Jan 22 '18 16:01 kennytm

May I ask that we keep unrelated issues (like rand versions) in their own issue?

I'm happy to address regressions this issue introduces, but target_os="cloudabi" looks like something that wouldn't work before this pull request (unless windows or unix are set); so if cloudabi yet another implementation of Encodable and Decodable, I suggest that a version be branched off this PR that adds the implementations and adds ,target_os="cloudabi" to the not-any clause to avoid merge conflicts.

chrysn avatar Jan 22 '18 17:01 chrysn

Is there a way to get this moving somehow?

tomaka avatar Mar 14 '18 10:03 tomaka

@alexcrichton is there a way to get this PR moving again? From what I understand it seems critical to getting a lot of Rust projects that still depend on rustc-serialize into wasm. Obviously the best solution would be to switch projects to serde, but this seems like a good stopgap for cases where that's unfeasible.

cwervo avatar Mar 26 '18 18:03 cwervo

This library is currently unmaintained and not publishing new releases, so there is currently not process or timeline for publishing this. Crates depending on rustc-serialize which also want to support new platforms will need to update to a serialization framework like Serde

alexcrichton avatar Apr 02 '18 21:04 alexcrichton

@alexcrichton There's still a lot of ecosystem critical libraries like num that still depend on rustc-serialize for semver reasons. So I think a new release for this makes sense.

If there's no maintainer here willing to merge and publish this, would it make sense to give someone like tomaka the rights to just push this real quick? This doesn't seem like it would take a lot of effort and affects the new wasm target a lot.

CryZe avatar Apr 02 '18 22:04 CryZe

Is it possible to get this going? Many community packages are depending on this. rust-crypto for example.

sallar avatar May 27 '18 20:05 sallar

Please fix this.

BelfordZ avatar Jun 08 '18 20:06 BelfordZ

This library is currently unmaintained and not publishing new releases

The README states:

No new feature development will happen in this crate, although bug fixes proposed through PRs will still be merged.

This PR looks to me like a bug fix and one that really affects the experience of targeting WASM from Rust.

Crates depending on rustc-serialize which also want to support new platforms will need to update to a serialization framework like Serde

This is an option for crate maintainers, but not users of those crates (which may no longer be maintained).

varkor avatar Sep 21 '18 14:09 varkor

Why don't we make the implementation that's currently used for redox work for not(any(unix,windows))? That should work for most platforms.

jethrogb avatar Jan 11 '19 05:01 jethrogb

Filed #195 with the same

jethrogb avatar Jan 11 '19 06:01 jethrogb