File tree Expand file tree Collapse file tree 4 files changed +7
-43
lines changed Expand file tree Collapse file tree 4 files changed +7
-43
lines changed Original file line number Diff line number Diff line change 11use std:: { env, path:: PathBuf } ;
22
3- use rustc_version:: Channel ;
4-
53use crate :: Target ;
64use crate :: cargo:: Subcommand ;
75use crate :: errors:: Result ;
8- use crate :: rustc:: { ChannelExt , TargetList } ;
6+ use crate :: rustc:: TargetList ;
97
108#[ derive( Debug ) ]
119pub struct Args {
1210 pub all : Vec < String > ,
1311 pub subcommand : Option < Subcommand > ,
14- pub channel : Option < Channel > ,
12+ pub channel : Option < String > ,
1513 pub target : Option < Target > ,
1614 pub target_dir : Option < PathBuf > ,
1715}
@@ -26,8 +24,8 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
2624 {
2725 let mut args = env:: args ( ) . skip ( 1 ) ;
2826 while let Some ( arg) = args. next ( ) {
29- if arg . starts_with ( "+" ) {
30- channel = Some ( Channel :: from_str ( & arg [ 1 .. ] ) ? ) ;
27+ if let ( "+" , ch ) = arg . split_at ( 1 ) {
28+ channel = Some ( ch . to_string ( ) ) ;
3129 } else if arg == "--target" {
3230 all. push ( arg) ;
3331 if let Some ( t) = args. next ( ) {
Original file line number Diff line number Diff line change @@ -7,11 +7,4 @@ error_chain! {
77 Io ( std:: io:: Error ) ;
88 Which ( which:: Error ) ;
99 }
10-
11- errors {
12- InvalidChannelName ( channel: String ) {
13- description( "invalid channel name" )
14- display( "invalid channel name: '{}'" , channel)
15- }
16- }
1710}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ use toml::{Value, value::Table};
2020
2121use self :: cargo:: { Root , Subcommand } ;
2222use self :: errors:: * ;
23- use self :: rustc:: { ChannelExt , TargetList , VersionMetaExt } ;
23+ use self :: rustc:: { TargetList , VersionMetaExt } ;
2424
2525#[ allow( non_camel_case_types) ]
2626#[ derive( Debug , Clone , PartialEq ) ]
@@ -232,7 +232,7 @@ fn run() -> Result<ExitStatus> {
232232 let default_toolchain = sysroot. file_name ( ) . and_then ( |file_name| file_name. to_str ( ) )
233233 . ok_or ( "couldn't get toolchain name" ) ?;
234234 let toolchain = if let Some ( channel) = args. channel {
235- [ channel. to_string ( ) ] . iter ( ) . map ( |c| c. as_str ( ) ) . chain (
235+ [ channel] . iter ( ) . map ( |c| c. as_str ( ) ) . chain (
236236 default_toolchain. splitn ( 2 , '-' ) . skip ( 1 )
237237 )
238238 . collect :: < Vec < _ > > ( )
Original file line number Diff line number Diff line change 11use std:: path:: PathBuf ;
22use std:: process:: Command ;
33
4- use rustc_version:: { Channel , Version , VersionMeta } ;
4+ use rustc_version:: { Version , VersionMeta } ;
55
66use crate :: { Host , Target } ;
77use crate :: errors:: * ;
@@ -38,33 +38,6 @@ impl VersionMetaExt for VersionMeta {
3838 }
3939}
4040
41- pub ( crate ) trait ChannelExt {
42- fn from_str ( chan : & str ) -> Result < Channel > ;
43- fn to_string ( & self ) -> String ;
44- }
45-
46- impl ChannelExt for Channel {
47- fn from_str ( chan : & str ) -> Result < Channel > {
48- Ok ( match chan {
49- "stable" => Channel :: Stable ,
50- "nightly" => Channel :: Nightly ,
51- "dev" => Channel :: Dev ,
52- "beta" => Channel :: Beta ,
53- _ => return Err (
54- ErrorKind :: InvalidChannelName ( chan. to_string ( ) ) . into ( )
55- ) ,
56- } )
57- }
58- fn to_string ( & self ) -> String {
59- match self {
60- Channel :: Stable => "stable" ,
61- Channel :: Nightly => "nightly" ,
62- Channel :: Dev => "dev" ,
63- Channel :: Beta => "beta" ,
64- } . to_string ( )
65- }
66- }
67-
6841pub fn target_list ( verbose : bool ) -> Result < TargetList > {
6942 Command :: new ( "rustc" )
7043 . args ( & [ "--print" , "target-list" ] )
You can’t perform that action at this time.
0 commit comments