This repository was archived by the owner on Dec 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export class Rustup {
36
36
/**
37
37
* Components received by invoking rustup
38
38
*/
39
- private components : { [ toolchain : string ] : string [ ] } ;
39
+ private components : { [ toolchain : string ] : string [ ] | undefined } ;
40
40
41
41
/**
42
42
* Toolchains received by invoking rustup
@@ -321,6 +321,10 @@ export class Rustup {
321
321
return false ;
322
322
}
323
323
const components = this . components [ nightlyToolchain . toString ( true , false ) ] ;
324
+ if ( ! components ) {
325
+ logger . error ( 'no components' ) ;
326
+ return false ;
327
+ }
324
328
const rlsComponent = components . find ( component => component . startsWith ( Rustup . getRlsComponentName ( ) ) ) ;
325
329
if ( ! rlsComponent ) {
326
330
return false ;
@@ -373,6 +377,10 @@ export class Rustup {
373
377
return false ;
374
378
}
375
379
const components = this . components [ nightlyToolchain . toString ( true , false ) ] ;
380
+ if ( ! components ) {
381
+ logger . error ( 'no components' ) ;
382
+ return false ;
383
+ }
376
384
const component : string | undefined = components . find ( c => c . startsWith ( Rustup . getRustAnalysisComponentName ( ) ) ) ;
377
385
if ( ! component ) {
378
386
return false ;
@@ -517,6 +525,9 @@ export class Rustup {
517
525
private getInstalledComponents ( toolchain : Toolchain ) : string [ ] {
518
526
const toolchainAsString = toolchain . toString ( true , false ) ;
519
527
const components = this . components [ toolchainAsString ] ;
528
+ if ( ! components ) {
529
+ return [ ] ;
530
+ }
520
531
const installedComponents = components . filter ( component => {
521
532
return component . endsWith ( Rustup . getSuffixForInstalledComponent ( ) ) ;
522
533
} ) ;
Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ async function askPermissionToInstall(what: string): Promise<boolean> {
66
66
*/
67
67
async function handleMissingNightlyToolchain ( logger : ChildLogger , rustup : Rustup ) : Promise < boolean > {
68
68
const functionLogger = logger . createChildLogger ( 'handleMissingNightlyToolchain: ' ) ;
69
- await window . showInformationMessage ( 'The nightly toolchain is not installed, but is required to install RLS' ) ;
70
69
const permissionGranted = await askPermissionToInstall ( 'the nightly toolchain' ) ;
71
70
functionLogger . debug ( `permissionGranted=${ permissionGranted } ` ) ;
72
71
if ( ! permissionGranted ) {
@@ -78,7 +77,12 @@ async function handleMissingNightlyToolchain(logger: ChildLogger, rustup: Rustup
78
77
if ( ! toolchainInstalled ) {
79
78
return false ;
80
79
}
81
- await rustup . updateComponents ( < Toolchain > Toolchain . parse ( 'nightly' ) ) ;
80
+ const nightlyToolchain = rustup . getNightlyToolchain ( functionLogger ) ;
81
+ if ( ! nightlyToolchain ) {
82
+ functionLogger . error ( 'the nightly toolchain has not been installed' ) ;
83
+ return false ;
84
+ }
85
+ await rustup . updateComponents ( nightlyToolchain ) ;
82
86
return true ;
83
87
}
84
88
You can’t perform that action at this time.
0 commit comments