mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 13:18:47 +00:00
Code review feedback.
This commit is contained in:
parent
9fcad82980
commit
72718bc2d7
5 changed files with 14 additions and 12 deletions
|
@ -99,9 +99,9 @@ config_data! {
|
||||||
diagnostics_enableExperimental: bool = "true",
|
diagnostics_enableExperimental: bool = "true",
|
||||||
/// List of rust-analyzer diagnostics to disable.
|
/// List of rust-analyzer diagnostics to disable.
|
||||||
diagnostics_disabled: FxHashSet<String> = "[]",
|
diagnostics_disabled: FxHashSet<String> = "[]",
|
||||||
/// Map of path prefixes to be substituted when parsing diagnostic file paths.
|
/// Map of prefixes to be substituted when parsing diagnostic file paths.
|
||||||
/// This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`.
|
/// This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`.
|
||||||
diagnostics_remapPathPrefixes: FxHashMap<String, String> = "{}",
|
diagnostics_remapPrefix: FxHashMap<String, String> = "{}",
|
||||||
/// List of warnings that should be displayed with info severity.
|
/// List of warnings that should be displayed with info severity.
|
||||||
///
|
///
|
||||||
/// The warnings will be indicated by a blue squiggly underline in code
|
/// The warnings will be indicated by a blue squiggly underline in code
|
||||||
|
@ -477,7 +477,7 @@ impl Config {
|
||||||
}
|
}
|
||||||
pub fn diagnostics_map(&self) -> DiagnosticsMapConfig {
|
pub fn diagnostics_map(&self) -> DiagnosticsMapConfig {
|
||||||
DiagnosticsMapConfig {
|
DiagnosticsMapConfig {
|
||||||
remap_path_prefixes: self.data.diagnostics_remapPathPrefixes.clone(),
|
remap_prefix: self.data.diagnostics_remapPrefix.clone(),
|
||||||
warnings_as_info: self.data.diagnostics_warningsAsInfo.clone(),
|
warnings_as_info: self.data.diagnostics_warningsAsInfo.clone(),
|
||||||
warnings_as_hint: self.data.diagnostics_warningsAsHint.clone(),
|
warnings_as_hint: self.data.diagnostics_warningsAsHint.clone(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub(crate) type CheckFixes = Arc<FxHashMap<FileId, Vec<Fix>>>;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct DiagnosticsMapConfig {
|
pub struct DiagnosticsMapConfig {
|
||||||
pub remap_path_prefixes: FxHashMap<String, String>,
|
pub remap_prefix: FxHashMap<String, String>,
|
||||||
pub warnings_as_info: Vec<String>,
|
pub warnings_as_info: Vec<String>,
|
||||||
pub warnings_as_hint: Vec<String>,
|
pub warnings_as_hint: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,10 +99,12 @@ fn diagnostic_related_information(
|
||||||
/// Resolves paths applying any matching path prefix remappings, and then
|
/// Resolves paths applying any matching path prefix remappings, and then
|
||||||
/// joining the path to the workspace root.
|
/// joining the path to the workspace root.
|
||||||
fn resolve_path(config: &DiagnosticsMapConfig, workspace_root: &Path, file_name: &str) -> PathBuf {
|
fn resolve_path(config: &DiagnosticsMapConfig, workspace_root: &Path, file_name: &str) -> PathBuf {
|
||||||
match config.remap_path_prefixes.iter().find(|(from, _)| file_name.starts_with(*from)) {
|
match config
|
||||||
Some((from, to)) => {
|
.remap_prefix
|
||||||
workspace_root.join(format!("{}{}", to, file_name.strip_prefix(from).unwrap()))
|
.iter()
|
||||||
}
|
.find_map(|(from, to)| file_name.strip_prefix(from).map(|file_name| (to, file_name)))
|
||||||
|
{
|
||||||
|
Some((to, file_name)) => workspace_root.join(format!("{}{}", to, file_name)),
|
||||||
None => workspace_root.join(file_name),
|
None => workspace_root.join(file_name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,10 +147,10 @@ have more false positives than usual.
|
||||||
--
|
--
|
||||||
List of rust-analyzer diagnostics to disable.
|
List of rust-analyzer diagnostics to disable.
|
||||||
--
|
--
|
||||||
[[rust-analyzer.diagnostics.remapPathPrefixes]]rust-analyzer.diagnostics.remapPathPrefixes (default: `{}`)::
|
[[rust-analyzer.diagnostics.remapPrefix]]rust-analyzer.diagnostics.remapPrefix (default: `{}`)::
|
||||||
+
|
+
|
||||||
--
|
--
|
||||||
Map of path prefixes to be substituted when parsing diagnostic file paths.
|
Map of prefixes to be substituted when parsing diagnostic file paths.
|
||||||
This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`.
|
This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`.
|
||||||
--
|
--
|
||||||
[[rust-analyzer.diagnostics.warningsAsHint]]rust-analyzer.diagnostics.warningsAsHint (default: `[]`)::
|
[[rust-analyzer.diagnostics.warningsAsHint]]rust-analyzer.diagnostics.warningsAsHint (default: `[]`)::
|
||||||
|
|
|
@ -565,8 +565,8 @@
|
||||||
},
|
},
|
||||||
"uniqueItems": true
|
"uniqueItems": true
|
||||||
},
|
},
|
||||||
"rust-analyzer.diagnostics.remapPathPrefixes": {
|
"rust-analyzer.diagnostics.remapPrefix": {
|
||||||
"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`.",
|
"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`.",
|
||||||
"default": {},
|
"default": {},
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue