Skip to content

Commit a76df5b

Browse files
committed
[rust] Update strategy for the default active target
Due to some updates in the Installation Profiles PR in Rustup (rust-lang/rustup#1673), as of Rustup 1.20.0, there is no longer a ` (default)` ending indicator on the active target when calling `rustup target list`. Looking at the update, it's not totally clear that this was ever completely accurate so another strategy was in order. This change, uses the knowledge of the current active toolchain (via `rustup show active-toolchain`) to list all installed components for that toolchain. The `rustc` component should be installed in an active toolchain (although this is honestly a stated assumption which could be invalidated), so if we strip off `rustc-` from the start of the component name, we should be left with the full target triple of the active toolchain, hence the "default active target". Signed-off-by: Fletcher Nichol <[email protected]>
1 parent 921fab5 commit a76df5b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

home/.vim/autoload/rust/detect.vim

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
function! s:default_target() abort
2-
return get(split(get(filter(systemlist(
3-
\ 'rustup target list'), 'v:val =~? " (default)$"'), 0, ''), '\s\+'),
4-
\ 0, '')
2+
let l:active = rust#detect#RlsActiveToolchain()
3+
4+
" Use the current active toolchain to get a list of installed components, of
5+
" which `rustc` should be installed. Knowing this, we'll strip off `rustc-`
6+
" and what we're left with should be the full target triple of the active
7+
" toolchain.
8+
return substitute(get(filter(systemlist(
9+
\ 'rustup component list --installed --toolchain '. l:active),
10+
\ 'v:val =~? "^rustc-"'), 0, ''), 'rustc-', '', '')
511
endfunction
612

713
function! s:component_installed(toolchain, fq_component) abort

0 commit comments

Comments
 (0)