Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/rust-analyzer/src/config.rs12
-rw-r--r--crates/rust-analyzer/src/global_state.rs2
-rw-r--r--crates/rust-analyzer/src/reload.rs7
-rw-r--r--crates/rust-analyzer/tests/slow-tests/ratoml.rs2
-rw-r--r--crates/rust-analyzer/tests/slow-tests/support.rs2
5 files changed, 10 insertions, 15 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 02a513f44b..36907c468b 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -794,19 +794,17 @@ impl Config {
/// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config |
/// | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
/// | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
- pub fn user_config_path() -> &'static AbsPath {
- static USER_CONFIG_PATH: LazyLock<AbsPathBuf> = LazyLock::new(|| {
+ pub fn user_config_path() -> Option<&'static AbsPath> {
+ static USER_CONFIG_PATH: LazyLock<Option<AbsPathBuf>> = LazyLock::new(|| {
let user_config_path = if let Some(path) = env::var_os("__TEST_RA_USER_CONFIG_DIR") {
std::path::PathBuf::from(path)
} else {
- dirs::config_dir()
- .expect("A config dir is expected to existed on all platforms ra supports.")
- .join("rust-analyzer")
+ dirs::config_dir()?.join("rust-analyzer")
}
.join("rust-analyzer.toml");
- AbsPathBuf::assert_utf8(user_config_path)
+ Some(AbsPathBuf::assert_utf8(user_config_path))
});
- &USER_CONFIG_PATH
+ USER_CONFIG_PATH.as_deref()
}
pub fn same_source_root_parent_map(
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index 1e21249c12..8fcdfa5829 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -399,7 +399,7 @@ impl GlobalState {
.collect_vec();
for (file_id, (_change_kind, vfs_path)) in modified_ratoml_files {
- if vfs_path == *user_config_path {
+ if vfs_path.as_path() == user_config_path {
change.change_user_config(Some(db.file_text(file_id)));
continue;
}
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 5b58b332df..2b9bcf12a4 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -551,11 +551,8 @@ impl GlobalState {
watchers.extend(
iter::once(Config::user_config_path())
- .chain(
- self.workspaces
- .iter()
- .filter_map(|ws| ws.manifest().map(ManifestPath::as_ref)),
- )
+ .chain(self.workspaces.iter().map(|ws| ws.manifest().map(ManifestPath::as_ref)))
+ .flatten()
.map(|glob_pattern| lsp_types::FileSystemWatcher {
glob_pattern: lsp_types::GlobPattern::String(glob_pattern.to_string()),
kind: None,
diff --git a/crates/rust-analyzer/tests/slow-tests/ratoml.rs b/crates/rust-analyzer/tests/slow-tests/ratoml.rs
index 478840f104..f68b94fa66 100644
--- a/crates/rust-analyzer/tests/slow-tests/ratoml.rs
+++ b/crates/rust-analyzer/tests/slow-tests/ratoml.rs
@@ -77,7 +77,7 @@ impl RatomlTest {
let mut spl = spl.into_iter();
if let Some(first) = spl.next() {
if first == "$$CONFIG_DIR$$" {
- path = Config::user_config_path().to_path_buf().into();
+ path = Config::user_config_path().unwrap().to_path_buf().into();
} else {
path = path.join(first);
}
diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs
index 5bd27133c2..06ce984681 100644
--- a/crates/rust-analyzer/tests/slow-tests/support.rs
+++ b/crates/rust-analyzer/tests/slow-tests/support.rs
@@ -123,7 +123,7 @@ impl Project<'_> {
if config_dir_guard.is_none() {
config_dir_guard = Some(CONFIG_DIR_LOCK.lock());
}
- let path = Config::user_config_path().join(&pth['/'.len_utf8()..]);
+ let path = Config::user_config_path().unwrap().join(&pth['/'.len_utf8()..]);
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(path.as_path(), entry.text.as_bytes()).unwrap();
} else {