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;
22use serde:: { Deserialize , Serialize } ;
33use std:: env;
44use std:: error:: Error ;
5- use std:: path:: PathBuf ;
5+ use std:: path:: { Path , PathBuf } ;
66use std:: process:: Command ;
77
88/// Contains the structure of resulting rust-project.json file
@@ -79,21 +79,24 @@ impl RustAnalyzerProject {
7979 . output ( ) ?
8080 . stdout ;
8181
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 ( ) ;
8484
85- let toolchain = whitespace_iter . next ( ) . unwrap_or ( & toolchain) ;
85+ println ! ( "Determined toolchain: { toolchain} \n " ) ;
8686
87- println ! ( "Determined toolchain: {}\n " , & toolchain) ;
88-
89- self . sysroot_src = ( std:: path:: Path :: new ( toolchain)
87+ let Ok ( path) = Path :: new ( toolchain)
9088 . join ( "lib" )
9189 . join ( "rustlib" )
9290 . join ( "src" )
9391 . join ( "rust" )
9492 . 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+
97100 Ok ( ( ) )
98101 }
99102}
You can’t perform that action at this time.
0 commit comments