@@ -459,7 +459,7 @@ impl fmt::Display for LinkOutputKind {
459
459
}
460
460
}
461
461
462
- pub type LinkArgs = BTreeMap < LinkerFlavor , Vec < Cow < ' static , str > > > ;
462
+ pub type LinkArgs = BTreeMap < LinkerFlavor , Vec < StaticCow < str > > > ;
463
463
464
464
#[ derive( Clone , Copy , Hash , Debug , PartialEq , Eq ) ]
465
465
pub enum SplitDebuginfo {
@@ -1028,19 +1028,16 @@ supported_targets! {
1028
1028
}
1029
1029
1030
1030
/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
1031
- // FIXME(Urgau): Figure out why the obvious form `["".into()].into()` doesn't work.
1032
1031
macro_rules! cvs {
1033
1032
( ) => {
1034
1033
:: std:: borrow:: Cow :: Borrowed ( & [ ] )
1035
1034
} ;
1036
1035
( $( $x: expr) ,+ $( , ) ?) => {
1037
- {
1038
- :: std:: borrow:: Cow :: Borrowed ( & [
1039
- $(
1040
- :: std:: borrow:: Cow :: Borrowed ( $x) ,
1041
- ) *
1042
- ] )
1043
- }
1036
+ :: std:: borrow:: Cow :: Borrowed ( & [
1037
+ $(
1038
+ :: std:: borrow:: Cow :: Borrowed ( $x) ,
1039
+ ) *
1040
+ ] )
1044
1041
} ;
1045
1042
}
1046
1043
@@ -1084,14 +1081,14 @@ impl TargetWarnings {
1084
1081
#[ derive( PartialEq , Clone , Debug ) ]
1085
1082
pub struct Target {
1086
1083
/// Target triple to pass to LLVM.
1087
- pub llvm_target : Cow < ' static , str > ,
1084
+ pub llvm_target : StaticCow < str > ,
1088
1085
/// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable.
1089
1086
pub pointer_width : u32 ,
1090
1087
/// Architecture to use for ABI considerations. Valid options include: "x86",
1091
1088
/// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others.
1092
- pub arch : Cow < ' static , str > ,
1089
+ pub arch : StaticCow < str > ,
1093
1090
/// [Data layout](https://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM.
1094
- pub data_layout : Cow < ' static , str > ,
1091
+ pub data_layout : StaticCow < str > ,
1095
1092
/// Optional settings with defaults.
1096
1093
pub options : TargetOptions ,
1097
1094
}
@@ -1107,6 +1104,8 @@ impl HasTargetSpec for Target {
1107
1104
}
1108
1105
}
1109
1106
1107
+ type StaticCow < T > = Cow < ' static , T > ;
1108
+
1110
1109
/// Optional aspects of a target specification.
1111
1110
///
1112
1111
/// This has an implementation of `Default`, see each field for what the default is. In general,
@@ -1123,25 +1122,25 @@ pub struct TargetOptions {
1123
1122
/// Used as the `target_endian` `cfg` variable. Defaults to little endian.
1124
1123
pub endian : Endian ,
1125
1124
/// Width of c_int type. Defaults to "32".
1126
- pub c_int_width : Cow < ' static , str > ,
1125
+ pub c_int_width : StaticCow < str > ,
1127
1126
/// OS name to use for conditional compilation (`target_os`). Defaults to "none".
1128
1127
/// "none" implies a bare metal target without `std` library.
1129
1128
/// A couple of targets having `std` also use "unknown" as an `os` value,
1130
1129
/// but they are exceptions.
1131
- pub os : Cow < ' static , str > ,
1130
+ pub os : StaticCow < str > ,
1132
1131
/// Environment name to use for conditional compilation (`target_env`). Defaults to "".
1133
- pub env : Cow < ' static , str > ,
1132
+ pub env : StaticCow < str > ,
1134
1133
/// ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, `"eabi"`
1135
1134
/// or `"eabihf"`. Defaults to "".
1136
- pub abi : Cow < ' static , str > ,
1135
+ pub abi : StaticCow < str > ,
1137
1136
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown".
1138
- pub vendor : Cow < ' static , str > ,
1137
+ pub vendor : StaticCow < str > ,
1139
1138
/// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed
1140
1139
/// on the command line. Defaults to `LinkerFlavor::Gcc`.
1141
1140
pub linker_flavor : LinkerFlavor ,
1142
1141
1143
1142
/// Linker to invoke
1144
- pub linker : Option < Cow < ' static , str > > ,
1143
+ pub linker : Option < StaticCow < str > > ,
1145
1144
1146
1145
/// LLD flavor used if `lld` (or `rust-lld`) is specified as a linker
1147
1146
/// without clarifying its flavor in any way.
@@ -1176,23 +1175,23 @@ pub struct TargetOptions {
1176
1175
/// Optional link script applied to `dylib` and `executable` crate types.
1177
1176
/// This is a string containing the script, not a path. Can only be applied
1178
1177
/// to linkers where `linker_is_gnu` is true.
1179
- pub link_script : Option < Cow < ' static , str > > ,
1178
+ pub link_script : Option < StaticCow < str > > ,
1180
1179
1181
1180
/// Environment variables to be set for the linker invocation.
1182
- pub link_env : Cow < ' static , [ ( Cow < ' static , str > , Cow < ' static , str > ) ] > ,
1181
+ pub link_env : StaticCow < [ ( StaticCow < str > , StaticCow < str > ) ] > ,
1183
1182
/// Environment variables to be removed for the linker invocation.
1184
- pub link_env_remove : Cow < ' static , [ Cow < ' static , str > ] > ,
1183
+ pub link_env_remove : StaticCow < [ StaticCow < str > ] > ,
1185
1184
1186
1185
/// Extra arguments to pass to the external assembler (when used)
1187
- pub asm_args : Cow < ' static , [ Cow < ' static , str > ] > ,
1186
+ pub asm_args : StaticCow < [ StaticCow < str > ] > ,
1188
1187
1189
1188
/// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults
1190
1189
/// to "generic".
1191
- pub cpu : Cow < ' static , str > ,
1190
+ pub cpu : StaticCow < str > ,
1192
1191
/// Default target features to pass to LLVM. These features will *always* be
1193
1192
/// passed, and cannot be disabled even via `-C`. Corresponds to `llc
1194
1193
/// -mattr=$features`.
1195
- pub features : Cow < ' static , str > ,
1194
+ pub features : StaticCow < str > ,
1196
1195
/// Whether dynamic linking is available on this target. Defaults to false.
1197
1196
pub dynamic_linking : bool ,
1198
1197
/// If dynamic linking is available, whether only cdylibs are supported.
@@ -1216,21 +1215,21 @@ pub struct TargetOptions {
1216
1215
/// Emit each function in its own section. Defaults to true.
1217
1216
pub function_sections : bool ,
1218
1217
/// String to prepend to the name of every dynamic library. Defaults to "lib".
1219
- pub dll_prefix : Cow < ' static , str > ,
1218
+ pub dll_prefix : StaticCow < str > ,
1220
1219
/// String to append to the name of every dynamic library. Defaults to ".so".
1221
- pub dll_suffix : Cow < ' static , str > ,
1220
+ pub dll_suffix : StaticCow < str > ,
1222
1221
/// String to append to the name of every executable.
1223
- pub exe_suffix : Cow < ' static , str > ,
1222
+ pub exe_suffix : StaticCow < str > ,
1224
1223
/// String to prepend to the name of every static library. Defaults to "lib".
1225
- pub staticlib_prefix : Cow < ' static , str > ,
1224
+ pub staticlib_prefix : StaticCow < str > ,
1226
1225
/// String to append to the name of every static library. Defaults to ".a".
1227
- pub staticlib_suffix : Cow < ' static , str > ,
1226
+ pub staticlib_suffix : StaticCow < str > ,
1228
1227
/// Values of the `target_family` cfg set for this target.
1229
1228
///
1230
1229
/// Common options are: "unix", "windows". Defaults to no families.
1231
1230
///
1232
1231
/// See <https://doc.rust-lang.org/reference/conditional-compilation.html#target_family>.
1233
- pub families : Cow < ' static , [ Cow < ' static , str > ] > ,
1232
+ pub families : StaticCow < [ StaticCow < str > ] > ,
1234
1233
/// Whether the target toolchain's ABI supports returning small structs as an integer.
1235
1234
pub abi_return_struct_as_int : bool ,
1236
1235
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
@@ -1302,7 +1301,7 @@ pub struct TargetOptions {
1302
1301
/// LLVM to assemble an archive or fall back to the system linker, and
1303
1302
/// currently only "gnu" is used to fall into LLVM. Unknown strings cause
1304
1303
/// the system linker to be used.
1305
- pub archive_format : Cow < ' static , str > ,
1304
+ pub archive_format : StaticCow < str > ,
1306
1305
/// Is asm!() allowed? Defaults to true.
1307
1306
pub allow_asm : bool ,
1308
1307
/// Whether the runtime startup code requires the `main` function be passed
@@ -1318,7 +1317,7 @@ pub struct TargetOptions {
1318
1317
/// Whether the target requires that emitted object code includes bitcode.
1319
1318
pub forces_embed_bitcode : bool ,
1320
1319
/// Content of the LLVM cmdline section associated with embedded bitcode.
1321
- pub bitcode_llvm_cmdline : Cow < ' static , str > ,
1320
+ pub bitcode_llvm_cmdline : StaticCow < str > ,
1322
1321
1323
1322
/// Don't use this field; instead use the `.min_atomic_width()` method.
1324
1323
pub min_atomic_width : Option < u64 > ,
@@ -1390,7 +1389,7 @@ pub struct TargetOptions {
1390
1389
1391
1390
/// If set, have the linker export exactly these symbols, instead of using
1392
1391
/// the usual logic to figure this out from the crate itself.
1393
- pub override_export_symbols : Option < Cow < ' static , [ Cow < ' static , str > ] > > ,
1392
+ pub override_export_symbols : Option < StaticCow < [ StaticCow < str > ] > > ,
1394
1393
1395
1394
/// Determines how or whether the MergeFunctions LLVM pass should run for
1396
1395
/// this target. Either "disabled", "trampolines", or "aliases".
@@ -1401,16 +1400,16 @@ pub struct TargetOptions {
1401
1400
pub merge_functions : MergeFunctions ,
1402
1401
1403
1402
/// Use platform dependent mcount function
1404
- pub mcount : Cow < ' static , str > ,
1403
+ pub mcount : StaticCow < str > ,
1405
1404
1406
1405
/// LLVM ABI name, corresponds to the '-mabi' parameter available in multilib C compilers
1407
- pub llvm_abiname : Cow < ' static , str > ,
1406
+ pub llvm_abiname : StaticCow < str > ,
1408
1407
1409
1408
/// Whether or not RelaxElfRelocation flag will be passed to the linker
1410
1409
pub relax_elf_relocations : bool ,
1411
1410
1412
1411
/// Additional arguments to pass to LLVM, similar to the `-C llvm-args` codegen option.
1413
- pub llvm_args : Cow < ' static , [ Cow < ' static , str > ] > ,
1412
+ pub llvm_args : StaticCow < [ StaticCow < str > ] > ,
1414
1413
1415
1414
/// Whether to use legacy .ctors initialization hooks rather than .init_array. Defaults
1416
1415
/// to false (uses .init_array).
@@ -1459,18 +1458,18 @@ impl Default for TargetOptions {
1459
1458
endian : Endian :: Little ,
1460
1459
c_int_width : "32" . into ( ) ,
1461
1460
os : "none" . into ( ) ,
1462
- env : Cow :: from ( "" ) ,
1463
- abi : Cow :: from ( "" ) ,
1461
+ env : "" . into ( ) ,
1462
+ abi : "" . into ( ) ,
1464
1463
vendor : "unknown" . into ( ) ,
1465
1464
linker_flavor : LinkerFlavor :: Gcc ,
1466
1465
linker : option_env ! ( "CFG_DEFAULT_LINKER" ) . map ( |s| s. into ( ) ) ,
1467
1466
lld_flavor : LldFlavor :: Ld ,
1468
1467
pre_link_args : LinkArgs :: new ( ) ,
1469
1468
post_link_args : LinkArgs :: new ( ) ,
1470
1469
link_script : None ,
1471
- asm_args : Cow :: Borrowed ( & [ ] ) ,
1470
+ asm_args : cvs ! [ ] ,
1472
1471
cpu : "generic" . into ( ) ,
1473
- features : Cow :: from ( "" ) ,
1472
+ features : "" . into ( ) ,
1474
1473
dynamic_linking : false ,
1475
1474
only_cdylib : false ,
1476
1475
executables : false ,
@@ -1482,7 +1481,7 @@ impl Default for TargetOptions {
1482
1481
function_sections : true ,
1483
1482
dll_prefix : "lib" . into ( ) ,
1484
1483
dll_suffix : ".so" . into ( ) ,
1485
- exe_suffix : Cow :: from ( "" ) ,
1484
+ exe_suffix : "" . into ( ) ,
1486
1485
staticlib_prefix : "lib" . into ( ) ,
1487
1486
staticlib_suffix : ".a" . into ( ) ,
1488
1487
families : cvs ! [ ] ,
@@ -1511,15 +1510,15 @@ impl Default for TargetOptions {
1511
1510
late_link_args : LinkArgs :: new ( ) ,
1512
1511
late_link_args_dynamic : LinkArgs :: new ( ) ,
1513
1512
late_link_args_static : LinkArgs :: new ( ) ,
1514
- link_env : Cow :: Borrowed ( & [ ] ) ,
1515
- link_env_remove : Cow :: Borrowed ( & [ ] ) ,
1513
+ link_env : cvs ! [ ] ,
1514
+ link_env_remove : cvs ! [ ] ,
1516
1515
archive_format : "gnu" . into ( ) ,
1517
1516
main_needs_argc_argv : true ,
1518
1517
allow_asm : true ,
1519
1518
has_thread_local : false ,
1520
1519
obj_is_bitcode : false ,
1521
1520
forces_embed_bitcode : false ,
1522
- bitcode_llvm_cmdline : Cow :: from ( "" ) ,
1521
+ bitcode_llvm_cmdline : "" . into ( ) ,
1523
1522
min_atomic_width : None ,
1524
1523
max_atomic_width : None ,
1525
1524
atomic_cas : true ,
0 commit comments