The impls added in #22235 violate some assumptions in libserialize by trying to serialize multiple values for the "lines" field. When decoding, it ends up hitting this unwrap.
#![feature(rustc_private)]
extern crate syntax_pos;
extern crate serialize;
use std::cell::RefCell;
use syntax_pos::{FileMap, BytePos};
use serialize::json;
fn main() {
let file_map = FileMap {
name: "rustc".to_owned(),
name_was_remapped: false,
crate_of_origin: 0,
src: None,
start_pos: BytePos(0),
end_pos: BytePos(0),
lines: RefCell::new(vec![BytePos(1), BytePos(2), BytePos(3)]),
multibyte_chars: RefCell::new(vec![]),
};
let j = json::as_pretty_json(&file_map).to_string();
println!("{}", j);
// panic in libserialize
let _ = json::decode::<FileMap>(&j);
}
{
"name": "rustc",
"name_was_remapped": false,
"start_pos": 0,
"end_pos": 0,
"lines": 31111,
"multibyte_chars": []
}
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:335
This may not be important if it has worked for this long, but there may be other variations of this bug lurking elsewhere.
The impls added in #22235 violate some assumptions in libserialize by trying to serialize multiple values for the "lines" field. When decoding, it ends up hitting this unwrap.
This may not be important if it has worked for this long, but there may be other variations of this bug lurking elsewhere.