"rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_codegen_utils 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_target 0.0.0",
"rustc_typeck 0.0.0",
+ "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syntax 0.0.0",
"syntax_pos 0.0.0",
]
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
rustc_target = { path = "../librustc_target" }
rustc_typeck = { path = "../librustc_typeck" }
+serde_json = "1"
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
rls-data = "0.18.1"
rls-span = "0.4"
-# FIXME(#40527) should move rustc serialize out of tree
-rustc-serialize = "0.3"
use std::io::Write;
-use rustc_serialize::json::as_json;
-
use rls_data::config::Config;
use rls_data::{self, Analysis, CompilationOptions, CratePreludeData, Def, DefKind, Impl, Import,
MacroRef, Ref, RefKind, Relation};
impl<'b, W: Write> DumpOutput for WriteOutput<'b, W> {
fn dump(&mut self, result: &Analysis) {
- if write!(self.output, "{}", as_json(&result)).is_err() {
- error!("Error writing output");
+ if let Err(e) = serde_json::to_writer(self.output.by_ref(), result) {
+ error!("Can't serialize save-analysis: {:?}", e);
}
}
}
if let Some(config) = supplied {
return config;
}
+
match env::var_os("RUST_SAVE_ANALYSIS_CONFIG") {
- Some(config_string) => rustc_serialize::json::decode(config_string.to_str().unwrap())
- .expect("Could not deserialize save-analysis config"),
None => Config::default(),
+ Some(config) => config.to_str()
+ .ok_or(())
+ .map_err(|_| error!("`RUST_SAVE_ANALYSIS_CONFIG` isn't UTF-8"))
+ .and_then(|cfg| serde_json::from_str(cfg)
+ .map_err(|_| error!("Could not deserialize save-analysis config"))
+ ).unwrap_or_default()
}
}