@@ -96,40 +96,6 @@ export class Cargo {
9696 return artifacts [ 0 ] . fileName ;
9797 }
9898
99- async crates ( ) : Promise < Crate [ ] > {
100- const pathToCargo = await cargoPath ( ) ;
101- return await new Promise ( ( resolve , reject ) => {
102- const crates : Crate [ ] = [ ] ;
103-
104- const cargo = cp . spawn ( pathToCargo , [ "tree" , "--prefix" , "none" ] , {
105- stdio : [ "ignore" , "pipe" , "pipe" ] ,
106- cwd : this . rootFolder ,
107- } ) ;
108- const rl = readline . createInterface ( { input : cargo . stdout } ) ;
109- rl . on ( "line" , ( line ) => {
110- const match = line . match ( TREE_LINE_PATTERN ) ;
111- if ( match ) {
112- const name = match [ 1 ] ;
113- const version = match [ 2 ] ;
114- const extraInfo = match [ 3 ] ;
115- // ignore duplicates '(*)' and path dependencies
116- if ( this . shouldIgnore ( extraInfo ) ) {
117- return ;
118- }
119- crates . push ( { name, version } ) ;
120- }
121- } ) ;
122- cargo . on ( "exit" , ( exitCode , _ ) => {
123- if ( exitCode === 0 ) resolve ( crates ) ;
124- else reject ( new Error ( `exit code: ${ exitCode } .` ) ) ;
125- } ) ;
126- } ) ;
127- }
128-
129- private shouldIgnore ( extraInfo : string ) : boolean {
130- return extraInfo !== undefined && ( extraInfo === "*" || path . isAbsolute ( extraInfo ) ) ;
131- }
132-
13399 private async runCargo (
134100 cargoArgs : string [ ] ,
135101 onStdoutJson : ( obj : any ) => void ,
@@ -161,29 +127,6 @@ export class Cargo {
161127 }
162128}
163129
164- export async function activeToolchain ( ) : Promise < string > {
165- const pathToRustup = await rustupPath ( ) ;
166- return await new Promise ( ( resolve , reject ) => {
167- const execution = cp . spawn ( pathToRustup , [ "show" , "active-toolchain" ] , {
168- stdio : [ "ignore" , "pipe" , "pipe" ] ,
169- cwd : os . homedir ( ) ,
170- } ) ;
171- const rl = readline . createInterface ( { input : execution . stdout } ) ;
172-
173- let currToolchain : string | undefined = undefined ;
174- rl . on ( "line" , ( line ) => {
175- const match = line . match ( TOOLCHAIN_PATTERN ) ;
176- if ( match ) {
177- currToolchain = match [ 1 ] ;
178- }
179- } ) ;
180- execution . on ( "exit" , ( exitCode , _ ) => {
181- if ( exitCode === 0 && currToolchain ) resolve ( currToolchain ) ;
182- else reject ( new Error ( `exit code: ${ exitCode } .` ) ) ;
183- } ) ;
184- } ) ;
185- }
186-
187130/** Mirrors `project_model::sysroot::discover_sysroot_dir()` implementation*/
188131export async function getSysroot ( dir : string ) : Promise < string > {
189132 const rustcPath = await getPathForExecutable ( "rustc" ) ;
@@ -202,16 +145,6 @@ export async function getRustcId(dir: string): Promise<string> {
202145 return rx . exec ( data ) ! [ 1 ] ;
203146}
204147
205- export async function getRustcVersion ( dir : string ) : Promise < string > {
206- const rustcPath = await getPathForExecutable ( "rustc" ) ;
207-
208- // do not memoize the result because the toolchain may change between runs
209- const data = await execute ( `${ rustcPath } -V` , { cwd : dir } ) ;
210- const rx = / ( \d \. \d + \. \d + ) / ;
211-
212- return rx . exec ( data ) ! [ 1 ] ;
213- }
214-
215148/** Mirrors `toolchain::cargo()` implementation */
216149export function cargoPath ( ) : Promise < string > {
217150 return getPathForExecutable ( "cargo" ) ;
@@ -278,4 +211,4 @@ async function isFileAtUri(uri: vscode.Uri): Promise<boolean> {
278211 } catch {
279212 return false ;
280213 }
281- }
214+ }
0 commit comments