You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit: And of course the literal second I submit the issue I realize I'm in the json repository, not the main one. Sorry about that.
It's been mentioned that, since not all OsStrings are valid Strings, serializing them to JSON causes problems.
However, since as far as I know all Strings are valid OsStrings, I'd expect serde to deserialize into a String or &str then convert it to an OsString or &OsStr.
Rust version: 1.68.2 stable
Cargo.toml:
[package]
name = "serde_osstring"version = "0.1.0"edition = "2021"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.160", features = ["derive"] }
serde_json = "1.0.96"
main.rs:
use serde::Deserialize;use serde_json;use std::ffi::OsString;#[derive(Deserialize)]structA{x:OsString}fnmain(){
serde_json::from_str::<A>("{\"x\": \"y\"}").unwrap();}
Error with backtrace:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unknown variant `y`, expected `Unix` or `Windows`", line: 1, column: 9)', src/main.rs:11:49
stack backtrace:
0: 0x55c6719d55fa - std::backtrace_rs::backtrace::libunwind::trace::ha271a8a7e1f3d4ef
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x55c6719d55fa - std::backtrace_rs::backtrace::trace_unsynchronized::h85739da0352c791a
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x55c6719d55fa - std::sys_common::backtrace::_print_fmt::hbc6ebcfb2910b329
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:65:5
3: 0x55c6719d55fa - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he1c117e52d53614f
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:44:22
4: 0x55c6719f2d5e - core::fmt::write::h25eb51b9526b8e0c
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/fmt/mod.rs:1213:17
5: 0x55c6719d3685 - std::io::Write::write_fmt::ha9edec5fb1621933
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/io/mod.rs:1682:15
6: 0x55c6719d53c5 - std::sys_common::backtrace::_print::hf8657cd429fc3452
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:47:5
7: 0x55c6719d53c5 - std::sys_common::backtrace::print::h41b9b18ed86f86bd
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:34:9
8: 0x55c6719d6a4f - std::panicking::default_hook::{{closure}}::h22a91871f4454152
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:267:22
9: 0x55c6719d678b - std::panicking::default_hook::h21ddc36de0cd4ae7
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:286:9
10: 0x55c6719d7159 - std::panicking::rust_panic_with_hook::h5059419d6d59b3d0
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:688:13
11: 0x55c6719d6ef9 - std::panicking::begin_panic_handler::{{closure}}::h0f383c291cd78343
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:579:13
12: 0x55c6719d5aac - std::sys_common::backtrace::__rust_end_short_backtrace::h70ab22f2ad318cdd
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:137:18
13: 0x55c6719d6c02 - rust_begin_unwind
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:575:5
14: 0x55c6719a5d73 - core::panicking::panic_fmt::hd1d46bcde3c61d72
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:64:14
15: 0x55c6719a61c3 - core::result::unwrap_failed::h456a23f68607268c
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/result.rs:1790:5
16: 0x55c6719a66bc - core::result::Result<T,E>::unwrap::h56594b553cab4079
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/result.rs:1112:23
17: 0x55c6719a72b0 - serde_osstring::main::h8c52b5dd0a5f834f
at /home/james/Desktop/serde_osstring/src/main.rs:11:5
18: 0x55c6719a67fb - core::ops::function::FnOnce::call_once::h64223838b298f290
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/ops/function.rs:250:5
19: 0x55c6719a7ece - std::sys_common::backtrace::__rust_begin_short_backtrace::h84f44f7b4c2d9400
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:121:18
20: 0x55c6719a7381 - std::rt::lang_start::{{closure}}::hf61f028edf677e65
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/rt.rs:166:18
21: 0x55c6719d1a7c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h203afb3af230319a
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/ops/function.rs:287:13
22: 0x55c6719d1a7c - std::panicking::try::do_call::hf68e87013b70f3c5
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:483:40
23: 0x55c6719d1a7c - std::panicking::try::h040ea8f298390ba2
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:447:19
24: 0x55c6719d1a7c - std::panic::catch_unwind::h1e17b198887a05fa
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panic.rs:140:14
25: 0x55c6719d1a7c - std::rt::lang_start_internal::{{closure}}::hfb902d8927e51b86
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/rt.rs:148:48
26: 0x55c6719d1a7c - std::panicking::try::do_call::h354e6eb41f2e7d42
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:483:40
27: 0x55c6719d1a7c - std::panicking::try::h4a39749cd018228c
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:447:19
28: 0x55c6719d1a7c - std::panic::catch_unwind::h30bce83b8de61cca
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panic.rs:140:14
29: 0x55c6719d1a7c - std::rt::lang_start_internal::h8f7e70b1a2558118
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/rt.rs:148:20
30: 0x55c6719a735a - std::rt::lang_start::h358a865e45ef7ee6
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/rt.rs:165:17
31: 0x55c6719a731e - main
32: 0x7fc82a829d90 - __libc_start_call_main
at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
33: 0x7fc82a829e40 - __libc_start_main_impl
at ./csu/../csu/libc-start.c:392:3
34: 0x55c6719a6305 - _start
35: 0x0 - <unknown>
The text was updated successfully, but these errors were encountered:
Edit: And of course the literal second I submit the issue I realize I'm in the json repository, not the main one. Sorry about that.
It's been mentioned that, since not all
OsString
s are validString
s, serializing them to JSON causes problems.However, since as far as I know all
String
s are validOsString
s, I'd expect serde to deserialize into aString
or&str
then convert it to anOsString
or&OsStr
.Rust version: 1.68.2 stable
Cargo.toml:
main.rs:
Error with backtrace:
The text was updated successfully, but these errors were encountered: