1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
|
From a5a3db2d32ff1d359aef5ec586b91164570c1685 Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Tue, 5 Nov 2019 09:56:15 -0800
Subject: [PATCH 1/7] Support custom vendor strings.
Add support for custom vendors, as in "x86_64-gentoo-linux-musl".
Fixes #33.
---
src/targets.rs | 108 ++++++++++++++++++++++++++++++++++++++++++++++++-
src/triple.rs | 4 --
2 files changed, 106 insertions(+), 6 deletions(-)
diff --git a/src/targets.rs b/src/targets.rs
index 6ae570e..90b2736 100644
--- a/third_party/rust/target-lexicon-0.9.0/src/targets.rs
+++ b/third_party/rust/target-lexicon-0.9.0/src/targets.rs
@@ -1,6 +1,8 @@
// This file defines all the identifier enums and target-aware logic.
use crate::triple::{Endianness, PointerWidth, Triple};
+use alloc::boxed::Box;
+use alloc::string::String;
use core::fmt;
use core::str::FromStr;
@@ -292,7 +294,7 @@ impl Aarch64Architecture {
/// The "vendor" field, which in practice is little more than an arbitrary
/// modifier.
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Vendor {
Unknown,
@@ -306,6 +308,15 @@ pub enum Vendor {
Sun,
Uwp,
Wrs,
+
+ /// A custom vendor. "Custom" in this context means that the vendor is
+ /// not specifically recognized by upstream Autotools, LLVM, Rust, or other
+ /// relevant authorities on triple naming. It's useful for people building
+ /// and using locally patched toolchains.
+ ///
+ /// Outside of such patched environments, users of `target-lexicon` should
+ /// treat `Custom` the same as `Unknown` and ignore the string.
+ Custom(Box<String>),
}
/// The "operating system" field, which sometimes implies an environment, and
@@ -717,6 +728,7 @@ impl fmt::Display for Vendor {
Vendor::Sun => "sun",
Vendor::Uwp => "uwp",
Vendor::Wrs => "wrs",
+ Vendor::Custom(ref name) => name,
};
f.write_str(s)
}
@@ -738,7 +750,46 @@ impl FromStr for Vendor {
"sun" => Vendor::Sun,
"uwp" => Vendor::Uwp,
"wrs" => Vendor::Wrs,
- _ => return Err(()),
+ custom => {
+ use alloc::borrow::ToOwned;
+
+ // A custom vendor. Since triple syntax is so loosely defined,
+ // be as conservative as we can to avoid potential ambiguities.
+ // We err on the side of being too strict here, as we can
+ // always relax it if needed.
+
+ // Don't allow empty string names.
+ if custom.is_empty() {
+ return Err(());
+ }
+
+ // Don't allow any other recognized name as a custom vendor,
+ // since vendors can be omitted in some contexts.
+ if Architecture::from_str(custom).is_ok()
+ || OperatingSystem::from_str(custom).is_ok()
+ || Environment::from_str(custom).is_ok()
+ || BinaryFormat::from_str(custom).is_ok()
+ {
+ return Err(());
+ }
+
+ // Require the first character to be an ascii lowercase.
+ if !custom.chars().nth(0).unwrap().is_ascii_lowercase() {
+ return Err(());
+ }
+
+ // Restrict the set of characters permitted in a custom vendor.
+ if custom
+ .find(|c: char| {
+ !(c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_' || c == '.')
+ })
+ .is_some()
+ {
+ return Err(());
+ }
+
+ Vendor::Custom(Box::new(custom.to_owned()))
+ }
})
}
}
@@ -1120,4 +1171,57 @@ mod tests {
assert_eq!(t.environment, Environment::Eabihf);
assert_eq!(t.binary_format, BinaryFormat::Elf);
}
+
+ #[test]
+ fn custom_vendors() {
+ assert!(Triple::from_str("x86_64--linux").is_err());
+ assert!(Triple::from_str("x86_64-42-linux").is_err());
+ assert!(Triple::from_str("x86_64-__customvendor__-linux").is_err());
+ assert!(Triple::from_str("x86_64-^-linux").is_err());
+ assert!(Triple::from_str("x86_64- -linux").is_err());
+ assert!(Triple::from_str("x86_64-CustomVendor-linux").is_err());
+ assert!(Triple::from_str("x86_64-linux-linux").is_err());
+ assert!(Triple::from_str("x86_64-x86_64-linux").is_err());
+ assert!(Triple::from_str("x86_64-elf-linux").is_err());
+ assert!(Triple::from_str("x86_64-gnu-linux").is_err());
+ assert!(Triple::from_str("x86_64-linux-customvendor").is_err());
+ assert!(Triple::from_str("customvendor").is_err());
+ assert!(Triple::from_str("customvendor-x86_64").is_err());
+ assert!(Triple::from_str("x86_64-").is_err());
+ assert!(Triple::from_str("x86_64--").is_err());
+
+ let t = Triple::from_str("x86_64-customvendor-linux")
+ .expect("can't parse target with custom vendor");
+ assert_eq!(t.architecture, Architecture::X86_64);
+ assert_eq!(
+ t.vendor,
+ Vendor::Custom(Box::new(String::from_str("customvendor").unwrap()))
+ );
+ assert_eq!(t.operating_system, OperatingSystem::Linux);
+ assert_eq!(t.environment, Environment::Unknown);
+ assert_eq!(t.binary_format, BinaryFormat::Elf);
+ assert_eq!(t.to_string(), "x86_64-customvendor-linux");
+
+ let t = Triple::from_str("x86_64-customvendor")
+ .expect("can't parse target with custom vendor");
+ assert_eq!(t.architecture, Architecture::X86_64);
+ assert_eq!(
+ t.vendor,
+ Vendor::Custom(Box::new(String::from_str("customvendor").unwrap()))
+ );
+ assert_eq!(t.operating_system, OperatingSystem::Unknown);
+ assert_eq!(t.environment, Environment::Unknown);
+ assert_eq!(t.binary_format, BinaryFormat::Unknown);
+
+ assert_eq!(
+ Triple::from_str("unknown-foo"),
+ Ok(Triple {
+ architecture: Architecture::Unknown,
+ vendor: Vendor::Custom(Box::new(String::from_str("foo").unwrap())),
+ operating_system: OperatingSystem::Unknown,
+ environment: Environment::Unknown,
+ binary_format: BinaryFormat::Unknown,
+ })
+ );
+ }
}
diff --git a/src/triple.rs b/src/triple.rs
index 36dcd9a..1abda26 100644
--- a/third_party/rust/target-lexicon.0.9.0/src/triple.rs
+++ b/third_party/rust/target-lexicon-0.9.0/src/triple.rs
@@ -322,10 +322,6 @@ mod tests {
Triple::from_str("foo"),
Err(ParseError::UnrecognizedArchitecture("foo".to_owned()))
);
- assert_eq!(
- Triple::from_str("unknown-foo"),
- Err(ParseError::UnrecognizedVendor("foo".to_owned()))
- );
assert_eq!(
Triple::from_str("unknown-unknown-foo"),
Err(ParseError::UnrecognizedOperatingSystem("foo".to_owned()))
From 6f90d7274dce4e7f9bb120f6b36cf26881bde9a7 Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Tue, 5 Nov 2019 10:33:56 -0800
Subject: [PATCH 2/7] Add more tests.
---
src/targets.rs | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/targets.rs b/src/targets.rs
index 90b2736..7d1f069 100644
--- a/third_party/rust/target-lexicon-0.9.0/src/targets.rs
+++ b/third_party/rust/target-lexicon-0.9.0/src/targets.rs
@@ -1174,6 +1174,7 @@ mod tests {
#[test]
fn custom_vendors() {
+ // Test various invalid cases.
assert!(Triple::from_str("x86_64--linux").is_err());
assert!(Triple::from_str("x86_64-42-linux").is_err());
assert!(Triple::from_str("x86_64-__customvendor__-linux").is_err());
@@ -1190,6 +1191,31 @@ mod tests {
assert!(Triple::from_str("x86_64-").is_err());
assert!(Triple::from_str("x86_64--").is_err());
+ // Test various Unicode things.
+ assert!(
+ Triple::from_str("x86_64-𝓬𝓾𝓼𝓽𝓸𝓶𝓿𝓮𝓷𝓭𝓸𝓻-linux").is_err(),
+ "unicode font hazard"
+ );
+ assert!(
+ Triple::from_str("x86_64-ćúśtőḿvéńdőŕ-linux").is_err(),
+ "diacritical mark stripping hazard"
+ );
+ assert!(
+ Triple::from_str("x86_64-customvendοr-linux").is_err(),
+ "homoglyph hazard"
+ );
+ assert!(Triple::from_str("x86_64-customvendor-linux").is_ok());
+ assert!(
+ Triple::from_str("x86_64-ffi-linux").is_err(),
+ "normalization hazard"
+ );
+ assert!(Triple::from_str("x86_64-ffi-linux").is_ok());
+ assert!(
+ Triple::from_str("x86_64-customvendor-linux").is_err(),
+ "zero-width character hazard"
+ );
+
+ // Test some valid cases.
let t = Triple::from_str("x86_64-customvendor-linux")
.expect("can't parse target with custom vendor");
assert_eq!(t.architecture, Architecture::X86_64);
@@ -1202,8 +1228,8 @@ mod tests {
assert_eq!(t.binary_format, BinaryFormat::Elf);
assert_eq!(t.to_string(), "x86_64-customvendor-linux");
- let t = Triple::from_str("x86_64-customvendor")
- .expect("can't parse target with custom vendor");
+ let t =
+ Triple::from_str("x86_64-customvendor").expect("can't parse target with custom vendor");
assert_eq!(t.architecture, Architecture::X86_64);
assert_eq!(
t.vendor,
From c0e318b3c1be2d1965579f07dd563fb9cc0c4eb1 Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Tue, 5 Nov 2019 12:56:31 -0800
Subject: [PATCH 3/7] Use `.chars().any(...)` instead of
`.find(...).is_some()`.
---
src/targets.rs | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/targets.rs b/src/targets.rs
index 7d1f069..1078dd3 100644
--- a/third_party/rust/target-lexicon-0.9.0/src/targets.rs
+++ b/third_party/rust/target-lexicon/src-0.9.0/targets.rs
@@ -779,12 +779,9 @@ impl FromStr for Vendor {
}
// Restrict the set of characters permitted in a custom vendor.
- if custom
- .find(|c: char| {
- !(c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_' || c == '.')
- })
- .is_some()
- {
+ if custom.chars().any(|c: char| {
+ !(c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_' || c == '.')
+ }) {
return Err(());
}
From f319950528654c772193d9eb3bf40bc8df35fcae Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Thu, 7 Nov 2019 15:15:48 -0800
Subject: [PATCH 4/7] Fix build.rs to generate the correct code to build
Vendors.
---
build.rs | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/build.rs b/build.rs
index a0ba3b7..446f9e7 100644
--- a/third_party/rust/target-lexicon-0.9.0/build.rs
+++ b/third_party/rust/target-lexicon-0.9.0/build.rs
@@ -32,6 +32,7 @@ mod parse_error {
}
}
+use self::targets::Vendor;
use self::triple::Triple;
fn main() {
@@ -60,7 +61,7 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
" architecture: Architecture::{:?},",
triple.architecture
)?;
- writeln!(out, " vendor: Vendor::{:?},", triple.vendor)?;
+ writeln!(out, " vendor: {},", vendor_display(&triple.vendor))?;
writeln!(
out,
" operating_system: OperatingSystem::{:?},",
@@ -90,7 +91,7 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
writeln!(out, "impl Vendor {{")?;
writeln!(out, " /// Return the vendor for the current host.")?;
writeln!(out, " pub const fn host() -> Self {{")?;
- writeln!(out, " Vendor::{:?}", triple.vendor)?;
+ writeln!(out, " {}", vendor_display(&triple.vendor))?;
writeln!(out, " }}")?;
writeln!(out, "}}")?;
writeln!(out)?;
@@ -160,3 +161,12 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
Ok(())
}
+
+fn vendor_display(vendor: &Vendor) -> String {
+ match vendor {
+ Vendor::Custom(custom) => {
+ format!("Vendor::Custom(Box::new(String::from_str({:?})))", custom)
+ }
+ known => format!("Vendor::{:?}", known),
+ }
+}
From e558f6934535be3b8ccc9a99a33e861cb7431dfe Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Fri, 8 Nov 2019 12:10:34 -0800
Subject: [PATCH 5/7] Fix custom vendors in `const fn` contexts.
---
build.rs | 15 +++++++++++----
src/lib.rs | 4 ++--
src/targets.rs | 51 ++++++++++++++++++++++++++++++++++++++++++--------
3 files changed, 56 insertions(+), 14 deletions(-)
diff --git a/build.rs b/build.rs
index 446f9e7..e88206e 100644
--- a/third_party/rust/target-lexicon-0.9.0/build.rs
+++ b/third_party/rust/target-lexicon-0.9.0/build.rs
@@ -53,6 +53,8 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
writeln!(out, "use crate::Aarch64Architecture::*;")?;
writeln!(out, "#[allow(unused_imports)]")?;
writeln!(out, "use crate::ArmArchitecture::*;")?;
+ writeln!(out, "#[allow(unused_imports)]")?;
+ writeln!(out, "use crate::CustomVendor;")?;
writeln!(out)?;
writeln!(out, "/// The `Triple` of the current host.")?;
writeln!(out, "pub const HOST: Triple = Triple {{")?;
@@ -139,7 +141,11 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
" architecture: Architecture::{:?},",
triple.architecture
)?;
- writeln!(out, " vendor: Vendor::{:?},", triple.vendor)?;
+ writeln!(
+ out,
+ " vendor: {},",
+ vendor_display(&triple.vendor)
+ )?;
writeln!(
out,
" operating_system: OperatingSystem::{:?},",
@@ -164,9 +170,10 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
fn vendor_display(vendor: &Vendor) -> String {
match vendor {
- Vendor::Custom(custom) => {
- format!("Vendor::Custom(Box::new(String::from_str({:?})))", custom)
- }
+ Vendor::Custom(custom) => format!(
+ "Vendor::Custom(CustomVendor::Static({:?}))",
+ custom.as_str()
+ ),
known => format!("Vendor::{:?}", known),
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 8d6da8d..70f6488 100644
--- a/third_party/rust/target-lexicon-0.9.0/src/lib.rs
+++ b/third_party/rust/target-lexicon-0.9.0/src/lib.rs
@@ -28,7 +28,7 @@ mod triple;
pub use self::host::HOST;
pub use self::parse_error::ParseError;
pub use self::targets::{
- Aarch64Architecture, Architecture, ArmArchitecture, BinaryFormat, Environment, OperatingSystem,
- Vendor,
+ Aarch64Architecture, Architecture, ArmArchitecture, BinaryFormat, CustomVendor, Environment,
+ OperatingSystem, Vendor,
};
pub use self::triple::{CallingConvention, Endianness, PointerWidth, Triple};
diff --git a/src/targets.rs b/src/targets.rs
index 1078dd3..7152020 100644
--- a/third_party/rust/target-lexicon-0.9.0/src/targets.rs
+++ b/third_party/rust/target-lexicon-0.9.0/src/targets.rs
@@ -4,6 +4,7 @@ use crate::triple::{Endianness, PointerWidth, Triple};
use alloc::boxed::Box;
use alloc::string::String;
use core::fmt;
+use core::hash::{Hash, Hasher};
use core::str::FromStr;
/// The "architecture" field, which in some cases also specifies a specific
@@ -292,6 +293,39 @@ impl Aarch64Architecture {
}
}
+/// A string for a `Vendor::Custom` that can either be used in `const`
+/// contexts or hold dynamic strings.
+#[derive(Clone, Debug, Eq)]
+pub enum CustomVendor {
+ /// An owned `String`. This supports the general case.
+ Owned(Box<String>),
+ /// A static `str`, so that `CustomVendor` can be constructed in `const`
+ /// contexts.
+ Static(&'static str),
+}
+
+impl CustomVendor {
+ /// Extracts a string slice.
+ pub fn as_str(&self) -> &str {
+ match self {
+ CustomVendor::Owned(s) => s,
+ CustomVendor::Static(s) => s,
+ }
+ }
+}
+
+impl PartialEq for CustomVendor {
+ fn eq(&self, other: &Self) -> bool {
+ self.as_str() == other.as_str()
+ }
+}
+
+impl Hash for CustomVendor {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.as_str().hash(state)
+ }
+}
+
/// The "vendor" field, which in practice is little more than an arbitrary
/// modifier.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
@@ -316,7 +350,7 @@ pub enum Vendor {
///
/// Outside of such patched environments, users of `target-lexicon` should
/// treat `Custom` the same as `Unknown` and ignore the string.
- Custom(Box<String>),
+ Custom(CustomVendor),
}
/// The "operating system" field, which sometimes implies an environment, and
@@ -728,7 +762,7 @@ impl fmt::Display for Vendor {
Vendor::Sun => "sun",
Vendor::Uwp => "uwp",
Vendor::Wrs => "wrs",
- Vendor::Custom(ref name) => name,
+ Vendor::Custom(ref name) => name.as_str(),
};
f.write_str(s)
}
@@ -779,13 +813,14 @@ impl FromStr for Vendor {
}
// Restrict the set of characters permitted in a custom vendor.
- if custom.chars().any(|c: char| {
+ fn is_prohibited_char(c: char) -> bool {
!(c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_' || c == '.')
- }) {
+ }
+ if custom.chars().any(is_prohibited_char) {
return Err(());
}
- Vendor::Custom(Box::new(custom.to_owned()))
+ Vendor::Custom(CustomVendor::Owned(Box::new(custom.to_owned())))
}
})
}
@@ -1218,7 +1253,7 @@ mod tests {
assert_eq!(t.architecture, Architecture::X86_64);
assert_eq!(
t.vendor,
- Vendor::Custom(Box::new(String::from_str("customvendor").unwrap()))
+ Vendor::Custom(CustomVendor::Static("customvendor"))
);
assert_eq!(t.operating_system, OperatingSystem::Linux);
assert_eq!(t.environment, Environment::Unknown);
@@ -1230,7 +1265,7 @@ mod tests {
assert_eq!(t.architecture, Architecture::X86_64);
assert_eq!(
t.vendor,
- Vendor::Custom(Box::new(String::from_str("customvendor").unwrap()))
+ Vendor::Custom(CustomVendor::Static("customvendor"))
);
assert_eq!(t.operating_system, OperatingSystem::Unknown);
assert_eq!(t.environment, Environment::Unknown);
@@ -1240,7 +1275,7 @@ mod tests {
Triple::from_str("unknown-foo"),
Ok(Triple {
architecture: Architecture::Unknown,
- vendor: Vendor::Custom(Box::new(String::from_str("foo").unwrap())),
+ vendor: Vendor::Custom(CustomVendor::Static("foo")),
operating_system: OperatingSystem::Unknown,
environment: Environment::Unknown,
binary_format: BinaryFormat::Unknown,
From bc4b444133b8a5e56602f7c77c10ef3f1e7a7c78 Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Mon, 18 Nov 2019 13:45:58 -0800
Subject: [PATCH 6/7] Add a testcase with a BOM too, just in case.
---
src/targets.rs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/targets.rs b/src/targets.rs
index 7152020..9a4d990 100644
--- a/third_party/rust/target-lexicon-0.9.0/src/targets.rs
+++ b/third_party/rust/target-lexicon-0.9.0/src/targets.rs
@@ -1246,6 +1246,10 @@ mod tests {
Triple::from_str("x86_64-customvendor-linux").is_err(),
"zero-width character hazard"
);
+ assert!(
+ Triple::from_str("x86_64-customvendor-linux").is_err(),
+ "BOM hazard"
+ );
// Test some valid cases.
let t = Triple::from_str("x86_64-customvendor-linux")
From 721fbbe1c9cfd3adc9aaf011c62d6a36078f4133 Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Mon, 18 Nov 2019 20:56:40 -0800
Subject: [PATCH 7/7] Use an anonymous function instead of just a local
function.
---
src/targets.rs | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/targets.rs b/src/targets.rs
index 9a4d990..eb5a088 100644
--- a/third_party/rust/target-lexicon-0.9.0/src/targets.rs
+++ b/third_party/rust/target-lexicon-0.9.0/src/targets.rs
@@ -813,10 +813,9 @@ impl FromStr for Vendor {
}
// Restrict the set of characters permitted in a custom vendor.
- fn is_prohibited_char(c: char) -> bool {
+ if custom.chars().any(|c: char| {
!(c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_' || c == '.')
- }
- if custom.chars().any(is_prohibited_char) {
+ }) {
return Err(());
}
|