@@ -1027,6 +1027,25 @@ supported_targets! {
1027
1027
( "mips64-openwrt-linux-musl" , mips64_openwrt_linux_musl) ,
1028
1028
}
1029
1029
1030
+ /// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
1031
+ // FIXME(Urgau): Figure out why the obvious form `["".into()].into()` doesn't work.
1032
+ macro_rules! cvs {
1033
+ ( ) => {
1034
+ :: std:: borrow:: Cow :: Borrowed ( & [ ] )
1035
+ } ;
1036
+ ( $( $x: expr) ,+ $( , ) ?) => {
1037
+ {
1038
+ :: std:: borrow:: Cow :: Borrowed ( & [
1039
+ $(
1040
+ :: std:: borrow:: Cow :: Borrowed ( $x) ,
1041
+ ) *
1042
+ ] )
1043
+ }
1044
+ } ;
1045
+ }
1046
+
1047
+ pub ( crate ) use cvs;
1048
+
1030
1049
/// Warnings encountered when parsing the target `json`.
1031
1050
///
1032
1051
/// Includes fields that weren't recognized and fields that don't have the expected type.
@@ -1160,12 +1179,12 @@ pub struct TargetOptions {
1160
1179
pub link_script : Option < Cow < ' static , str > > ,
1161
1180
1162
1181
/// Environment variables to be set for the linker invocation.
1163
- pub link_env : Vec < ( Cow < ' static , str > , Cow < ' static , str > ) > ,
1182
+ pub link_env : Cow < ' static , [ ( Cow < ' static , str > , Cow < ' static , str > ) ] > ,
1164
1183
/// Environment variables to be removed for the linker invocation.
1165
- pub link_env_remove : Vec < Cow < ' static , str > > ,
1184
+ pub link_env_remove : Cow < ' static , [ Cow < ' static , str > ] > ,
1166
1185
1167
1186
/// Extra arguments to pass to the external assembler (when used)
1168
- pub asm_args : Vec < Cow < ' static , str > > ,
1187
+ pub asm_args : Cow < ' static , [ Cow < ' static , str > ] > ,
1169
1188
1170
1189
/// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults
1171
1190
/// to "generic".
@@ -1211,7 +1230,7 @@ pub struct TargetOptions {
1211
1230
/// Common options are: "unix", "windows". Defaults to no families.
1212
1231
///
1213
1232
/// See <https://doc.rust-lang.org/reference/conditional-compilation.html#target_family>.
1214
- pub families : Vec < Cow < ' static , str > > ,
1233
+ pub families : Cow < ' static , [ Cow < ' static , str > ] > ,
1215
1234
/// Whether the target toolchain's ABI supports returning small structs as an integer.
1216
1235
pub abi_return_struct_as_int : bool ,
1217
1236
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
@@ -1371,7 +1390,7 @@ pub struct TargetOptions {
1371
1390
1372
1391
/// If set, have the linker export exactly these symbols, instead of using
1373
1392
/// the usual logic to figure this out from the crate itself.
1374
- pub override_export_symbols : Option < Vec < Cow < ' static , str > > > ,
1393
+ pub override_export_symbols : Option < Cow < ' static , [ Cow < ' static , str > ] > > ,
1375
1394
1376
1395
/// Determines how or whether the MergeFunctions LLVM pass should run for
1377
1396
/// this target. Either "disabled", "trampolines", or "aliases".
@@ -1391,7 +1410,7 @@ pub struct TargetOptions {
1391
1410
pub relax_elf_relocations : bool ,
1392
1411
1393
1412
/// Additional arguments to pass to LLVM, similar to the `-C llvm-args` codegen option.
1394
- pub llvm_args : Vec < Cow < ' static , str > > ,
1413
+ pub llvm_args : Cow < ' static , [ Cow < ' static , str > ] > ,
1395
1414
1396
1415
/// Whether to use legacy .ctors initialization hooks rather than .init_array. Defaults
1397
1416
/// to false (uses .init_array).
@@ -1449,7 +1468,7 @@ impl Default for TargetOptions {
1449
1468
pre_link_args : LinkArgs :: new ( ) ,
1450
1469
post_link_args : LinkArgs :: new ( ) ,
1451
1470
link_script : None ,
1452
- asm_args : Vec :: new ( ) ,
1471
+ asm_args : Cow :: Borrowed ( & [ ] ) ,
1453
1472
cpu : "generic" . into ( ) ,
1454
1473
features : Cow :: from ( "" ) ,
1455
1474
dynamic_linking : false ,
@@ -1466,7 +1485,7 @@ impl Default for TargetOptions {
1466
1485
exe_suffix : Cow :: from ( "" ) ,
1467
1486
staticlib_prefix : "lib" . into ( ) ,
1468
1487
staticlib_suffix : ".a" . into ( ) ,
1469
- families : Vec :: new ( ) ,
1488
+ families : cvs ! [ ] ,
1470
1489
abi_return_struct_as_int : false ,
1471
1490
is_like_osx : false ,
1472
1491
is_like_solaris : false ,
@@ -1492,8 +1511,8 @@ impl Default for TargetOptions {
1492
1511
late_link_args : LinkArgs :: new ( ) ,
1493
1512
late_link_args_dynamic : LinkArgs :: new ( ) ,
1494
1513
late_link_args_static : LinkArgs :: new ( ) ,
1495
- link_env : Vec :: new ( ) ,
1496
- link_env_remove : Vec :: new ( ) ,
1514
+ link_env : Cow :: Borrowed ( & [ ] ) ,
1515
+ link_env_remove : Cow :: Borrowed ( & [ ] ) ,
1497
1516
archive_format : "gnu" . into ( ) ,
1498
1517
main_needs_argc_argv : true ,
1499
1518
allow_asm : true ,
@@ -1526,7 +1545,7 @@ impl Default for TargetOptions {
1526
1545
mcount : "mcount" . into ( ) ,
1527
1546
llvm_abiname : "" . into ( ) ,
1528
1547
relax_elf_relocations : false ,
1529
- llvm_args : vec ! [ ] ,
1548
+ llvm_args : cvs ! [ ] ,
1530
1549
use_ctors_section : false ,
1531
1550
eh_frame_header : true ,
1532
1551
has_thumb_interworking : false ,
@@ -1978,7 +1997,7 @@ impl Target {
1978
1997
if p. len( ) == 2 {
1979
1998
let k = p[ 0 ] . to_string( ) ;
1980
1999
let v = p[ 1 ] . to_string( ) ;
1981
- base. $key_name. push( ( k. into( ) , v. into( ) ) ) ;
2000
+ base. $key_name. to_mut ( ) . push( ( k. into( ) , v. into( ) ) ) ;
1982
2001
}
1983
2002
}
1984
2003
}
@@ -2004,7 +2023,7 @@ impl Target {
2004
2023
. map( |a| a. as_string( ) . unwrap( ) . to_string( ) . into( ) )
2005
2024
. collect( ) ;
2006
2025
} else if let Some ( v) = Json :: as_string( & value) {
2007
- base. $key_name = vec![ v. to_string( ) . into( ) ] ;
2026
+ base. $key_name = vec![ v. to_string( ) . into( ) ] . into ( ) ;
2008
2027
}
2009
2028
}
2010
2029
} ) ;
0 commit comments