diff options
author | James Leitch <[email protected]> | 2021-04-21 23:09:37 +0100 |
---|---|---|
committer | James Leitch <[email protected]> | 2021-04-21 23:10:53 +0100 |
commit | 72718bc2d7113874536b8bcd486aa5bd7dacafe6 (patch) | |
tree | c5859e4eb7334478b5e9ba58329b67df43e39305 | |
parent | 9fcad829807a0306fbf4eb2ebc1603a11a6df182 (diff) |
Code review feedback.
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 6 | ||||
-rw-r--r-- | crates/rust-analyzer/src/diagnostics.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 10 | ||||
-rw-r--r-- | docs/user/generated_config.adoc | 4 | ||||
-rw-r--r-- | editors/code/package.json | 4 |
5 files changed, 14 insertions, 12 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 3be335550..1109d2daf 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -99,9 +99,9 @@ config_data! { | |||
99 | diagnostics_enableExperimental: bool = "true", | 99 | diagnostics_enableExperimental: bool = "true", |
100 | /// List of rust-analyzer diagnostics to disable. | 100 | /// List of rust-analyzer diagnostics to disable. |
101 | diagnostics_disabled: FxHashSet<String> = "[]", | 101 | diagnostics_disabled: FxHashSet<String> = "[]", |
102 | /// Map of path prefixes to be substituted when parsing diagnostic file paths. | 102 | /// Map of prefixes to be substituted when parsing diagnostic file paths. |
103 | /// This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`. | 103 | /// This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`. |
104 | diagnostics_remapPathPrefixes: FxHashMap<String, String> = "{}", | 104 | diagnostics_remapPrefix: FxHashMap<String, String> = "{}", |
105 | /// List of warnings that should be displayed with info severity. | 105 | /// List of warnings that should be displayed with info severity. |
106 | /// | 106 | /// |
107 | /// The warnings will be indicated by a blue squiggly underline in code | 107 | /// The warnings will be indicated by a blue squiggly underline in code |
@@ -477,7 +477,7 @@ impl Config { | |||
477 | } | 477 | } |
478 | pub fn diagnostics_map(&self) -> DiagnosticsMapConfig { | 478 | pub fn diagnostics_map(&self) -> DiagnosticsMapConfig { |
479 | DiagnosticsMapConfig { | 479 | DiagnosticsMapConfig { |
480 | remap_path_prefixes: self.data.diagnostics_remapPathPrefixes.clone(), | 480 | remap_prefix: self.data.diagnostics_remapPrefix.clone(), |
481 | warnings_as_info: self.data.diagnostics_warningsAsInfo.clone(), | 481 | warnings_as_info: self.data.diagnostics_warningsAsInfo.clone(), |
482 | warnings_as_hint: self.data.diagnostics_warningsAsHint.clone(), | 482 | warnings_as_hint: self.data.diagnostics_warningsAsHint.clone(), |
483 | } | 483 | } |
diff --git a/crates/rust-analyzer/src/diagnostics.rs b/crates/rust-analyzer/src/diagnostics.rs index 776d21778..d4b9db362 100644 --- a/crates/rust-analyzer/src/diagnostics.rs +++ b/crates/rust-analyzer/src/diagnostics.rs | |||
@@ -12,7 +12,7 @@ pub(crate) type CheckFixes = Arc<FxHashMap<FileId, Vec<Fix>>>; | |||
12 | 12 | ||
13 | #[derive(Debug, Default, Clone)] | 13 | #[derive(Debug, Default, Clone)] |
14 | pub struct DiagnosticsMapConfig { | 14 | pub struct DiagnosticsMapConfig { |
15 | pub remap_path_prefixes: FxHashMap<String, String>, | 15 | pub remap_prefix: FxHashMap<String, String>, |
16 | pub warnings_as_info: Vec<String>, | 16 | pub warnings_as_info: Vec<String>, |
17 | pub warnings_as_hint: Vec<String>, | 17 | pub warnings_as_hint: Vec<String>, |
18 | } | 18 | } |
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 08303a781..82dd0da9a 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -99,10 +99,12 @@ fn diagnostic_related_information( | |||
99 | /// Resolves paths applying any matching path prefix remappings, and then | 99 | /// Resolves paths applying any matching path prefix remappings, and then |
100 | /// joining the path to the workspace root. | 100 | /// joining the path to the workspace root. |
101 | fn resolve_path(config: &DiagnosticsMapConfig, workspace_root: &Path, file_name: &str) -> PathBuf { | 101 | fn resolve_path(config: &DiagnosticsMapConfig, workspace_root: &Path, file_name: &str) -> PathBuf { |
102 | match config.remap_path_prefixes.iter().find(|(from, _)| file_name.starts_with(*from)) { | 102 | match config |
103 | Some((from, to)) => { | 103 | .remap_prefix |
104 | workspace_root.join(format!("{}{}", to, file_name.strip_prefix(from).unwrap())) | 104 | .iter() |
105 | } | 105 | .find_map(|(from, to)| file_name.strip_prefix(from).map(|file_name| (to, file_name))) |
106 | { | ||
107 | Some((to, file_name)) => workspace_root.join(format!("{}{}", to, file_name)), | ||
106 | None => workspace_root.join(file_name), | 108 | None => workspace_root.join(file_name), |
107 | } | 109 | } |
108 | } | 110 | } |
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index cb6fe5850..e28423e99 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc | |||
@@ -147,10 +147,10 @@ have more false positives than usual. | |||
147 | -- | 147 | -- |
148 | List of rust-analyzer diagnostics to disable. | 148 | List of rust-analyzer diagnostics to disable. |
149 | -- | 149 | -- |
150 | [[rust-analyzer.diagnostics.remapPathPrefixes]]rust-analyzer.diagnostics.remapPathPrefixes (default: `{}`):: | 150 | [[rust-analyzer.diagnostics.remapPrefix]]rust-analyzer.diagnostics.remapPrefix (default: `{}`):: |
151 | + | 151 | + |
152 | -- | 152 | -- |
153 | Map of path prefixes to be substituted when parsing diagnostic file paths. | 153 | Map of prefixes to be substituted when parsing diagnostic file paths. |
154 | This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`. | 154 | This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`. |
155 | -- | 155 | -- |
156 | [[rust-analyzer.diagnostics.warningsAsHint]]rust-analyzer.diagnostics.warningsAsHint (default: `[]`):: | 156 | [[rust-analyzer.diagnostics.warningsAsHint]]rust-analyzer.diagnostics.warningsAsHint (default: `[]`):: |
diff --git a/editors/code/package.json b/editors/code/package.json index dcb2e89d1..fa5632f90 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -565,8 +565,8 @@ | |||
565 | }, | 565 | }, |
566 | "uniqueItems": true | 566 | "uniqueItems": true |
567 | }, | 567 | }, |
568 | "rust-analyzer.diagnostics.remapPathPrefixes": { | 568 | "rust-analyzer.diagnostics.remapPrefix": { |
569 | "markdownDescription": "Map of path prefixes to be substituted when parsing diagnostic file paths.\nThis should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`.", | 569 | "markdownDescription": "Map of prefixes to be substituted when parsing diagnostic file paths.\nThis should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`.", |
570 | "default": {}, | 570 | "default": {}, |
571 | "type": "object" | 571 | "type": "object" |
572 | }, | 572 | }, |