File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use glob::glob;
2
2
use serde:: { Deserialize , Serialize } ;
3
3
use std:: env;
4
4
use std:: error:: Error ;
5
- use std:: path:: PathBuf ;
5
+ use std:: path:: { Path , PathBuf } ;
6
6
use std:: process:: Command ;
7
7
8
8
/// Contains the structure of resulting rust-project.json file
@@ -79,21 +79,24 @@ impl RustAnalyzerProject {
79
79
. output ( ) ?
80
80
. stdout ;
81
81
82
- let toolchain = String :: from_utf8_lossy ( & toolchain) ;
83
- let mut whitespace_iter = toolchain. split_whitespace ( ) ;
82
+ let toolchain = String :: from_utf8 ( toolchain) ? ;
83
+ let toolchain = toolchain. trim_end ( ) ;
84
84
85
- let toolchain = whitespace_iter . next ( ) . unwrap_or ( & toolchain) ;
85
+ println ! ( "Determined toolchain: { toolchain} \n " ) ;
86
86
87
- println ! ( "Determined toolchain: {}\n " , & toolchain) ;
88
-
89
- self . sysroot_src = ( std:: path:: Path :: new ( toolchain)
87
+ let Ok ( path) = Path :: new ( toolchain)
90
88
. join ( "lib" )
91
89
. join ( "rustlib" )
92
90
. join ( "src" )
93
91
. join ( "rust" )
94
92
. join ( "library" )
95
- . to_string_lossy ( ) )
96
- . to_string ( ) ;
93
+ . into_os_string ( )
94
+ . into_string ( )
95
+ else {
96
+ return Err ( "The sysroot path is invalid UTF8" . into ( ) ) ;
97
+ } ;
98
+ self . sysroot_src = path;
99
+
97
100
Ok ( ( ) )
98
101
}
99
102
}
You can’t perform that action at this time.
0 commit comments