File tree 5 files changed +10
-15
lines changed
src/tools/rust-analyzer/crates/rust-analyzer
5 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -794,19 +794,17 @@ impl Config {
794
794
/// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config |
795
795
/// | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
796
796
/// | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
797
- pub fn user_config_path ( ) -> & ' static AbsPath {
798
- static USER_CONFIG_PATH : LazyLock < AbsPathBuf > = LazyLock :: new ( || {
797
+ pub fn user_config_path ( ) -> Option < & ' static AbsPath > {
798
+ static USER_CONFIG_PATH : LazyLock < Option < AbsPathBuf > > = LazyLock :: new ( || {
799
799
let user_config_path = if let Some ( path) = env:: var_os ( "__TEST_RA_USER_CONFIG_DIR" ) {
800
800
std:: path:: PathBuf :: from ( path)
801
801
} else {
802
- dirs:: config_dir ( )
803
- . expect ( "A config dir is expected to existed on all platforms ra supports." )
804
- . join ( "rust-analyzer" )
802
+ dirs:: config_dir ( ) ?. join ( "rust-analyzer" )
805
803
}
806
804
. join ( "rust-analyzer.toml" ) ;
807
- AbsPathBuf :: assert_utf8 ( user_config_path)
805
+ Some ( AbsPathBuf :: assert_utf8 ( user_config_path) )
808
806
} ) ;
809
- & USER_CONFIG_PATH
807
+ USER_CONFIG_PATH . as_deref ( )
810
808
}
811
809
812
810
pub fn same_source_root_parent_map (
Original file line number Diff line number Diff line change @@ -399,7 +399,7 @@ impl GlobalState {
399
399
. collect_vec ( ) ;
400
400
401
401
for ( file_id, ( _change_kind, vfs_path) ) in modified_ratoml_files {
402
- if vfs_path == * user_config_path {
402
+ if vfs_path. as_path ( ) == user_config_path {
403
403
change. change_user_config ( Some ( db. file_text ( file_id) ) ) ;
404
404
continue ;
405
405
}
Original file line number Diff line number Diff line change @@ -551,11 +551,8 @@ impl GlobalState {
551
551
552
552
watchers. extend (
553
553
iter:: once ( Config :: user_config_path ( ) )
554
- . chain (
555
- self . workspaces
556
- . iter ( )
557
- . filter_map ( |ws| ws. manifest ( ) . map ( ManifestPath :: as_ref) ) ,
558
- )
554
+ . chain ( self . workspaces . iter ( ) . map ( |ws| ws. manifest ( ) . map ( ManifestPath :: as_ref) ) )
555
+ . flatten ( )
559
556
. map ( |glob_pattern| lsp_types:: FileSystemWatcher {
560
557
glob_pattern : lsp_types:: GlobPattern :: String ( glob_pattern. to_string ( ) ) ,
561
558
kind : None ,
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ impl RatomlTest {
77
77
let mut spl = spl. into_iter ( ) ;
78
78
if let Some ( first) = spl. next ( ) {
79
79
if first == "$$CONFIG_DIR$$" {
80
- path = Config :: user_config_path ( ) . to_path_buf ( ) . into ( ) ;
80
+ path = Config :: user_config_path ( ) . unwrap ( ) . to_path_buf ( ) . into ( ) ;
81
81
} else {
82
82
path = path. join ( first) ;
83
83
}
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ impl Project<'_> {
123
123
if config_dir_guard. is_none ( ) {
124
124
config_dir_guard = Some ( CONFIG_DIR_LOCK . lock ( ) ) ;
125
125
}
126
- let path = Config :: user_config_path ( ) . join ( & pth[ '/' . len_utf8 ( ) ..] ) ;
126
+ let path = Config :: user_config_path ( ) . unwrap ( ) . join ( & pth[ '/' . len_utf8 ( ) ..] ) ;
127
127
fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) . unwrap ( ) ;
128
128
fs:: write ( path. as_path ( ) , entry. text . as_bytes ( ) ) . unwrap ( ) ;
129
129
} else {
You can’t perform that action at this time.
0 commit comments