From dd4b53402d469e80151845bf28c74c6782d775f1 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 5 Jan 2022 19:35:48 +0100 Subject: [PATCH] Regenrate docs and package.json --- crates/hir_def/src/db.rs | 2 -- crates/rust-analyzer/src/config.rs | 13 ++++++++++++- crates/rust-analyzer/src/reload.rs | 6 +++--- docs/user/generated_config.adoc | 6 ++++++ editors/code/package.json | 5 +++++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/crates/hir_def/src/db.rs b/crates/hir_def/src/db.rs index 9f93bbd27b..7946558311 100644 --- a/crates/hir_def/src/db.rs +++ b/crates/hir_def/src/db.rs @@ -55,8 +55,6 @@ pub trait InternDatabase: SourceDatabase { pub trait DefDatabase: InternDatabase + AstDatabase + Upcast { #[salsa::input] fn enable_proc_attr_macros(&self) -> bool; - #[salsa::input] - fn enablse_proc_attr_macros(&self) -> bool; #[salsa::invoke(ItemTree::file_item_tree_query)] fn file_item_tree(&self, file_id: HirFileId) -> Arc; diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 665609cf9a..dba772259f 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -301,6 +301,8 @@ config_data! { /// Internal config, path to proc-macro server executable (typically, /// this is rust-analyzer itself, but we override this in tests). procMacro_server: Option = "null", + /// Replaces the proc-macro expanders for the named proc-macros in the named crates with + /// an identity expander that outputs the input again. procMacro_dummies: FxHashMap, Box<[Box]>> = "{}", /// Command to be executed instead of 'cargo' for runnables. @@ -1167,7 +1169,13 @@ fn get_field( .find_map(move |field| { let mut pointer = field.replace('_', "/"); pointer.insert(0, '/'); - json.pointer_mut(&pointer).and_then(|it| serde_json::from_value(it.take()).ok()) + json.pointer_mut(&pointer).and_then(|it| match serde_json::from_value(it.take()) { + Ok(it) => Some(it), + Err(e) => { + tracing::warn!("Failed to deserialize config field at {}: {:?}", pointer, e); + None + } + }) }) .unwrap_or(default) } @@ -1228,6 +1236,9 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json "items": { "type": "string" }, "uniqueItems": true, }, + "FxHashMap, Box<[Box]>>" => set! { + "type": "object", + }, "FxHashMap" => set! { "type": "object", }, diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index c687466bd2..eecc83e02a 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -291,9 +291,6 @@ impl GlobalState { } }, }; - self.analysis_host - .raw_database_mut() - .set_enable_proc_attr_macros(self.config.expand_proc_attr_macros()); } let watch = match files_config.watcher { @@ -514,6 +511,8 @@ impl SourceRootConfig { } } +/// Load the proc-macros for the given lib path, replacing all expanders whose names are in `dummy_replace` +/// with an identity dummy expander. pub(crate) fn load_proc_macro( client: Option<&ProcMacroServer>, path: &AbsPath, @@ -586,6 +585,7 @@ pub(crate) fn load_proc_macro( } } + /// Dummy identity expander, used for proc-macros that are deliberately ignored by the user. #[derive(Debug)] struct DummyExpander; diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index 494051b306..0b9abadf98 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc @@ -455,6 +455,12 @@ Enable support for procedural macros, implies `#rust-analyzer.cargo.runBuildScri Internal config, path to proc-macro server executable (typically, this is rust-analyzer itself, but we override this in tests). -- +[[rust-analyzer.procMacro.dummies]]rust-analyzer.procMacro.dummies (default: `{}`):: ++ +-- +Replaces the proc-macro expanders for the named proc-macros in the named crates with +an identity expander that outputs the input again. +-- [[rust-analyzer.runnables.overrideCargo]]rust-analyzer.runnables.overrideCargo (default: `null`):: + -- diff --git a/editors/code/package.json b/editors/code/package.json index 57757553a7..e7c958050e 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -880,6 +880,11 @@ "string" ] }, + "rust-analyzer.procMacro.dummies": { + "markdownDescription": "Replaces the proc-macro expanders for the named proc-macros in the named crates with\nan identity expander that outputs the input again.", + "default": {}, + "type": "object" + }, "rust-analyzer.runnables.overrideCargo": { "markdownDescription": "Command to be executed instead of 'cargo' for runnables.", "default": null,