From 4e6c1dddff853703bd31a8f3390e8aa2d4856fe8 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Wed, 2 Aug 2017 15:46:59 +1200 Subject: [PATCH 1/4] save-analysis: only emit public fields in value of a struct if the config permits --- src/librustc_save_analysis/dump_visitor.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index f74e8cb2160..4cfd570adea 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -560,14 +560,20 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { let (value, fields) = if let ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, _), _) = item.node { + let include_priv_fields = !self.save_ctxt.config.pub_only; let fields_str = fields.iter() .enumerate() - .map(|(i, f)| f.ident.map(|i| i.to_string()) - .unwrap_or(i.to_string())) + .filter_map(|(i, f)| { + if include_priv_fields || f.vis == ast::Visibility::Public { + f.ident.map(|i| i.to_string()).or_else(|| Some(i.to_string())) + } else { + None + } + }) .collect::>() .join(", "); - (format!("{} {{ {} }}", name, fields_str), - fields.iter().map(|f| ::id_from_node_id(f.id, &self.save_ctxt)).collect()) + let value = format!("{} {{ {} }}", name, fields_str); + (value, fields.iter().map(|f| ::id_from_node_id(f.id, &self.save_ctxt)).collect()) } else { (String::new(), vec![]) }; From 8c1699d8740c22397a56b3416a365a6083307c4b Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Wed, 2 Aug 2017 16:57:50 +1200 Subject: [PATCH 2/4] Update rls-data dep --- src/Cargo.lock | 12 +++++++++++- src/librustc_save_analysis/Cargo.toml | 2 +- src/librustc_save_analysis/json_dumper.rs | 10 +++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 5f363cb4c48..9db21d5827d 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1174,6 +1174,15 @@ dependencies = [ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rls-data" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rls-span" version = "0.4.0" @@ -1504,7 +1513,7 @@ name = "rustc_save_analysis" version = "0.0.0" dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (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)", @@ -2220,6 +2229,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" "checksum rls-analysis 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0127cfae9c726461facbbbc8327e782adf8afd61f7fcc6adf8ea9ad8fc428ed0" +"checksum rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11d339f1888e33e74d8032de0f83c40b2bdaaaf04a8cfc03b32186c3481fb534" "checksum rls-data 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f274ec7f966337dc2601fe9bde060b551d1293c277af782dc65cd7200ca070c0" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff" diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index 00b01994eb8..aa249af363f 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -15,7 +15,7 @@ rustc_data_structures = { path = "../librustc_data_structures" } rustc_typeck = { path = "../librustc_typeck" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -rls-data = "0.9" +rls-data = "0.10" rls-span = "0.4" # FIXME(#40527) should move rustc serialize out of tree rustc-serialize = "0.3" diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs index 60cec4c5e46..30a698e6351 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/json_dumper.rs @@ -51,7 +51,11 @@ impl<'b> DumpOutput for CallbackOutput<'b> { impl<'b, W: Write> JsonDumper> { pub fn new(writer: &'b mut W, config: Config) -> JsonDumper> { - JsonDumper { output: WriteOutput { output: writer }, config, result: Analysis::new() } + JsonDumper { + output: WriteOutput { output: writer }, + config: config.clone(), + result: Analysis::new(config) + } } } @@ -61,8 +65,8 @@ impl<'b> JsonDumper> { -> JsonDumper> { JsonDumper { output: CallbackOutput { callback: callback }, - config, - result: Analysis::new(), + config: config.clone(), + result: Analysis::new(config), } } } From 5abbf798e7dc1a9bfbe287d3d3d19e764b28225b Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Wed, 2 Aug 2017 17:21:12 +1200 Subject: [PATCH 3/4] Update RLS --- src/Cargo.lock | 22 +++++++--------------- src/tools/rls | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 9db21d5827d..2b8591ab88e 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1140,8 +1140,8 @@ dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "racer 2.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-analysis 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-analysis 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustfmt-nightly 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1155,21 +1155,12 @@ dependencies = [ [[package]] name = "rls-analysis" -version = "0.4.5" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "derive-new 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rls-data" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ + "rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1181,6 +1172,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2228,9 +2221,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" -"checksum rls-analysis 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0127cfae9c726461facbbbc8327e782adf8afd61f7fcc6adf8ea9ad8fc428ed0" +"checksum rls-analysis 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca5b4d890953b9cc60c8c97f196921d02edf75798ccab930604aa3b4f890616d" "checksum rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11d339f1888e33e74d8032de0f83c40b2bdaaaf04a8cfc03b32186c3481fb534" -"checksum rls-data 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f274ec7f966337dc2601fe9bde060b551d1293c277af782dc65cd7200ca070c0" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff" "checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95" diff --git a/src/tools/rls b/src/tools/rls index 06b48d1c97d..cb8a5900fd3 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 06b48d1c97dd69968a24b4f506e85e3a3efb7dea +Subproject commit cb8a5900fd3b5907b2bac07ca9832f91fed29750 From 2683ba631b41aae266dfc2a8661ca9442db96a2d Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 3 Aug 2017 10:20:01 +1200 Subject: [PATCH 4/4] Appease tidy and fix save-analysis config for dist builds --- src/bootstrap/bin/rustc.rs | 2 +- src/librustc_save_analysis/dump_visitor.rs | 23 +++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index ac2e3bc402a..f6ed4ee91b3 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -188,7 +188,7 @@ fn main() { cmd.arg("-Zsave-analysis"); cmd.env("RUST_SAVE_ANALYSIS_CONFIG", "{\"output_file\": null,\"full_docs\": false,\"pub_only\": true,\ - \"signatures\": false,\"borrow_data\": false}"); + \"distro_crate\": true,\"signatures\": false,\"borrow_data\": false}"); } // Dealing with rpath here is a little special, so let's go into some diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 4cfd570adea..4740f9a0d5a 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -561,17 +561,18 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { if let ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, _), _) = item.node { let include_priv_fields = !self.save_ctxt.config.pub_only; - let fields_str = fields.iter() - .enumerate() - .filter_map(|(i, f)| { - if include_priv_fields || f.vis == ast::Visibility::Public { - f.ident.map(|i| i.to_string()).or_else(|| Some(i.to_string())) - } else { - None - } - }) - .collect::>() - .join(", "); + let fields_str = fields + .iter() + .enumerate() + .filter_map(|(i, f)| { + if include_priv_fields || f.vis == ast::Visibility::Public { + f.ident.map(|i| i.to_string()).or_else(|| Some(i.to_string())) + } else { + None + } + }) + .collect::>() + .join(", "); let value = format!("{} {{ {} }}", name, fields_str); (value, fields.iter().map(|f| ::id_from_node_id(f.id, &self.save_ctxt)).collect()) } else {