@@ -14,6 +14,7 @@ use crate::dist::manifestation::{Changes, Manifestation, UpdateStatus};
1414use crate :: dist:: notifications:: * ;
1515use crate :: dist:: prefix:: InstallPrefix ;
1616use crate :: dist:: temp;
17+ pub use crate :: dist:: triple:: * ;
1718use crate :: errors:: * ;
1819use crate :: process;
1920use crate :: utils:: utils;
@@ -52,13 +53,6 @@ pub struct PartialToolchainDesc {
5253 pub target : PartialTargetTriple ,
5354}
5455
55- #[ derive( Debug , Clone , PartialEq ) ]
56- pub struct PartialTargetTriple {
57- pub arch : Option < String > ,
58- pub os : Option < String > ,
59- pub env : Option < String > ,
60- }
61-
6256// Fully-resolved toolchain descriptors. These always have full target
6357// triples attached to them and are used for canonical identification,
6458// such as naming their installation directory.
@@ -73,50 +67,6 @@ pub struct ToolchainDesc {
7367#[ derive( Debug , Clone , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
7468pub struct TargetTriple ( String ) ;
7569
76- // These lists contain the targets known to rustup, and used to build
77- // the PartialTargetTriple.
78-
79- static LIST_ARCHS : & [ & str ] = & [
80- "i386" ,
81- "i586" ,
82- "i686" ,
83- "x86_64" ,
84- "arm" ,
85- "armv7" ,
86- "armv7s" ,
87- "aarch64" ,
88- "mips" ,
89- "mipsel" ,
90- "mips64" ,
91- "mips64el" ,
92- "powerpc" ,
93- "powerpc64" ,
94- "powerpc64le" ,
95- "riscv64gc" ,
96- "s390x" ,
97- ] ;
98- static LIST_OSES : & [ & str ] = & [
99- "pc-windows" ,
100- "unknown-linux" ,
101- "apple-darwin" ,
102- "unknown-netbsd" ,
103- "apple-ios" ,
104- "linux" ,
105- "rumprun-netbsd" ,
106- "unknown-freebsd" ,
107- "unknown-illumos" ,
108- ] ;
109- static LIST_ENVS : & [ & str ] = & [
110- "gnu" ,
111- "msvc" ,
112- "gnueabi" ,
113- "gnueabihf" ,
114- "gnuabi64" ,
115- "androideabi" ,
116- "android" ,
117- "musl" ,
118- ] ;
119-
12070// Linux hosts don't indicate clib in uname, however binaries only
12171// run on boxes with the same clib, as expected.
12272#[ cfg( all( not( windows) , not( target_env = "musl" ) ) ) ]
@@ -303,47 +253,6 @@ impl std::convert::TryFrom<PartialTargetTriple> for TargetTriple {
303253 }
304254}
305255
306- impl PartialTargetTriple {
307- pub fn new ( name : & str ) -> Option < Self > {
308- if name. is_empty ( ) {
309- return Some ( Self {
310- arch : None ,
311- os : None ,
312- env : None ,
313- } ) ;
314- }
315-
316- // Prepending `-` makes this next regex easier since
317- // we can count on all triple components being
318- // delineated by it.
319- let name = format ! ( "-{}" , name) ;
320- lazy_static ! {
321- static ref PATTERN : String = format!(
322- r"^(?:-({}))?(?:-({}))?(?:-({}))?$" ,
323- LIST_ARCHS . join( "|" ) ,
324- LIST_OSES . join( "|" ) ,
325- LIST_ENVS . join( "|" )
326- ) ;
327- static ref RE : Regex = Regex :: new( & PATTERN ) . unwrap( ) ;
328- }
329- RE . captures ( & name) . map ( |c| {
330- fn fn_map ( s : & str ) -> Option < String > {
331- if s == "" {
332- None
333- } else {
334- Some ( s. to_owned ( ) )
335- }
336- }
337-
338- Self {
339- arch : c. get ( 1 ) . map ( |s| s. as_str ( ) ) . and_then ( fn_map) ,
340- os : c. get ( 2 ) . map ( |s| s. as_str ( ) ) . and_then ( fn_map) ,
341- env : c. get ( 3 ) . map ( |s| s. as_str ( ) ) . and_then ( fn_map) ,
342- }
343- } )
344- }
345- }
346-
347256impl FromStr for PartialToolchainDesc {
348257 type Err = Error ;
349258 fn from_str ( name : & str ) -> Result < Self > {
@@ -1033,69 +942,6 @@ mod tests {
1033942 }
1034943 }
1035944
1036- #[ test]
1037- fn test_partial_target_triple_new ( ) {
1038- let success_cases = vec ! [
1039- ( "" , ( None , None , None ) ) ,
1040- ( "i386" , ( Some ( "i386" ) , None , None ) ) ,
1041- ( "pc-windows" , ( None , Some ( "pc-windows" ) , None ) ) ,
1042- ( "gnu" , ( None , None , Some ( "gnu" ) ) ) ,
1043- ( "i386-gnu" , ( Some ( "i386" ) , None , Some ( "gnu" ) ) ) ,
1044- ( "pc-windows-gnu" , ( None , Some ( "pc-windows" ) , Some ( "gnu" ) ) ) ,
1045- ( "i386-pc-windows" , ( Some ( "i386" ) , Some ( "pc-windows" ) , None ) ) ,
1046- (
1047- "i386-pc-windows-gnu" ,
1048- ( Some ( "i386" ) , Some ( "pc-windows" ) , Some ( "gnu" ) ) ,
1049- ) ,
1050- ] ;
1051-
1052- for ( input, ( arch, os, env) ) in success_cases {
1053- let partial_target_triple = PartialTargetTriple :: new ( input) ;
1054- assert ! (
1055- partial_target_triple. is_some( ) ,
1056- "expected `{}` to create some partial target triple; got None" ,
1057- input
1058- ) ;
1059-
1060- let expected = PartialTargetTriple {
1061- arch : arch. map ( String :: from) ,
1062- os : os. map ( String :: from) ,
1063- env : env. map ( String :: from) ,
1064- } ;
1065-
1066- assert_eq ! (
1067- partial_target_triple. unwrap( ) ,
1068- expected,
1069- "input: `{}`" ,
1070- input
1071- ) ;
1072- }
1073-
1074- let failure_cases = vec ! [
1075- "anything" ,
1076- "any-other-thing" ,
1077- "-" ,
1078- "--" ,
1079- "i386-" ,
1080- "i386-pc-" ,
1081- "i386-pc-windows-" ,
1082- "-pc-windows" ,
1083- "i386-pc-windows-anything" ,
1084- "0000-00-00-" ,
1085- "00000-000-000" ,
1086- ] ;
1087-
1088- for input in failure_cases {
1089- let partial_target_triple = PartialTargetTriple :: new ( input) ;
1090- assert ! (
1091- partial_target_triple. is_none( ) ,
1092- "expected `{}` to be `None`, was: `{:?}`" ,
1093- input,
1094- partial_target_triple
1095- ) ;
1096- }
1097- }
1098-
1099945 #[ test]
1100946 fn test_tracking_channels ( ) {
1101947 static CASES : & [ ( & str , bool ) ] = & [
0 commit comments