Debian Codegraph @

src/gen/cfg.rs

raw
1 // SPDX-License-Identifier: Apache-2.0 OR MIT
2 // This file is @generated by cfg.sh.
3 // It is not intended for manual editing.
4
5 //! Trait and types for [`Config::cfg`](crate::Config::cfg).
6
7 #![cfg_attr(rustfmt, rustfmt::skip)]
8 #![allow(non_camel_case_types)]
9
10 use alloc::{boxed::Box, string::String, vec, vec::Vec};
11 use core::{fmt, mem, str::FromStr};
12
13 pub trait Cfg {
14 /// The type returned from [`Config::cfg`](crate::Config::cfg) when no error occurred.
15 type Output: Sized;
16 /// The name of this cfg.
17 const KEY: &'static str;
18 /// (For use inside [`Config::cfg`](crate::Config::cfg).)
19 type Error: Sized + core::error::Error + Send + Sync + 'static;
20 /// (For use inside [`Config::cfg`](crate::Config::cfg).)
21 ///
22 /// The maximum number of this cfg.
23 ///
24 /// In all implementation provided by this crate, if `Self::Output` is a
25 /// collection type such as `Vec` it is `usize::MAX`, otherwise `1`.
26 const MAX: usize;
27 /// (For use inside [`Config::cfg`](crate::Config::cfg).)
28 ///
29 /// The length of `values` is `1..=Self::MAX`.
30 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
31 values: I,
32 ) -> Result<Self::Output, Self::Error>;
33 /// (For use inside [`Config::cfg`](crate::Config::cfg).)
34 ///
35 /// The value returned if cfg is not found. If `None`, an error is returned in such a case.
36 fn default_output() -> Option<Self::Output>;
37 }
38
39 /// `cfg(target_abi == "..")`
40 /// (Rust 1.78+)
41 ///
42 /// All non-empty values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
43 /// to 1.97 are available as variants. To construct other values, use
44 /// `TargetAbi::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
45 #[derive(Clone)]
46 #[non_exhaustive]
47 pub enum TargetAbi {
48 abi64,
49 abiv2,
50 abiv2hf,
51 eabi,
52 eabihf,
53 elf,
54 elfv1,
55 elfv2,
56 fortanix,
57 ilp32,
58 ilp32e,
59 llvm,
60 macabi,
61 sim,
62 softfloat,
63 spe,
64 uwp,
65 vec_extabi,
66 x32,
67 #[doc(hidden)]
68 #[deprecated(note = "do not use this variant directly; use as_str or compare with a string instead")]
69 __Other(Box<str>),
70 }
71 impl TargetAbi {
72 #[must_use]
73 pub const fn as_str(&self) -> &str {
74 match self {
75 Self::abi64 => "abi64",
76 Self::abiv2 => "abiv2",
77 Self::abiv2hf => "abiv2hf",
78 Self::eabi => "eabi",
79 Self::eabihf => "eabihf",
80 Self::elf => "elf",
81 Self::elfv1 => "elfv1",
82 Self::elfv2 => "elfv2",
83 Self::fortanix => "fortanix",
84 Self::ilp32 => "ilp32",
85 Self::ilp32e => "ilp32e",
86 Self::llvm => "llvm",
87 Self::macabi => "macabi",
88 Self::sim => "sim",
89 Self::softfloat => "softfloat",
90 Self::spe => "spe",
91 Self::uwp => "uwp",
92 Self::vec_extabi => "vec-extabi",
93 Self::x32 => "x32",
94 #[allow(deprecated)]
95 Self::__Other(s) => s,
96 }
97 }
98 }
99 impl PartialEq for TargetAbi {
100 fn eq(&self, other: &Self) -> bool {
101 match (self, other) {
102 // Even after new variants are added, to ensure comparisons in old
103 // code using __Other still work, compare strings if either is __Other.
104 #[allow(deprecated)]
105 (Self::__Other(_), _) | (_, Self::__Other(_)) => self.as_str() == other.as_str(),
106 (this, other) => mem::discriminant(this) == mem::discriminant(other),
107 }
108 }
109 }
110 impl Eq for TargetAbi {}
111 impl PartialEq<str> for TargetAbi {
112 fn eq(&self, other: &str) -> bool {
113 *self.as_str() == *other
114 }
115 }
116 impl PartialEq<&str> for TargetAbi {
117 fn eq(&self, &other: &&str) -> bool {
118 *self.as_str() == *other
119 }
120 }
121 impl PartialEq<TargetAbi> for str {
122 fn eq(&self, other: &TargetAbi) -> bool {
123 *self == *other.as_str()
124 }
125 }
126 impl PartialEq<TargetAbi> for &str {
127 fn eq(&self, other: &TargetAbi) -> bool {
128 **self == *other.as_str()
129 }
130 }
131 impl PartialEq<String> for TargetAbi {
132 fn eq(&self, other: &String) -> bool {
133 *self.as_str() == **other
134 }
135 }
136 impl PartialEq<&String> for TargetAbi {
137 fn eq(&self, &other: &&String) -> bool {
138 *self.as_str() == **other
139 }
140 }
141 impl PartialEq<TargetAbi> for String {
142 fn eq(&self, other: &TargetAbi) -> bool {
143 **self == *other.as_str()
144 }
145 }
146 impl PartialEq<TargetAbi> for &String {
147 fn eq(&self, other: &TargetAbi) -> bool {
148 ***self == *other.as_str()
149 }
150 }
151 impl PartialEq<Box<str>> for TargetAbi {
152 fn eq(&self, other: &Box<str>) -> bool {
153 *self.as_str() == **other
154 }
155 }
156 impl PartialEq<&Box<str>> for TargetAbi {
157 fn eq(&self, &other: &&Box<str>) -> bool {
158 *self.as_str() == **other
159 }
160 }
161 impl PartialEq<TargetAbi> for Box<str> {
162 fn eq(&self, other: &TargetAbi) -> bool {
163 **self == *other.as_str()
164 }
165 }
166 impl PartialEq<TargetAbi> for &Box<str> {
167 fn eq(&self, other: &TargetAbi) -> bool {
168 ***self == *other.as_str()
169 }
170 }
171 impl From<&str> for TargetAbi {
172 fn from(s: &str) -> Self {
173 match Self::from_str(s) {
174 Ok(s) => s,
175 Err(e) => match e {},
176 }
177 }
178 }
179 impl FromStr for TargetAbi {
180 type Err = core::convert::Infallible;
181 fn from_str(s: &str) -> Result<Self, Self::Err> {
182 match s {
183 "abi64" => Ok(Self::abi64),
184 "abiv2" => Ok(Self::abiv2),
185 "abiv2hf" => Ok(Self::abiv2hf),
186 "eabi" => Ok(Self::eabi),
187 "eabihf" => Ok(Self::eabihf),
188 "elf" => Ok(Self::elf),
189 "elfv1" => Ok(Self::elfv1),
190 "elfv2" => Ok(Self::elfv2),
191 "fortanix" => Ok(Self::fortanix),
192 "ilp32" => Ok(Self::ilp32),
193 "ilp32e" => Ok(Self::ilp32e),
194 "llvm" => Ok(Self::llvm),
195 "macabi" => Ok(Self::macabi),
196 "sim" => Ok(Self::sim),
197 "softfloat" => Ok(Self::softfloat),
198 "spe" => Ok(Self::spe),
199 "uwp" => Ok(Self::uwp),
200 "vec-extabi" => Ok(Self::vec_extabi),
201 "x32" => Ok(Self::x32),
202 #[allow(deprecated)]
203 s => Ok(Self::__Other(s.into())),
204 }
205 }
206 }
207 impl Cfg for TargetAbi {
208 type Output = Option<Self>;
209 const KEY: &'static str = "target_abi";
210 type Error = core::convert::Infallible;
211 const MAX: usize = 1;
212 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
213 mut values: I,
214 ) -> Result<Self::Output, Self::Error> {
215 Ok(Some(values.next().unwrap().as_ref().parse()?))
216 }
217 fn default_output() -> Option<Self::Output> {
218 Some(None)
219 }
220 }
221 impl fmt::Debug for TargetAbi {
222 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
223 fmt::Debug::fmt(self.as_str(), f)
224 }
225 }
226 impl fmt::Display for TargetAbi {
227 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
228 f.write_str(self.as_str())
229 }
230 }
231
232 /// `cfg(target_arch == "..")`
233 ///
234 /// All non-empty values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
235 /// to 1.97 are available as variants. To construct other values, use
236 /// `TargetArch::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
237 #[derive(Clone)]
238 #[non_exhaustive]
239 pub enum TargetArch {
240 aarch64,
241 amdgpu,
242 arm,
243 arm64ec,
244 asmjs,
245 avr,
246 bpf,
247 csky,
248 hexagon,
249 le32,
250 loongarch32,
251 loongarch64,
252 m68k,
253 mips,
254 mips32r6,
255 mips64,
256 mips64r6,
257 msp430,
258 nvptx64,
259 powerpc,
260 powerpc64,
261 riscv32,
262 riscv64,
263 s390x,
264 sparc,
265 sparc64,
266 wasm32,
267 wasm64,
268 x86,
269 x86_64,
270 xtensa,
271 #[doc(hidden)]
272 #[deprecated(note = "do not use this variant directly; use as_str or compare with a string instead")]
273 __Other(Box<str>),
274 }
275 impl TargetArch {
276 #[must_use]
277 pub const fn as_str(&self) -> &str {
278 match self {
279 Self::aarch64 => "aarch64",
280 Self::amdgpu => "amdgpu",
281 Self::arm => "arm",
282 Self::arm64ec => "arm64ec",
283 Self::asmjs => "asmjs",
284 Self::avr => "avr",
285 Self::bpf => "bpf",
286 Self::csky => "csky",
287 Self::hexagon => "hexagon",
288 Self::le32 => "le32",
289 Self::loongarch32 => "loongarch32",
290 Self::loongarch64 => "loongarch64",
291 Self::m68k => "m68k",
292 Self::mips => "mips",
293 Self::mips32r6 => "mips32r6",
294 Self::mips64 => "mips64",
295 Self::mips64r6 => "mips64r6",
296 Self::msp430 => "msp430",
297 Self::nvptx64 => "nvptx64",
298 Self::powerpc => "powerpc",
299 Self::powerpc64 => "powerpc64",
300 Self::riscv32 => "riscv32",
301 Self::riscv64 => "riscv64",
302 Self::s390x => "s390x",
303 Self::sparc => "sparc",
304 Self::sparc64 => "sparc64",
305 Self::wasm32 => "wasm32",
306 Self::wasm64 => "wasm64",
307 Self::x86 => "x86",
308 Self::x86_64 => "x86_64",
309 Self::xtensa => "xtensa",
310 #[allow(deprecated)]
311 Self::__Other(s) => s,
312 }
313 }
314 }
315 impl PartialEq for TargetArch {
316 fn eq(&self, other: &Self) -> bool {
317 match (self, other) {
318 // Even after new variants are added, to ensure comparisons in old
319 // code using __Other still work, compare strings if either is __Other.
320 #[allow(deprecated)]
321 (Self::__Other(_), _) | (_, Self::__Other(_)) => self.as_str() == other.as_str(),
322 (this, other) => mem::discriminant(this) == mem::discriminant(other),
323 }
324 }
325 }
326 impl Eq for TargetArch {}
327 impl PartialEq<str> for TargetArch {
328 fn eq(&self, other: &str) -> bool {
329 *self.as_str() == *other
330 }
331 }
332 impl PartialEq<&str> for TargetArch {
333 fn eq(&self, &other: &&str) -> bool {
334 *self.as_str() == *other
335 }
336 }
337 impl PartialEq<TargetArch> for str {
338 fn eq(&self, other: &TargetArch) -> bool {
339 *self == *other.as_str()
340 }
341 }
342 impl PartialEq<TargetArch> for &str {
343 fn eq(&self, other: &TargetArch) -> bool {
344 **self == *other.as_str()
345 }
346 }
347 impl PartialEq<String> for TargetArch {
348 fn eq(&self, other: &String) -> bool {
349 *self.as_str() == **other
350 }
351 }
352 impl PartialEq<&String> for TargetArch {
353 fn eq(&self, &other: &&String) -> bool {
354 *self.as_str() == **other
355 }
356 }
357 impl PartialEq<TargetArch> for String {
358 fn eq(&self, other: &TargetArch) -> bool {
359 **self == *other.as_str()
360 }
361 }
362 impl PartialEq<TargetArch> for &String {
363 fn eq(&self, other: &TargetArch) -> bool {
364 ***self == *other.as_str()
365 }
366 }
367 impl PartialEq<Box<str>> for TargetArch {
368 fn eq(&self, other: &Box<str>) -> bool {
369 *self.as_str() == **other
370 }
371 }
372 impl PartialEq<&Box<str>> for TargetArch {
373 fn eq(&self, &other: &&Box<str>) -> bool {
374 *self.as_str() == **other
375 }
376 }
377 impl PartialEq<TargetArch> for Box<str> {
378 fn eq(&self, other: &TargetArch) -> bool {
379 **self == *other.as_str()
380 }
381 }
382 impl PartialEq<TargetArch> for &Box<str> {
383 fn eq(&self, other: &TargetArch) -> bool {
384 ***self == *other.as_str()
385 }
386 }
387 impl From<&str> for TargetArch {
388 fn from(s: &str) -> Self {
389 match Self::from_str(s) {
390 Ok(s) => s,
391 Err(e) => match e {},
392 }
393 }
394 }
395 impl FromStr for TargetArch {
396 type Err = core::convert::Infallible;
397 fn from_str(s: &str) -> Result<Self, Self::Err> {
398 match s {
399 "aarch64" => Ok(Self::aarch64),
400 "amdgpu" => Ok(Self::amdgpu),
401 "arm" => Ok(Self::arm),
402 "arm64ec" => Ok(Self::arm64ec),
403 "asmjs" => Ok(Self::asmjs),
404 "avr" => Ok(Self::avr),
405 "bpf" => Ok(Self::bpf),
406 "csky" => Ok(Self::csky),
407 "hexagon" => Ok(Self::hexagon),
408 "le32" => Ok(Self::le32),
409 "loongarch32" => Ok(Self::loongarch32),
410 "loongarch64" => Ok(Self::loongarch64),
411 "m68k" => Ok(Self::m68k),
412 "mips" => Ok(Self::mips),
413 "mips32r6" => Ok(Self::mips32r6),
414 "mips64" => Ok(Self::mips64),
415 "mips64r6" => Ok(Self::mips64r6),
416 "msp430" => Ok(Self::msp430),
417 "nvptx64" => Ok(Self::nvptx64),
418 "powerpc" => Ok(Self::powerpc),
419 "powerpc64" => Ok(Self::powerpc64),
420 "riscv32" => Ok(Self::riscv32),
421 "riscv64" => Ok(Self::riscv64),
422 "s390x" => Ok(Self::s390x),
423 "sparc" => Ok(Self::sparc),
424 "sparc64" => Ok(Self::sparc64),
425 "wasm32" => Ok(Self::wasm32),
426 "wasm64" => Ok(Self::wasm64),
427 "x86" => Ok(Self::x86),
428 "x86_64" => Ok(Self::x86_64),
429 "xtensa" => Ok(Self::xtensa),
430 #[allow(deprecated)]
431 s => Ok(Self::__Other(s.into())),
432 }
433 }
434 }
435 impl Cfg for TargetArch {
436 type Output = Self;
437 const KEY: &'static str = "target_arch";
438 type Error = core::convert::Infallible;
439 const MAX: usize = 1;
440 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
441 mut values: I,
442 ) -> Result<Self::Output, Self::Error> {
443 values.next().unwrap().as_ref().parse()
444 }
445 fn default_output() -> Option<Self::Output> {
446 None
447 }
448 }
449 impl fmt::Debug for TargetArch {
450 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
451 fmt::Debug::fmt(self.as_str(), f)
452 }
453 }
454 impl fmt::Display for TargetArch {
455 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
456 f.write_str(self.as_str())
457 }
458 }
459
460 /// `cfg(target_endian == "..")`
461 ///
462 /// All non-empty values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
463 /// to 1.97 are available as variants. To construct other values, use
464 /// `TargetEndian::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
465 #[derive(Clone, PartialEq, Eq)]
466 #[allow(clippy::exhaustive_enums)]
467 pub enum TargetEndian {
468 big,
469 little,
470 }
471 impl TargetEndian {
472 #[must_use]
473 pub const fn as_str(&self) -> &str {
474 match self {
475 Self::big => "big",
476 Self::little => "little",
477 }
478 }
479 }
480 impl PartialEq<str> for TargetEndian {
481 fn eq(&self, other: &str) -> bool {
482 *self.as_str() == *other
483 }
484 }
485 impl PartialEq<&str> for TargetEndian {
486 fn eq(&self, &other: &&str) -> bool {
487 *self.as_str() == *other
488 }
489 }
490 impl PartialEq<TargetEndian> for str {
491 fn eq(&self, other: &TargetEndian) -> bool {
492 *self == *other.as_str()
493 }
494 }
495 impl PartialEq<TargetEndian> for &str {
496 fn eq(&self, other: &TargetEndian) -> bool {
497 **self == *other.as_str()
498 }
499 }
500 impl PartialEq<String> for TargetEndian {
501 fn eq(&self, other: &String) -> bool {
502 *self.as_str() == **other
503 }
504 }
505 impl PartialEq<&String> for TargetEndian {
506 fn eq(&self, &other: &&String) -> bool {
507 *self.as_str() == **other
508 }
509 }
510 impl PartialEq<TargetEndian> for String {
511 fn eq(&self, other: &TargetEndian) -> bool {
512 **self == *other.as_str()
513 }
514 }
515 impl PartialEq<TargetEndian> for &String {
516 fn eq(&self, other: &TargetEndian) -> bool {
517 ***self == *other.as_str()
518 }
519 }
520 impl PartialEq<Box<str>> for TargetEndian {
521 fn eq(&self, other: &Box<str>) -> bool {
522 *self.as_str() == **other
523 }
524 }
525 impl PartialEq<&Box<str>> for TargetEndian {
526 fn eq(&self, &other: &&Box<str>) -> bool {
527 *self.as_str() == **other
528 }
529 }
530 impl PartialEq<TargetEndian> for Box<str> {
531 fn eq(&self, other: &TargetEndian) -> bool {
532 **self == *other.as_str()
533 }
534 }
535 impl PartialEq<TargetEndian> for &Box<str> {
536 fn eq(&self, other: &TargetEndian) -> bool {
537 ***self == *other.as_str()
538 }
539 }
540 impl FromStr for TargetEndian {
541 type Err = crate::Error;
542 fn from_str(s: &str) -> Result<Self, Self::Err> {
543 match s {
544 "big" => Ok(Self::big),
545 "little" => Ok(Self::little),
546 other => bail!("must be one of big, little, but found `{other}`"),
547 }
548 }
549 }
550 impl Cfg for TargetEndian {
551 type Output = Self;
552 const KEY: &'static str = "target_endian";
553 type Error = crate::Error;
554 const MAX: usize = 1;
555 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
556 mut values: I,
557 ) -> Result<Self::Output, Self::Error> {
558 values.next().unwrap().as_ref().parse()
559 }
560 fn default_output() -> Option<Self::Output> {
561 None
562 }
563 }
564 impl fmt::Debug for TargetEndian {
565 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
566 fmt::Debug::fmt(self.as_str(), f)
567 }
568 }
569 impl fmt::Display for TargetEndian {
570 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
571 f.write_str(self.as_str())
572 }
573 }
574
575 /// `cfg(target_env == "..")`
576 ///
577 /// All non-empty values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
578 /// to 1.97 are available as variants. To construct other values, use
579 /// `TargetEnv::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
580 #[derive(Clone)]
581 #[non_exhaustive]
582 pub enum TargetEnv {
583 eabihf,
584 gnu,
585 gnueabi,
586 gnueabihf,
587 macabi,
588 mlibc,
589 msvc,
590 musl,
591 newlib,
592 nto70,
593 nto71,
594 nto71_iosock,
595 nto80,
596 ohos,
597 p1,
598 p2,
599 p3,
600 psx,
601 relibc,
602 sgx,
603 sim,
604 uclibc,
605 v5,
606 wasi,
607 #[doc(hidden)]
608 #[deprecated(note = "do not use this variant directly; use as_str or compare with a string instead")]
609 __Other(Box<str>),
610 }
611 impl TargetEnv {
612 #[must_use]
613 pub const fn as_str(&self) -> &str {
614 match self {
615 Self::eabihf => "eabihf",
616 Self::gnu => "gnu",
617 Self::gnueabi => "gnueabi",
618 Self::gnueabihf => "gnueabihf",
619 Self::macabi => "macabi",
620 Self::mlibc => "mlibc",
621 Self::msvc => "msvc",
622 Self::musl => "musl",
623 Self::newlib => "newlib",
624 Self::nto70 => "nto70",
625 Self::nto71 => "nto71",
626 Self::nto71_iosock => "nto71_iosock",
627 Self::nto80 => "nto80",
628 Self::ohos => "ohos",
629 Self::p1 => "p1",
630 Self::p2 => "p2",
631 Self::p3 => "p3",
632 Self::psx => "psx",
633 Self::relibc => "relibc",
634 Self::sgx => "sgx",
635 Self::sim => "sim",
636 Self::uclibc => "uclibc",
637 Self::v5 => "v5",
638 Self::wasi => "wasi",
639 #[allow(deprecated)]
640 Self::__Other(s) => s,
641 }
642 }
643 }
644 impl PartialEq for TargetEnv {
645 fn eq(&self, other: &Self) -> bool {
646 match (self, other) {
647 // Even after new variants are added, to ensure comparisons in old
648 // code using __Other still work, compare strings if either is __Other.
649 #[allow(deprecated)]
650 (Self::__Other(_), _) | (_, Self::__Other(_)) => self.as_str() == other.as_str(),
651 (this, other) => mem::discriminant(this) == mem::discriminant(other),
652 }
653 }
654 }
655 impl Eq for TargetEnv {}
656 impl PartialEq<str> for TargetEnv {
657 fn eq(&self, other: &str) -> bool {
658 *self.as_str() == *other
659 }
660 }
661 impl PartialEq<&str> for TargetEnv {
662 fn eq(&self, &other: &&str) -> bool {
663 *self.as_str() == *other
664 }
665 }
666 impl PartialEq<TargetEnv> for str {
667 fn eq(&self, other: &TargetEnv) -> bool {
668 *self == *other.as_str()
669 }
670 }
671 impl PartialEq<TargetEnv> for &str {
672 fn eq(&self, other: &TargetEnv) -> bool {
673 **self == *other.as_str()
674 }
675 }
676 impl PartialEq<String> for TargetEnv {
677 fn eq(&self, other: &String) -> bool {
678 *self.as_str() == **other
679 }
680 }
681 impl PartialEq<&String> for TargetEnv {
682 fn eq(&self, &other: &&String) -> bool {
683 *self.as_str() == **other
684 }
685 }
686 impl PartialEq<TargetEnv> for String {
687 fn eq(&self, other: &TargetEnv) -> bool {
688 **self == *other.as_str()
689 }
690 }
691 impl PartialEq<TargetEnv> for &String {
692 fn eq(&self, other: &TargetEnv) -> bool {
693 ***self == *other.as_str()
694 }
695 }
696 impl PartialEq<Box<str>> for TargetEnv {
697 fn eq(&self, other: &Box<str>) -> bool {
698 *self.as_str() == **other
699 }
700 }
701 impl PartialEq<&Box<str>> for TargetEnv {
702 fn eq(&self, &other: &&Box<str>) -> bool {
703 *self.as_str() == **other
704 }
705 }
706 impl PartialEq<TargetEnv> for Box<str> {
707 fn eq(&self, other: &TargetEnv) -> bool {
708 **self == *other.as_str()
709 }
710 }
711 impl PartialEq<TargetEnv> for &Box<str> {
712 fn eq(&self, other: &TargetEnv) -> bool {
713 ***self == *other.as_str()
714 }
715 }
716 impl From<&str> for TargetEnv {
717 fn from(s: &str) -> Self {
718 match Self::from_str(s) {
719 Ok(s) => s,
720 Err(e) => match e {},
721 }
722 }
723 }
724 impl FromStr for TargetEnv {
725 type Err = core::convert::Infallible;
726 fn from_str(s: &str) -> Result<Self, Self::Err> {
727 match s {
728 "eabihf" => Ok(Self::eabihf),
729 "gnu" => Ok(Self::gnu),
730 "gnueabi" => Ok(Self::gnueabi),
731 "gnueabihf" => Ok(Self::gnueabihf),
732 "macabi" => Ok(Self::macabi),
733 "mlibc" => Ok(Self::mlibc),
734 "msvc" => Ok(Self::msvc),
735 "musl" => Ok(Self::musl),
736 "newlib" => Ok(Self::newlib),
737 "nto70" => Ok(Self::nto70),
738 "nto71" => Ok(Self::nto71),
739 "nto71_iosock" => Ok(Self::nto71_iosock),
740 "nto80" => Ok(Self::nto80),
741 "ohos" => Ok(Self::ohos),
742 "p1" => Ok(Self::p1),
743 "p2" => Ok(Self::p2),
744 "p3" => Ok(Self::p3),
745 "psx" => Ok(Self::psx),
746 "relibc" => Ok(Self::relibc),
747 "sgx" => Ok(Self::sgx),
748 "sim" => Ok(Self::sim),
749 "uclibc" => Ok(Self::uclibc),
750 "v5" => Ok(Self::v5),
751 "wasi" => Ok(Self::wasi),
752 #[allow(deprecated)]
753 s => Ok(Self::__Other(s.into())),
754 }
755 }
756 }
757 impl Cfg for TargetEnv {
758 type Output = Option<Self>;
759 const KEY: &'static str = "target_env";
760 type Error = core::convert::Infallible;
761 const MAX: usize = 1;
762 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
763 mut values: I,
764 ) -> Result<Self::Output, Self::Error> {
765 Ok(Some(values.next().unwrap().as_ref().parse()?))
766 }
767 fn default_output() -> Option<Self::Output> {
768 Some(None)
769 }
770 }
771 impl fmt::Debug for TargetEnv {
772 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
773 fmt::Debug::fmt(self.as_str(), f)
774 }
775 }
776 impl fmt::Display for TargetEnv {
777 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
778 f.write_str(self.as_str())
779 }
780 }
781
782 /// `cfg(target_family == "..")`
783 ///
784 /// All non-empty values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
785 /// to 1.97 are available as variants. To construct other values, use
786 /// `TargetFamily::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
787 #[derive(Clone)]
788 #[non_exhaustive]
789 pub enum TargetFamily {
790 unix,
791 wasm,
792 windows,
793 #[doc(hidden)]
794 #[deprecated(note = "do not use this variant directly; use as_str or compare with a string instead")]
795 __Other(Box<str>),
796 }
797 impl TargetFamily {
798 #[must_use]
799 pub const fn as_str(&self) -> &str {
800 match self {
801 Self::unix => "unix",
802 Self::wasm => "wasm",
803 Self::windows => "windows",
804 #[allow(deprecated)]
805 Self::__Other(s) => s,
806 }
807 }
808 }
809 impl PartialEq for TargetFamily {
810 fn eq(&self, other: &Self) -> bool {
811 match (self, other) {
812 // Even after new variants are added, to ensure comparisons in old
813 // code using __Other still work, compare strings if either is __Other.
814 #[allow(deprecated)]
815 (Self::__Other(_), _) | (_, Self::__Other(_)) => self.as_str() == other.as_str(),
816 (this, other) => mem::discriminant(this) == mem::discriminant(other),
817 }
818 }
819 }
820 impl Eq for TargetFamily {}
821 impl PartialEq<str> for TargetFamily {
822 fn eq(&self, other: &str) -> bool {
823 *self.as_str() == *other
824 }
825 }
826 impl PartialEq<&str> for TargetFamily {
827 fn eq(&self, &other: &&str) -> bool {
828 *self.as_str() == *other
829 }
830 }
831 impl PartialEq<TargetFamily> for str {
832 fn eq(&self, other: &TargetFamily) -> bool {
833 *self == *other.as_str()
834 }
835 }
836 impl PartialEq<TargetFamily> for &str {
837 fn eq(&self, other: &TargetFamily) -> bool {
838 **self == *other.as_str()
839 }
840 }
841 impl PartialEq<String> for TargetFamily {
842 fn eq(&self, other: &String) -> bool {
843 *self.as_str() == **other
844 }
845 }
846 impl PartialEq<&String> for TargetFamily {
847 fn eq(&self, &other: &&String) -> bool {
848 *self.as_str() == **other
849 }
850 }
851 impl PartialEq<TargetFamily> for String {
852 fn eq(&self, other: &TargetFamily) -> bool {
853 **self == *other.as_str()
854 }
855 }
856 impl PartialEq<TargetFamily> for &String {
857 fn eq(&self, other: &TargetFamily) -> bool {
858 ***self == *other.as_str()
859 }
860 }
861 impl PartialEq<Box<str>> for TargetFamily {
862 fn eq(&self, other: &Box<str>) -> bool {
863 *self.as_str() == **other
864 }
865 }
866 impl PartialEq<&Box<str>> for TargetFamily {
867 fn eq(&self, &other: &&Box<str>) -> bool {
868 *self.as_str() == **other
869 }
870 }
871 impl PartialEq<TargetFamily> for Box<str> {
872 fn eq(&self, other: &TargetFamily) -> bool {
873 **self == *other.as_str()
874 }
875 }
876 impl PartialEq<TargetFamily> for &Box<str> {
877 fn eq(&self, other: &TargetFamily) -> bool {
878 ***self == *other.as_str()
879 }
880 }
881 impl From<&str> for TargetFamily {
882 fn from(s: &str) -> Self {
883 match Self::from_str(s) {
884 Ok(s) => s,
885 Err(e) => match e {},
886 }
887 }
888 }
889 impl FromStr for TargetFamily {
890 type Err = core::convert::Infallible;
891 fn from_str(s: &str) -> Result<Self, Self::Err> {
892 match s {
893 "unix" => Ok(Self::unix),
894 "wasm" => Ok(Self::wasm),
895 "windows" => Ok(Self::windows),
896 #[allow(deprecated)]
897 s => Ok(Self::__Other(s.into())),
898 }
899 }
900 }
901 impl Cfg for TargetFamily {
902 type Output = Vec<Self>;
903 const KEY: &'static str = "target_family";
904 type Error = core::convert::Infallible;
905 const MAX: usize = usize::MAX;
906 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
907 values: I,
908 ) -> Result<Self::Output, Self::Error> {
909 let mut res = Vec::with_capacity(values.len());
910 for value in values {
911 res.push(value.as_ref().parse()?);
912 }
913 Ok(res)
914 }
915 fn default_output() -> Option<Self::Output> {
916 Some(vec![])
917 }
918 }
919 impl fmt::Debug for TargetFamily {
920 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
921 fmt::Debug::fmt(self.as_str(), f)
922 }
923 }
924 impl fmt::Display for TargetFamily {
925 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
926 f.write_str(self.as_str())
927 }
928 }
929
930 /// `cfg(target_has_atomic == "..")`
931 /// (Rust 1.60+)
932 ///
933 /// All values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
934 /// to 1.97 are constructable without allocation. To construct values, use
935 /// `TargetHasAtomic::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
936 #[derive(Clone)]
937 pub struct TargetHasAtomic(TargetHasAtomicRepr);
938 #[derive(Clone)]
939 enum TargetHasAtomicRepr {
940 _128,
941 _16,
942 _32,
943 _64,
944 _8,
945 ptr,
946 __Other(Box<str>),
947 }
948 impl TargetHasAtomic {
949 #[must_use]
950 pub const fn as_str(&self) -> &str {
951 match &self.0 {
952 TargetHasAtomicRepr::_128 => "128",
953 TargetHasAtomicRepr::_16 => "16",
954 TargetHasAtomicRepr::_32 => "32",
955 TargetHasAtomicRepr::_64 => "64",
956 TargetHasAtomicRepr::_8 => "8",
957 TargetHasAtomicRepr::ptr => "ptr",
958 TargetHasAtomicRepr::__Other(s) => s,
959 }
960 }
961 }
962 impl PartialEq for TargetHasAtomic {
963 fn eq(&self, other: &Self) -> bool {
964 match (&self.0, &other.0) {
965 // Even after new variants are added, to ensure comparisons in old
966 // code using __Other still work, compare strings if either is __Other.
967 (TargetHasAtomicRepr::__Other(_), _) | (_, TargetHasAtomicRepr::__Other(_)) => self.as_str() == other.as_str(),
968 (this, other) => mem::discriminant(this) == mem::discriminant(other),
969 }
970 }
971 }
972 impl Eq for TargetHasAtomic {}
973 impl PartialEq<str> for TargetHasAtomic {
974 fn eq(&self, other: &str) -> bool {
975 *self.as_str() == *other
976 }
977 }
978 impl PartialEq<&str> for TargetHasAtomic {
979 fn eq(&self, &other: &&str) -> bool {
980 *self.as_str() == *other
981 }
982 }
983 impl PartialEq<TargetHasAtomic> for str {
984 fn eq(&self, other: &TargetHasAtomic) -> bool {
985 *self == *other.as_str()
986 }
987 }
988 impl PartialEq<TargetHasAtomic> for &str {
989 fn eq(&self, other: &TargetHasAtomic) -> bool {
990 **self == *other.as_str()
991 }
992 }
993 impl PartialEq<String> for TargetHasAtomic {
994 fn eq(&self, other: &String) -> bool {
995 *self.as_str() == **other
996 }
997 }
998 impl PartialEq<&String> for TargetHasAtomic {
999 fn eq(&self, &other: &&String) -> bool {
1000 *self.as_str() == **other
1001 }
1002 }
1003 impl PartialEq<TargetHasAtomic> for String {
1004 fn eq(&self, other: &TargetHasAtomic) -> bool {
1005 **self == *other.as_str()
1006 }
1007 }
1008 impl PartialEq<TargetHasAtomic> for &String {
1009 fn eq(&self, other: &TargetHasAtomic) -> bool {
1010 ***self == *other.as_str()
1011 }
1012 }
1013 impl PartialEq<Box<str>> for TargetHasAtomic {
1014 fn eq(&self, other: &Box<str>) -> bool {
1015 *self.as_str() == **other
1016 }
1017 }
1018 impl PartialEq<&Box<str>> for TargetHasAtomic {
1019 fn eq(&self, &other: &&Box<str>) -> bool {
1020 *self.as_str() == **other
1021 }
1022 }
1023 impl PartialEq<TargetHasAtomic> for Box<str> {
1024 fn eq(&self, other: &TargetHasAtomic) -> bool {
1025 **self == *other.as_str()
1026 }
1027 }
1028 impl PartialEq<TargetHasAtomic> for &Box<str> {
1029 fn eq(&self, other: &TargetHasAtomic) -> bool {
1030 ***self == *other.as_str()
1031 }
1032 }
1033 impl PartialEq<u16> for TargetHasAtomic {
1034 fn eq(&self, other: &u16) -> bool {
1035 match &self.0 {
1036 TargetHasAtomicRepr::_128 => 128 == *other,
1037 TargetHasAtomicRepr::_16 => 16 == *other,
1038 TargetHasAtomicRepr::_32 => 32 == *other,
1039 TargetHasAtomicRepr::_64 => 64 == *other,
1040 TargetHasAtomicRepr::_8 => 8 == *other,
1041 TargetHasAtomicRepr::ptr => false,
1042 TargetHasAtomicRepr::__Other(this) => this.parse().ok() == Some(*other),
1043 }
1044 }
1045 }
1046 impl PartialEq<u16> for &TargetHasAtomic {
1047 fn eq(&self, other: &u16) -> bool {
1048 *self == other
1049 }
1050 }
1051 impl PartialEq<TargetHasAtomic> for u16 {
1052 fn eq(&self, other: &TargetHasAtomic) -> bool {
1053 other == self
1054 }
1055 }
1056 impl PartialEq<&TargetHasAtomic> for u16 {
1057 fn eq(&self, &other: &&TargetHasAtomic) -> bool {
1058 other == self
1059 }
1060 }
1061 impl PartialEq<i32> for TargetHasAtomic {
1062 fn eq(&self, other: &i32) -> bool {
1063 match &self.0 {
1064 TargetHasAtomicRepr::_128 => 128 == *other,
1065 TargetHasAtomicRepr::_16 => 16 == *other,
1066 TargetHasAtomicRepr::_32 => 32 == *other,
1067 TargetHasAtomicRepr::_64 => 64 == *other,
1068 TargetHasAtomicRepr::_8 => 8 == *other,
1069 TargetHasAtomicRepr::ptr => false,
1070 TargetHasAtomicRepr::__Other(this) => this.parse().ok() == Some(*other),
1071 }
1072 }
1073 }
1074 impl PartialEq<i32> for &TargetHasAtomic {
1075 fn eq(&self, other: &i32) -> bool {
1076 *self == other
1077 }
1078 }
1079 impl PartialEq<TargetHasAtomic> for i32 {
1080 fn eq(&self, other: &TargetHasAtomic) -> bool {
1081 other == self
1082 }
1083 }
1084 impl PartialEq<&TargetHasAtomic> for i32 {
1085 fn eq(&self, &other: &&TargetHasAtomic) -> bool {
1086 other == self
1087 }
1088 }
1089 impl PartialEq<u32> for TargetHasAtomic {
1090 fn eq(&self, other: &u32) -> bool {
1091 match &self.0 {
1092 TargetHasAtomicRepr::_128 => 128 == *other,
1093 TargetHasAtomicRepr::_16 => 16 == *other,
1094 TargetHasAtomicRepr::_32 => 32 == *other,
1095 TargetHasAtomicRepr::_64 => 64 == *other,
1096 TargetHasAtomicRepr::_8 => 8 == *other,
1097 TargetHasAtomicRepr::ptr => false,
1098 TargetHasAtomicRepr::__Other(this) => this.parse().ok() == Some(*other),
1099 }
1100 }
1101 }
1102 impl PartialEq<u32> for &TargetHasAtomic {
1103 fn eq(&self, other: &u32) -> bool {
1104 *self == other
1105 }
1106 }
1107 impl PartialEq<TargetHasAtomic> for u32 {
1108 fn eq(&self, other: &TargetHasAtomic) -> bool {
1109 other == self
1110 }
1111 }
1112 impl PartialEq<&TargetHasAtomic> for u32 {
1113 fn eq(&self, &other: &&TargetHasAtomic) -> bool {
1114 other == self
1115 }
1116 }
1117 impl PartialEq<u64> for TargetHasAtomic {
1118 fn eq(&self, other: &u64) -> bool {
1119 match &self.0 {
1120 TargetHasAtomicRepr::_128 => 128 == *other,
1121 TargetHasAtomicRepr::_16 => 16 == *other,
1122 TargetHasAtomicRepr::_32 => 32 == *other,
1123 TargetHasAtomicRepr::_64 => 64 == *other,
1124 TargetHasAtomicRepr::_8 => 8 == *other,
1125 TargetHasAtomicRepr::ptr => false,
1126 TargetHasAtomicRepr::__Other(this) => this.parse().ok() == Some(*other),
1127 }
1128 }
1129 }
1130 impl PartialEq<u64> for &TargetHasAtomic {
1131 fn eq(&self, other: &u64) -> bool {
1132 *self == other
1133 }
1134 }
1135 impl PartialEq<TargetHasAtomic> for u64 {
1136 fn eq(&self, other: &TargetHasAtomic) -> bool {
1137 other == self
1138 }
1139 }
1140 impl PartialEq<&TargetHasAtomic> for u64 {
1141 fn eq(&self, &other: &&TargetHasAtomic) -> bool {
1142 other == self
1143 }
1144 }
1145 impl FromStr for TargetHasAtomic {
1146 type Err = crate::Error;
1147 fn from_str(s: &str) -> Result<Self, Self::Err> {
1148 match s {
1149 "128" => Ok(Self(TargetHasAtomicRepr::_128)),
1150 "16" => Ok(Self(TargetHasAtomicRepr::_16)),
1151 "32" => Ok(Self(TargetHasAtomicRepr::_32)),
1152 "64" => Ok(Self(TargetHasAtomicRepr::_64)),
1153 "8" => Ok(Self(TargetHasAtomicRepr::_8)),
1154 "ptr" => Ok(Self(TargetHasAtomicRepr::ptr)),
1155 s => Ok(Self(TargetHasAtomicRepr::__Other(s.into()))),
1156 }
1157 }
1158 }
1159 impl Cfg for TargetHasAtomic {
1160 type Output = Vec<Self>;
1161 const KEY: &'static str = "target_has_atomic";
1162 type Error = crate::Error;
1163 const MAX: usize = usize::MAX;
1164 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
1165 values: I,
1166 ) -> Result<Self::Output, Self::Error> {
1167 let mut res = Vec::with_capacity(values.len());
1168 for value in values {
1169 res.push(value.as_ref().parse()?);
1170 }
1171 Ok(res)
1172 }
1173 fn default_output() -> Option<Self::Output> {
1174 Some(vec![])
1175 }
1176 }
1177 impl fmt::Debug for TargetHasAtomic {
1178 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1179 fmt::Debug::fmt(self.as_str(), f)
1180 }
1181 }
1182 impl fmt::Display for TargetHasAtomic {
1183 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1184 f.write_str(self.as_str())
1185 }
1186 }
1187
1188 /// `cfg(target_os == "..")`
1189 ///
1190 /// All non-empty values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
1191 /// to 1.97 are available as variants. To construct other values, use
1192 /// `TargetOs::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
1193 #[derive(Clone)]
1194 #[non_exhaustive]
1195 pub enum TargetOs {
1196 aix,
1197 amdhsa,
1198 android,
1199 bitrig,
1200 cloudabi,
1201 cuda,
1202 cygwin,
1203 dragonfly,
1204 emscripten,
1205 espidf,
1206 freebsd,
1207 fuchsia,
1208 haiku,
1209 helenos,
1210 hermit,
1211 horizon,
1212 hurd,
1213 illumos,
1214 ios,
1215 l4re,
1216 linux,
1217 lynxos178,
1218 macos,
1219 managarm,
1220 motor,
1221 nacl,
1222 netbsd,
1223 none,
1224 nto,
1225 nuttx,
1226 openbsd,
1227 psp,
1228 psx,
1229 qurt,
1230 redox,
1231 rtems,
1232 solaris,
1233 solid_asp3,
1234 teeos,
1235 trusty,
1236 tvos,
1237 uefi,
1238 unknown,
1239 vexos,
1240 visionos,
1241 vita,
1242 vxworks,
1243 wasi,
1244 watchos,
1245 windows,
1246 xous,
1247 zkvm,
1248 #[doc(hidden)]
1249 #[deprecated(note = "do not use this variant directly; use as_str or compare with a string instead")]
1250 __Other(Box<str>),
1251 }
1252 impl TargetOs {
1253 #[must_use]
1254 pub const fn as_str(&self) -> &str {
1255 match self {
1256 Self::aix => "aix",
1257 Self::amdhsa => "amdhsa",
1258 Self::android => "android",
1259 Self::bitrig => "bitrig",
1260 Self::cloudabi => "cloudabi",
1261 Self::cuda => "cuda",
1262 Self::cygwin => "cygwin",
1263 Self::dragonfly => "dragonfly",
1264 Self::emscripten => "emscripten",
1265 Self::espidf => "espidf",
1266 Self::freebsd => "freebsd",
1267 Self::fuchsia => "fuchsia",
1268 Self::haiku => "haiku",
1269 Self::helenos => "helenos",
1270 Self::hermit => "hermit",
1271 Self::horizon => "horizon",
1272 Self::hurd => "hurd",
1273 Self::illumos => "illumos",
1274 Self::ios => "ios",
1275 Self::l4re => "l4re",
1276 Self::linux => "linux",
1277 Self::lynxos178 => "lynxos178",
1278 Self::macos => "macos",
1279 Self::managarm => "managarm",
1280 Self::motor => "motor",
1281 Self::nacl => "nacl",
1282 Self::netbsd => "netbsd",
1283 Self::none => "none",
1284 Self::nto => "nto",
1285 Self::nuttx => "nuttx",
1286 Self::openbsd => "openbsd",
1287 Self::psp => "psp",
1288 Self::psx => "psx",
1289 Self::qurt => "qurt",
1290 Self::redox => "redox",
1291 Self::rtems => "rtems",
1292 Self::solaris => "solaris",
1293 Self::solid_asp3 => "solid_asp3",
1294 Self::teeos => "teeos",
1295 Self::trusty => "trusty",
1296 Self::tvos => "tvos",
1297 Self::uefi => "uefi",
1298 Self::unknown => "unknown",
1299 Self::vexos => "vexos",
1300 Self::visionos => "visionos",
1301 Self::vita => "vita",
1302 Self::vxworks => "vxworks",
1303 Self::wasi => "wasi",
1304 Self::watchos => "watchos",
1305 Self::windows => "windows",
1306 Self::xous => "xous",
1307 Self::zkvm => "zkvm",
1308 #[allow(deprecated)]
1309 Self::__Other(s) => s,
1310 }
1311 }
1312 }
1313 impl PartialEq for TargetOs {
1314 fn eq(&self, other: &Self) -> bool {
1315 match (self, other) {
1316 // Even after new variants are added, to ensure comparisons in old
1317 // code using __Other still work, compare strings if either is __Other.
1318 #[allow(deprecated)]
1319 (Self::__Other(_), _) | (_, Self::__Other(_)) => self.as_str() == other.as_str(),
1320 (this, other) => mem::discriminant(this) == mem::discriminant(other),
1321 }
1322 }
1323 }
1324 impl Eq for TargetOs {}
1325 impl PartialEq<str> for TargetOs {
1326 fn eq(&self, other: &str) -> bool {
1327 *self.as_str() == *other
1328 }
1329 }
1330 impl PartialEq<&str> for TargetOs {
1331 fn eq(&self, &other: &&str) -> bool {
1332 *self.as_str() == *other
1333 }
1334 }
1335 impl PartialEq<TargetOs> for str {
1336 fn eq(&self, other: &TargetOs) -> bool {
1337 *self == *other.as_str()
1338 }
1339 }
1340 impl PartialEq<TargetOs> for &str {
1341 fn eq(&self, other: &TargetOs) -> bool {
1342 **self == *other.as_str()
1343 }
1344 }
1345 impl PartialEq<String> for TargetOs {
1346 fn eq(&self, other: &String) -> bool {
1347 *self.as_str() == **other
1348 }
1349 }
1350 impl PartialEq<&String> for TargetOs {
1351 fn eq(&self, &other: &&String) -> bool {
1352 *self.as_str() == **other
1353 }
1354 }
1355 impl PartialEq<TargetOs> for String {
1356 fn eq(&self, other: &TargetOs) -> bool {
1357 **self == *other.as_str()
1358 }
1359 }
1360 impl PartialEq<TargetOs> for &String {
1361 fn eq(&self, other: &TargetOs) -> bool {
1362 ***self == *other.as_str()
1363 }
1364 }
1365 impl PartialEq<Box<str>> for TargetOs {
1366 fn eq(&self, other: &Box<str>) -> bool {
1367 *self.as_str() == **other
1368 }
1369 }
1370 impl PartialEq<&Box<str>> for TargetOs {
1371 fn eq(&self, &other: &&Box<str>) -> bool {
1372 *self.as_str() == **other
1373 }
1374 }
1375 impl PartialEq<TargetOs> for Box<str> {
1376 fn eq(&self, other: &TargetOs) -> bool {
1377 **self == *other.as_str()
1378 }
1379 }
1380 impl PartialEq<TargetOs> for &Box<str> {
1381 fn eq(&self, other: &TargetOs) -> bool {
1382 ***self == *other.as_str()
1383 }
1384 }
1385 impl From<&str> for TargetOs {
1386 fn from(s: &str) -> Self {
1387 match Self::from_str(s) {
1388 Ok(s) => s,
1389 Err(e) => match e {},
1390 }
1391 }
1392 }
1393 impl FromStr for TargetOs {
1394 type Err = core::convert::Infallible;
1395 fn from_str(s: &str) -> Result<Self, Self::Err> {
1396 match s {
1397 "aix" => Ok(Self::aix),
1398 "amdhsa" => Ok(Self::amdhsa),
1399 "android" => Ok(Self::android),
1400 "bitrig" => Ok(Self::bitrig),
1401 "cloudabi" => Ok(Self::cloudabi),
1402 "cuda" => Ok(Self::cuda),
1403 "cygwin" => Ok(Self::cygwin),
1404 "dragonfly" => Ok(Self::dragonfly),
1405 "emscripten" => Ok(Self::emscripten),
1406 "espidf" => Ok(Self::espidf),
1407 "freebsd" => Ok(Self::freebsd),
1408 "fuchsia" => Ok(Self::fuchsia),
1409 "haiku" => Ok(Self::haiku),
1410 "helenos" => Ok(Self::helenos),
1411 "hermit" => Ok(Self::hermit),
1412 "horizon" => Ok(Self::horizon),
1413 "hurd" => Ok(Self::hurd),
1414 "illumos" => Ok(Self::illumos),
1415 "ios" => Ok(Self::ios),
1416 "l4re" => Ok(Self::l4re),
1417 "linux" => Ok(Self::linux),
1418 "lynxos178" => Ok(Self::lynxos178),
1419 "macos" => Ok(Self::macos),
1420 "managarm" => Ok(Self::managarm),
1421 "motor" => Ok(Self::motor),
1422 "nacl" => Ok(Self::nacl),
1423 "netbsd" => Ok(Self::netbsd),
1424 "none" => Ok(Self::none),
1425 "nto" => Ok(Self::nto),
1426 "nuttx" => Ok(Self::nuttx),
1427 "openbsd" => Ok(Self::openbsd),
1428 "psp" => Ok(Self::psp),
1429 "psx" => Ok(Self::psx),
1430 "qurt" => Ok(Self::qurt),
1431 "redox" => Ok(Self::redox),
1432 "rtems" => Ok(Self::rtems),
1433 "solaris" => Ok(Self::solaris),
1434 "solid_asp3" => Ok(Self::solid_asp3),
1435 "teeos" => Ok(Self::teeos),
1436 "trusty" => Ok(Self::trusty),
1437 "tvos" => Ok(Self::tvos),
1438 "uefi" => Ok(Self::uefi),
1439 "unknown" => Ok(Self::unknown),
1440 "vexos" => Ok(Self::vexos),
1441 "visionos" => Ok(Self::visionos),
1442 "vita" => Ok(Self::vita),
1443 "vxworks" => Ok(Self::vxworks),
1444 "wasi" => Ok(Self::wasi),
1445 "watchos" => Ok(Self::watchos),
1446 "windows" => Ok(Self::windows),
1447 "xous" => Ok(Self::xous),
1448 "zkvm" => Ok(Self::zkvm),
1449 #[allow(deprecated)]
1450 s => Ok(Self::__Other(s.into())),
1451 }
1452 }
1453 }
1454 impl Cfg for TargetOs {
1455 type Output = Self;
1456 const KEY: &'static str = "target_os";
1457 type Error = core::convert::Infallible;
1458 const MAX: usize = 1;
1459 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
1460 mut values: I,
1461 ) -> Result<Self::Output, Self::Error> {
1462 values.next().unwrap().as_ref().parse()
1463 }
1464 fn default_output() -> Option<Self::Output> {
1465 None
1466 }
1467 }
1468 impl fmt::Debug for TargetOs {
1469 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1470 fmt::Debug::fmt(self.as_str(), f)
1471 }
1472 }
1473 impl fmt::Display for TargetOs {
1474 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1475 f.write_str(self.as_str())
1476 }
1477 }
1478
1479 /// `cfg(target_pointer_width == "..")`
1480 ///
1481 /// All values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
1482 /// to 1.97 are constructable without allocation. To construct values, use
1483 /// `TargetPointerWidth::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
1484 #[derive(Clone)]
1485 pub struct TargetPointerWidth(TargetPointerWidthRepr);
1486 #[derive(Clone)]
1487 enum TargetPointerWidthRepr {
1488 _16,
1489 _32,
1490 _64,
1491 __Other(Box<str>),
1492 }
1493 impl TargetPointerWidth {
1494 #[must_use]
1495 pub const fn as_str(&self) -> &str {
1496 match &self.0 {
1497 TargetPointerWidthRepr::_16 => "16",
1498 TargetPointerWidthRepr::_32 => "32",
1499 TargetPointerWidthRepr::_64 => "64",
1500 TargetPointerWidthRepr::__Other(s) => s,
1501 }
1502 }
1503 }
1504 impl PartialEq for TargetPointerWidth {
1505 fn eq(&self, other: &Self) -> bool {
1506 match (&self.0, &other.0) {
1507 // Even after new variants are added, to ensure comparisons in old
1508 // code using __Other still work, compare strings if either is __Other.
1509 (TargetPointerWidthRepr::__Other(_), _) | (_, TargetPointerWidthRepr::__Other(_)) => self.as_str() == other.as_str(),
1510 (this, other) => mem::discriminant(this) == mem::discriminant(other),
1511 }
1512 }
1513 }
1514 impl Eq for TargetPointerWidth {}
1515 impl PartialEq<str> for TargetPointerWidth {
1516 fn eq(&self, other: &str) -> bool {
1517 *self.as_str() == *other
1518 }
1519 }
1520 impl PartialEq<&str> for TargetPointerWidth {
1521 fn eq(&self, &other: &&str) -> bool {
1522 *self.as_str() == *other
1523 }
1524 }
1525 impl PartialEq<TargetPointerWidth> for str {
1526 fn eq(&self, other: &TargetPointerWidth) -> bool {
1527 *self == *other.as_str()
1528 }
1529 }
1530 impl PartialEq<TargetPointerWidth> for &str {
1531 fn eq(&self, other: &TargetPointerWidth) -> bool {
1532 **self == *other.as_str()
1533 }
1534 }
1535 impl PartialEq<String> for TargetPointerWidth {
1536 fn eq(&self, other: &String) -> bool {
1537 *self.as_str() == **other
1538 }
1539 }
1540 impl PartialEq<&String> for TargetPointerWidth {
1541 fn eq(&self, &other: &&String) -> bool {
1542 *self.as_str() == **other
1543 }
1544 }
1545 impl PartialEq<TargetPointerWidth> for String {
1546 fn eq(&self, other: &TargetPointerWidth) -> bool {
1547 **self == *other.as_str()
1548 }
1549 }
1550 impl PartialEq<TargetPointerWidth> for &String {
1551 fn eq(&self, other: &TargetPointerWidth) -> bool {
1552 ***self == *other.as_str()
1553 }
1554 }
1555 impl PartialEq<Box<str>> for TargetPointerWidth {
1556 fn eq(&self, other: &Box<str>) -> bool {
1557 *self.as_str() == **other
1558 }
1559 }
1560 impl PartialEq<&Box<str>> for TargetPointerWidth {
1561 fn eq(&self, &other: &&Box<str>) -> bool {
1562 *self.as_str() == **other
1563 }
1564 }
1565 impl PartialEq<TargetPointerWidth> for Box<str> {
1566 fn eq(&self, other: &TargetPointerWidth) -> bool {
1567 **self == *other.as_str()
1568 }
1569 }
1570 impl PartialEq<TargetPointerWidth> for &Box<str> {
1571 fn eq(&self, other: &TargetPointerWidth) -> bool {
1572 ***self == *other.as_str()
1573 }
1574 }
1575 impl PartialEq<u16> for TargetPointerWidth {
1576 fn eq(&self, other: &u16) -> bool {
1577 match &self.0 {
1578 TargetPointerWidthRepr::_16 => 16 == *other,
1579 TargetPointerWidthRepr::_32 => 32 == *other,
1580 TargetPointerWidthRepr::_64 => 64 == *other,
1581 TargetPointerWidthRepr::__Other(this) => this.parse().ok() == Some(*other),
1582 }
1583 }
1584 }
1585 impl PartialEq<u16> for &TargetPointerWidth {
1586 fn eq(&self, other: &u16) -> bool {
1587 *self == other
1588 }
1589 }
1590 impl PartialEq<TargetPointerWidth> for u16 {
1591 fn eq(&self, other: &TargetPointerWidth) -> bool {
1592 other == self
1593 }
1594 }
1595 impl PartialEq<&TargetPointerWidth> for u16 {
1596 fn eq(&self, &other: &&TargetPointerWidth) -> bool {
1597 other == self
1598 }
1599 }
1600 impl PartialEq<i32> for TargetPointerWidth {
1601 fn eq(&self, other: &i32) -> bool {
1602 match &self.0 {
1603 TargetPointerWidthRepr::_16 => 16 == *other,
1604 TargetPointerWidthRepr::_32 => 32 == *other,
1605 TargetPointerWidthRepr::_64 => 64 == *other,
1606 TargetPointerWidthRepr::__Other(this) => this.parse().ok() == Some(*other),
1607 }
1608 }
1609 }
1610 impl PartialEq<i32> for &TargetPointerWidth {
1611 fn eq(&self, other: &i32) -> bool {
1612 *self == other
1613 }
1614 }
1615 impl PartialEq<TargetPointerWidth> for i32 {
1616 fn eq(&self, other: &TargetPointerWidth) -> bool {
1617 other == self
1618 }
1619 }
1620 impl PartialEq<&TargetPointerWidth> for i32 {
1621 fn eq(&self, &other: &&TargetPointerWidth) -> bool {
1622 other == self
1623 }
1624 }
1625 impl PartialEq<u32> for TargetPointerWidth {
1626 fn eq(&self, other: &u32) -> bool {
1627 match &self.0 {
1628 TargetPointerWidthRepr::_16 => 16 == *other,
1629 TargetPointerWidthRepr::_32 => 32 == *other,
1630 TargetPointerWidthRepr::_64 => 64 == *other,
1631 TargetPointerWidthRepr::__Other(this) => this.parse().ok() == Some(*other),
1632 }
1633 }
1634 }
1635 impl PartialEq<u32> for &TargetPointerWidth {
1636 fn eq(&self, other: &u32) -> bool {
1637 *self == other
1638 }
1639 }
1640 impl PartialEq<TargetPointerWidth> for u32 {
1641 fn eq(&self, other: &TargetPointerWidth) -> bool {
1642 other == self
1643 }
1644 }
1645 impl PartialEq<&TargetPointerWidth> for u32 {
1646 fn eq(&self, &other: &&TargetPointerWidth) -> bool {
1647 other == self
1648 }
1649 }
1650 impl PartialEq<u64> for TargetPointerWidth {
1651 fn eq(&self, other: &u64) -> bool {
1652 match &self.0 {
1653 TargetPointerWidthRepr::_16 => 16 == *other,
1654 TargetPointerWidthRepr::_32 => 32 == *other,
1655 TargetPointerWidthRepr::_64 => 64 == *other,
1656 TargetPointerWidthRepr::__Other(this) => this.parse().ok() == Some(*other),
1657 }
1658 }
1659 }
1660 impl PartialEq<u64> for &TargetPointerWidth {
1661 fn eq(&self, other: &u64) -> bool {
1662 *self == other
1663 }
1664 }
1665 impl PartialEq<TargetPointerWidth> for u64 {
1666 fn eq(&self, other: &TargetPointerWidth) -> bool {
1667 other == self
1668 }
1669 }
1670 impl PartialEq<&TargetPointerWidth> for u64 {
1671 fn eq(&self, &other: &&TargetPointerWidth) -> bool {
1672 other == self
1673 }
1674 }
1675 impl FromStr for TargetPointerWidth {
1676 type Err = crate::Error;
1677 fn from_str(s: &str) -> Result<Self, Self::Err> {
1678 match s {
1679 "16" => Ok(Self(TargetPointerWidthRepr::_16)),
1680 "32" => Ok(Self(TargetPointerWidthRepr::_32)),
1681 "64" => Ok(Self(TargetPointerWidthRepr::_64)),
1682 s => Ok(Self(TargetPointerWidthRepr::__Other(s.into()))),
1683 }
1684 }
1685 }
1686 impl Cfg for TargetPointerWidth {
1687 type Output = Self;
1688 const KEY: &'static str = "target_pointer_width";
1689 type Error = crate::Error;
1690 const MAX: usize = 1;
1691 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
1692 mut values: I,
1693 ) -> Result<Self::Output, Self::Error> {
1694 values.next().unwrap().as_ref().parse()
1695 }
1696 fn default_output() -> Option<Self::Output> {
1697 None
1698 }
1699 }
1700 impl fmt::Debug for TargetPointerWidth {
1701 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1702 fmt::Debug::fmt(self.as_str(), f)
1703 }
1704 }
1705 impl fmt::Display for TargetPointerWidth {
1706 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1707 f.write_str(self.as_str())
1708 }
1709 }
1710
1711 /// `cfg(target_vendor == "..")`
1712 /// (Rust 1.33+)
1713 ///
1714 /// All non-empty values used in builtin targets in 1.8 (where `rustc --print cfg` was added)
1715 /// to 1.97 are available as variants. To construct other values, use
1716 /// `TargetVendor::from`/`.into()`; to reference them, use `.as_str()` or comparison to `&str`.
1717 #[derive(Clone)]
1718 #[non_exhaustive]
1719 pub enum TargetVendor {
1720 amd,
1721 apple,
1722 espressif,
1723 fortanix,
1724 ibm,
1725 kmc,
1726 mti,
1727 nintendo,
1728 nvidia,
1729 openwrt,
1730 pc,
1731 risc0,
1732 rumprun,
1733 sony,
1734 sun,
1735 unikraft,
1736 unknown,
1737 uwp,
1738 vex,
1739 win7,
1740 wrs,
1741 #[doc(hidden)]
1742 #[deprecated(note = "do not use this variant directly; use as_str or compare with a string instead")]
1743 __Other(Box<str>),
1744 }
1745 impl TargetVendor {
1746 #[must_use]
1747 pub const fn as_str(&self) -> &str {
1748 match self {
1749 Self::amd => "amd",
1750 Self::apple => "apple",
1751 Self::espressif => "espressif",
1752 Self::fortanix => "fortanix",
1753 Self::ibm => "ibm",
1754 Self::kmc => "kmc",
1755 Self::mti => "mti",
1756 Self::nintendo => "nintendo",
1757 Self::nvidia => "nvidia",
1758 Self::openwrt => "openwrt",
1759 Self::pc => "pc",
1760 Self::risc0 => "risc0",
1761 Self::rumprun => "rumprun",
1762 Self::sony => "sony",
1763 Self::sun => "sun",
1764 Self::unikraft => "unikraft",
1765 Self::unknown => "unknown",
1766 Self::uwp => "uwp",
1767 Self::vex => "vex",
1768 Self::win7 => "win7",
1769 Self::wrs => "wrs",
1770 #[allow(deprecated)]
1771 Self::__Other(s) => s,
1772 }
1773 }
1774 }
1775 impl PartialEq for TargetVendor {
1776 fn eq(&self, other: &Self) -> bool {
1777 match (self, other) {
1778 // Even after new variants are added, to ensure comparisons in old
1779 // code using __Other still work, compare strings if either is __Other.
1780 #[allow(deprecated)]
1781 (Self::__Other(_), _) | (_, Self::__Other(_)) => self.as_str() == other.as_str(),
1782 (this, other) => mem::discriminant(this) == mem::discriminant(other),
1783 }
1784 }
1785 }
1786 impl Eq for TargetVendor {}
1787 impl PartialEq<str> for TargetVendor {
1788 fn eq(&self, other: &str) -> bool {
1789 *self.as_str() == *other
1790 }
1791 }
1792 impl PartialEq<&str> for TargetVendor {
1793 fn eq(&self, &other: &&str) -> bool {
1794 *self.as_str() == *other
1795 }
1796 }
1797 impl PartialEq<TargetVendor> for str {
1798 fn eq(&self, other: &TargetVendor) -> bool {
1799 *self == *other.as_str()
1800 }
1801 }
1802 impl PartialEq<TargetVendor> for &str {
1803 fn eq(&self, other: &TargetVendor) -> bool {
1804 **self == *other.as_str()
1805 }
1806 }
1807 impl PartialEq<String> for TargetVendor {
1808 fn eq(&self, other: &String) -> bool {
1809 *self.as_str() == **other
1810 }
1811 }
1812 impl PartialEq<&String> for TargetVendor {
1813 fn eq(&self, &other: &&String) -> bool {
1814 *self.as_str() == **other
1815 }
1816 }
1817 impl PartialEq<TargetVendor> for String {
1818 fn eq(&self, other: &TargetVendor) -> bool {
1819 **self == *other.as_str()
1820 }
1821 }
1822 impl PartialEq<TargetVendor> for &String {
1823 fn eq(&self, other: &TargetVendor) -> bool {
1824 ***self == *other.as_str()
1825 }
1826 }
1827 impl PartialEq<Box<str>> for TargetVendor {
1828 fn eq(&self, other: &Box<str>) -> bool {
1829 *self.as_str() == **other
1830 }
1831 }
1832 impl PartialEq<&Box<str>> for TargetVendor {
1833 fn eq(&self, &other: &&Box<str>) -> bool {
1834 *self.as_str() == **other
1835 }
1836 }
1837 impl PartialEq<TargetVendor> for Box<str> {
1838 fn eq(&self, other: &TargetVendor) -> bool {
1839 **self == *other.as_str()
1840 }
1841 }
1842 impl PartialEq<TargetVendor> for &Box<str> {
1843 fn eq(&self, other: &TargetVendor) -> bool {
1844 ***self == *other.as_str()
1845 }
1846 }
1847 impl From<&str> for TargetVendor {
1848 fn from(s: &str) -> Self {
1849 match Self::from_str(s) {
1850 Ok(s) => s,
1851 Err(e) => match e {},
1852 }
1853 }
1854 }
1855 impl FromStr for TargetVendor {
1856 type Err = core::convert::Infallible;
1857 fn from_str(s: &str) -> Result<Self, Self::Err> {
1858 match s {
1859 "amd" => Ok(Self::amd),
1860 "apple" => Ok(Self::apple),
1861 "espressif" => Ok(Self::espressif),
1862 "fortanix" => Ok(Self::fortanix),
1863 "ibm" => Ok(Self::ibm),
1864 "kmc" => Ok(Self::kmc),
1865 "mti" => Ok(Self::mti),
1866 "nintendo" => Ok(Self::nintendo),
1867 "nvidia" => Ok(Self::nvidia),
1868 "openwrt" => Ok(Self::openwrt),
1869 "pc" => Ok(Self::pc),
1870 "risc0" => Ok(Self::risc0),
1871 "rumprun" => Ok(Self::rumprun),
1872 "sony" => Ok(Self::sony),
1873 "sun" => Ok(Self::sun),
1874 "unikraft" => Ok(Self::unikraft),
1875 "unknown" => Ok(Self::unknown),
1876 "uwp" => Ok(Self::uwp),
1877 "vex" => Ok(Self::vex),
1878 "win7" => Ok(Self::win7),
1879 "wrs" => Ok(Self::wrs),
1880 #[allow(deprecated)]
1881 s => Ok(Self::__Other(s.into())),
1882 }
1883 }
1884 }
1885 impl Cfg for TargetVendor {
1886 type Output = Option<Self>;
1887 const KEY: &'static str = "target_vendor";
1888 type Error = core::convert::Infallible;
1889 const MAX: usize = 1;
1890 fn from_values<I: ExactSizeIterator<Item = V>, V: AsRef<str>>(
1891 mut values: I,
1892 ) -> Result<Self::Output, Self::Error> {
1893 Ok(Some(values.next().unwrap().as_ref().parse()?))
1894 }
1895 fn default_output() -> Option<Self::Output> {
1896 Some(None)
1897 }
1898 }
1899 impl fmt::Debug for TargetVendor {
1900 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1901 fmt::Debug::fmt(self.as_str(), f)
1902 }
1903 }
1904 impl fmt::Display for TargetVendor {
1905 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1906 f.write_str(self.as_str())
1907 }
1908 }