Skip to content

Commit 8f06188

Browse files
committed
Auto merge of #60053 - Xanewok:serde-save-analysis, r=nrc
save-analysis: Use serde instead of libserialize to dump JSON data This breaks the save-analysis infrastructure (which also includes `rls-{analysis, data, span}` crates) from depending on rustc_serialize and so we can start moving them to being supported on stable without implementing `Decodable` et al. by hand for data structures defined there. Notable benefits: - we drop the awkward raw byte `PathBuf` [serialization](https://gist.github.com/Xanewok/f4fe8564d0dc0c3ab1dbc244279ff895) (until now (de)serialized as `&[u8]`) - [faster](https://github.com/serde-rs/json-benchmark) (hopefully noticeable for inner crate dependencies for the RLS workloads) - we can easily explore the binary serialization backend (which we planned to do for save-analysis anyway) ~This should be merged together with an update to RLS (rust-lang/rls#1435), which technically could be included right now because we can use the bundled `rls-analysis` here directly, however I'd prefer to publish this to crates.io first (rust-lang/rls#1434, cc @nrc) and use the published version, instead.~ Includes rust-lang/rls#1436. @matklad @nikomatsakis This is also important for the potential RLS 1.0 - 2.0 bridge we talked about on Zulip today
2 parents 247b505 + 2dccaa7 commit 8f06188

File tree

6 files changed

+43
-44
lines changed

6 files changed

+43
-44
lines changed

Cargo.lock

+29-32
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ dependencies = [
13671367

13681368
[[package]]
13691369
name = "lsp-types"
1370-
version = "0.55.4"
1370+
version = "0.57.0"
13711371
source = "registry+https://github.com/rust-lang/crates.io-index"
13721372
dependencies = [
13731373
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2029,7 +2029,7 @@ dependencies = [
20292029

20302030
[[package]]
20312031
name = "racer"
2032-
version = "2.1.21"
2032+
version = "2.1.22"
20332033
source = "registry+https://github.com/rust-lang/crates.io-index"
20342034
dependencies = [
20352035
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2039,7 +2039,7 @@ dependencies = [
20392039
"humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
20402040
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
20412041
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
2042-
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
2042+
"rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
20432043
"rustc-ap-syntax 407.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
20442044
]
20452045

@@ -2221,7 +2221,7 @@ dependencies = [
22212221

22222222
[[package]]
22232223
name = "rls"
2224-
version = "1.35.0"
2224+
version = "1.36.0"
22252225
dependencies = [
22262226
"cargo 0.37.0",
22272227
"cargo_metadata 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2238,19 +2238,19 @@ dependencies = [
22382238
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
22392239
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
22402240
"lsp-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
2241-
"lsp-types 0.55.4 (registry+https://github.com/rust-lang/crates.io-index)",
2241+
"lsp-types 0.57.0 (registry+https://github.com/rust-lang/crates.io-index)",
22422242
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
22432243
"ordslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
2244-
"racer 2.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
2244+
"racer 2.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
22452245
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
22462246
"rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
22472247
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
2248-
"rls-analysis 0.16.12 (registry+https://github.com/rust-lang/crates.io-index)",
2248+
"rls-analysis 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
22492249
"rls-blacklist 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
2250-
"rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
2250+
"rls-data 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
22512251
"rls-rustc 0.6.0",
2252-
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
2253-
"rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
2252+
"rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
2253+
"rls-vfs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
22542254
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
22552255
"rustc-workspace-hack 1.0.0",
22562256
"rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2270,17 +2270,18 @@ dependencies = [
22702270

22712271
[[package]]
22722272
name = "rls-analysis"
2273-
version = "0.16.12"
2273+
version = "0.17.0"
22742274
source = "registry+https://github.com/rust-lang/crates.io-index"
22752275
dependencies = [
22762276
"derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
22772277
"fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
22782278
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
22792279
"json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)",
22802280
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
2281-
"rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
2282-
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
2283-
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
2281+
"rls-data 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
2282+
"rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
2283+
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
2284+
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
22842285
]
22852286

22862287
[[package]]
@@ -2290,13 +2291,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
22902291

22912292
[[package]]
22922293
name = "rls-data"
2293-
version = "0.18.2"
2294+
version = "0.19.0"
22942295
source = "registry+https://github.com/rust-lang/crates.io-index"
22952296
dependencies = [
2296-
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
2297-
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
2297+
"rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
22982298
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
2299-
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
23002299
]
23012300

23022301
[[package]]
@@ -2305,21 +2304,19 @@ version = "0.6.0"
23052304

23062305
[[package]]
23072306
name = "rls-span"
2308-
version = "0.4.1"
2307+
version = "0.5.1"
23092308
source = "registry+https://github.com/rust-lang/crates.io-index"
23102309
dependencies = [
2311-
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
23122310
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
2313-
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
23142311
]
23152312

23162313
[[package]]
23172314
name = "rls-vfs"
2318-
version = "0.7.0"
2315+
version = "0.8.0"
23192316
source = "registry+https://github.com/rust-lang/crates.io-index"
23202317
dependencies = [
23212318
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
2322-
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
2319+
"rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
23232320
]
23242321

23252322
[[package]]
@@ -2930,14 +2927,14 @@ name = "rustc_save_analysis"
29302927
version = "0.0.0"
29312928
dependencies = [
29322929
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
2933-
"rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
2934-
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
2930+
"rls-data 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
2931+
"rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
29352932
"rustc 0.0.0",
2936-
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
29372933
"rustc_codegen_utils 0.0.0",
29382934
"rustc_data_structures 0.0.0",
29392935
"rustc_target 0.0.0",
29402936
"rustc_typeck 0.0.0",
2937+
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
29412938
"syntax 0.0.0",
29422939
"syntax_pos 0.0.0",
29432940
]
@@ -4125,7 +4122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
41254122
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
41264123
"checksum log_settings 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19af41f0565d7c19b2058153ad0b42d4d5ce89ec4dbf06ed6741114a8b63e7cd"
41274124
"checksum lsp-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "169d737ad89cf8ddd82d1804d9122f54568c49377665157277cc90d747b1d31a"
4128-
"checksum lsp-types 0.55.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6392b5843615b8a2adeebe87b83fdd29567c0870baba3407a67e6dbfee4712f8"
4125+
"checksum lsp-types 0.57.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d220de1fbbb12b60df17898272579c22329375fc4baa960402fbd17cf0cdd165"
41294126
"checksum lzma-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d1eaa027402541975218bb0eec67d6b0412f6233af96e0d096d31dbdfd22e614"
41304127
"checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
41314128
"checksum macro-utils 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2c4deaccc2ead6a28c16c0ba82f07d52b6475397415ce40876e559b0b0ea510"
@@ -4191,7 +4188,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
41914188
"checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45"
41924189
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
41934190
"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c"
4194-
"checksum racer 2.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "37c88638777cc178684cf648ca0e1dad56646ce105b8593dfe665c436300adc3"
4191+
"checksum racer 2.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4323343f25bc372dc9293ac6b5cd3034b32784af1e7de9366b4db71466d8c7"
41954192
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
41964193
"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a"
41974194
"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a"
@@ -4210,11 +4207,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
42104207
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
42114208
"checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1"
42124209
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
4213-
"checksum rls-analysis 0.16.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ae18d8ad01dec3b2014f4d7ae3c607d7adbcff79e5d3b48ea42ea71c10d43a71"
4210+
"checksum rls-analysis 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d53d49a28f75da9d02790d9256fecf6c0481e0871374326023c7a33131295579"
42144211
"checksum rls-blacklist 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ce1fdac03e138c4617ff87b194e1ff57a39bb985a044ccbd8673d30701e411"
4215-
"checksum rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f80b84551b32e26affaf7f12374913b5061730c0dcd185d9e8fa5a15e36e65c"
4216-
"checksum rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "33d66f1d6c6ccd5c98029f162544131698f6ebb61d8c697681cac409dcd08805"
4217-
"checksum rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72d56425bd5aa86d9d4372b76f0381d3b4bda9c0220e71956c9fcc929f45c1f1"
4212+
"checksum rls-data 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "76c72ea97e045be5f6290bb157ebdc5ee9f2b093831ff72adfaf59025cf5c491"
4213+
"checksum rls-span 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f1cb4694410d8d2ce43ccff3682f1c782158a018d5a9a92185675677f7533eb3"
4214+
"checksum rls-vfs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce4b57b25b4330ed5ec14028fc02141e083ddafda327e7eb598dc0569c8c83c9"
42184215
"checksum rustc-ap-arena 407.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5aab2fb5e5becf1c9183f6c63b8714817a3e780a20b4fe6b3920751c98a18225"
42194216
"checksum rustc-ap-graphviz 407.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0235ff613d4f96176ea56748010b5d8e978605cc47856ba9bb5372f4f38e9c03"
42204217
"checksum rustc-ap-rustc_cratesio_shim 407.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63e04a90b0dd8597da83633961698c61a2948f50c9d4b9a71e8afafc0ba0f158"

src/librustc_save_analysis/Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ rustc_data_structures = { path = "../librustc_data_structures" }
1616
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
1717
rustc_target = { path = "../librustc_target" }
1818
rustc_typeck = { path = "../librustc_typeck" }
19+
serde_json = "1"
1920
syntax = { path = "../libsyntax" }
2021
syntax_pos = { path = "../libsyntax_pos" }
21-
rls-data = "0.18.1"
22-
rls-span = "0.4"
23-
# FIXME(#40527) should move rustc serialize out of tree
24-
rustc-serialize = "0.3"
22+
rls-data = "0.19"
23+
rls-span = "0.5"

src/librustc_save_analysis/json_dumper.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use std::io::Write;
22

3-
use rustc_serialize::json::as_json;
4-
53
use rls_data::config::Config;
64
use rls_data::{self, Analysis, CompilationOptions, CratePreludeData, Def, DefKind, Impl, Import,
75
MacroRef, Ref, RefKind, Relation};
@@ -31,8 +29,8 @@ pub struct WriteOutput<'b, W: Write> {
3129

3230
impl<'b, W: Write> DumpOutput for WriteOutput<'b, W> {
3331
fn dump(&mut self, result: &Analysis) {
34-
if write!(self.output, "{}", as_json(&result)).is_err() {
35-
error!("Error writing output");
32+
if let Err(e) = serde_json::to_writer(self.output.by_ref(), result) {
33+
error!("Can't serialize save-analysis: {:?}", e);
3634
}
3735
}
3836
}

src/librustc_save_analysis/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1141,10 +1141,15 @@ fn find_config(supplied: Option<Config>) -> Config {
11411141
if let Some(config) = supplied {
11421142
return config;
11431143
}
1144+
11441145
match env::var_os("RUST_SAVE_ANALYSIS_CONFIG") {
1145-
Some(config_string) => rustc_serialize::json::decode(config_string.to_str().unwrap())
1146-
.expect("Could not deserialize save-analysis config"),
11471146
None => Config::default(),
1147+
Some(config) => config.to_str()
1148+
.ok_or(())
1149+
.map_err(|_| error!("`RUST_SAVE_ANALYSIS_CONFIG` isn't UTF-8"))
1150+
.and_then(|cfg| serde_json::from_str(cfg)
1151+
.map_err(|_| error!("Could not deserialize save-analysis config"))
1152+
).unwrap_or_default()
11481153
}
11491154
}
11501155

src/test/run-pass-fulldeps/newtype_index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(rustc_attrs, rustc_private, step_trait)]
22

33
#[macro_use] extern crate rustc_data_structures;
4-
extern crate rustc_serialize;
4+
extern crate serialize as rustc_serialize;
55

66
use rustc_data_structures::indexed_vec::Idx;
77

src/tools/rls

Submodule rls updated from b202e14 to 20e3268

0 commit comments

Comments
 (0)