charon_lib/ast/from_rustc.rs
1// This file is automatically generated by `cargo run --bin generate-asts`.
2// Do not edit it by hand.
3
4#![allow(
5 clippy::doc_lazy_continuation,
6 clippy::enum_variant_names,
7 clippy::large_enum_variant
8)]
9
10use crate::ast::meta::Span;
11use derive_generic_visitor::{Drive, DriveMut, DriveTwo};
12use serde::{Deserialize, Serialize};
13use ustr::Ustr;
14
15#[derive(Debug, Copy, Clone, PartialEq, Eq)]
16pub struct FromRustcError;
17
18/// Represents parsed *built-in* inert attributes.
19///
20/// ## Overview
21/// These attributes are markers that guide the compilation process and are never expanded into other code.
22/// They persist throughout the compilation phases, from AST to HIR and beyond.
23///
24/// ## Attribute Processing
25/// While attributes are initially parsed by [`rustc_parse`] into [`ast::Attribute`], they still contain raw token streams
26/// because different attributes have different internal structures. This enum represents the final,
27/// fully parsed form of these attributes, where each variant contains all the information and
28/// structure relevant for the specific attribute.
29///
30/// Some attributes can be applied multiple times to the same item, and they are "collapsed" into a single
31/// semantic attribute. For example:
32/// ```rust
33/// #[repr(C)]
34/// #[repr(packed)]
35/// struct S { }
36/// ```
37/// This is equivalent to `#[repr(C, packed)]` and results in a single [`AttributeKind::Repr`] containing
38/// both `C` and `packed` annotations. This collapsing happens during parsing and is reflected in the
39/// data structures defined in this enum.
40///
41/// ## Usage
42/// These parsed attributes are used throughout the compiler to:
43/// - Control code generation (e.g., `#[repr]`)
44/// - Mark API stability (`#[stable]`, `#[unstable]`)
45/// - Provide documentation (`#[doc]`)
46/// - Guide compiler behavior (e.g., `#[allow_internal_unstable]`)
47///
48/// ## Note on Attribute Organization
49/// Some attributes like `InlineAttr`, `OptimizeAttr`, and `InstructionSetAttr` are defined separately
50/// from this enum because they are used in specific compiler phases (like code generation) and don't
51/// need to persist throughout the entire compilation process. They are typically processed and
52/// converted into their final form earlier in the compilation pipeline.
53///
54/// For example:
55/// - `InlineAttr` is used during code generation to control function inlining
56/// - `OptimizeAttr` is used to control optimization levels
57/// - `InstructionSetAttr` is used for target-specific code generation
58///
59/// These attributes are handled by their respective compiler passes in the [`rustc_codegen_ssa`] crate
60/// and don't need to be preserved in the same way as the attributes in this enum.
61///
62/// For more details on attribute parsing, see the [`rustc_attr_parsing`] crate.
63///
64/// [`rustc_parse`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html
65/// [`rustc_codegen_ssa`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/index.html
66/// [`rustc_attr_parsing`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html
67#[derive(Debug, Clone, PartialEq, Eq)]
68#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
69#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcAttributeKind"))]
70#[cfg_attr(
71 feature = "charon_on_charon",
72 charon::variants_prefix("RustcAttributeKind")
73)]
74pub enum AttributeKind {
75 /// Represents `#[automatically_derived]`
76 AutomaticallyDerived,
77 /// Represents `#[cold]`.
78 Cold,
79 /// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
80 Deprecated {
81 deprecation: Deprecation,
82 span: Span,
83 },
84 /// Represents [`#[export_name]`](https://doc.rust-lang.org/reference/abi.html#the-export_name-attribute).
85 ExportName {
86 /// The name to export this item with.
87 /// It may not contain \0 bytes as it will be converted to a null-terminated string.
88 name: Ustr,
89 span: Span,
90 },
91 /// Represents `#[fundamental]`.
92 Fundamental,
93 /// Represents `#[ignore]`
94 Ignore {
95 span: Span,
96 /// ignore can optionally have a reason: `#[ignore = "reason this is ignored"]`
97 reason: Option<Ustr>,
98 },
99 /// Represents `#[inline]` and `#[rustc_force_inline]`.
100 Inline(InlineAttr, Span),
101 /// Represents [`#[link_section]`](https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute)
102 LinkSection { name: Ustr },
103 /// Represents `#[linkage]`.
104 Linkage(Linkage, Span),
105 /// Represents [`#[may_dangle]`](https://std-dev-guide.rust-lang.org/tricky/may-dangle.html).
106 MayDangle(Span),
107 /// Represents `#[naked]`
108 Naked(Span),
109 /// Represents `#[no_link]`
110 NoLink,
111 /// Represents `#[no_mangle]`
112 NoMangle(Span),
113 /// Represents `#[non_exhaustive]`
114 NonExhaustive(Span),
115 /// Represents `#[optimize(size|speed)]`
116 Optimize(OptimizeAttr, Span),
117 /// Represents `#[align(N)]`.
118 RustcAlign { align: u64, span: Span },
119 /// Represents `#[rustc_allocator]`
120 RustcAllocator,
121 /// Represents `#[rustc_allocator_zeroed]`
122 RustcAllocatorZeroed,
123 /// Represents `#[rustc_allocator_zeroed_variant]`
124 RustcAllocatorZeroedVariant { name: Ustr },
125 /// Represents `#[rustc_deallocator]`
126 RustcDeallocator,
127 /// Represents `#[rustc_intrinsic]`
128 RustcIntrinsic,
129 /// Represents `#[rustc_no_writable]`
130 RustcNoWritable,
131 /// Represents `#[rustc_reallocator]`
132 RustcReallocator,
133 /// Represents `#[should_panic]`
134 ShouldPanic { reason: Option<Ustr> },
135 /// Represents `#[target_feature(enable = "...")]` and
136 /// `#[unsafe(force_target_feature(enable = "...")]`.
137 TargetFeature {
138 features: Vec<(Ustr, Span)>,
139 attr_span: Span,
140 was_forced: bool,
141 },
142 /// Represents `#[track_caller]`
143 TrackCaller(Span),
144}
145
146/// A representation of all the valid lang items in Rust.
147#[derive(Debug, Clone, PartialEq, Eq)]
148#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
149#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcLangItem"))]
150#[cfg_attr(feature = "charon_on_charon", charon::variants_prefix("RustcLangItem"))]
151pub enum LangItem {
152 ///The `sized` lang item.
153 Sized,
154 ///The `meta_sized` lang item.
155 MetaSized,
156 ///The `pointee_sized` lang item.
157 PointeeSized,
158 ///The `unsize` lang item.
159 Unsize,
160 ///The `mem_align_const` lang item.
161 AlignOf,
162 ///The `mem_size_const` lang item.
163 SizeOf,
164 ///The `offset_of` lang item.
165 OffsetOf,
166 ///The `structural_peq` lang item.
167 /// Trait injected by `#[derive(PartialEq)]`, (i.e. "Partial EQ").
168 StructuralPeq,
169 ///The `copy` lang item.
170 Copy,
171 ///The `clone` lang item.
172 Clone,
173 ///The `clone_fn` lang item.
174 CloneFn,
175 ///The `use_cloned` lang item.
176 UseCloned,
177 ///The `trivial_clone` lang item.
178 TrivialClone,
179 ///The `sync` lang item.
180 Sync,
181 ///The `discriminant_kind` lang item.
182 DiscriminantKind,
183 ///The `discriminant_type` lang item.
184 /// The associated item of the `DiscriminantKind` trait.
185 Discriminant,
186 ///The `pointee_trait` lang item.
187 PointeeTrait,
188 ///The `metadata_type` lang item.
189 Metadata,
190 ///The `dyn_metadata` lang item.
191 DynMetadata,
192 ///The `non_null` lang item.
193 NonNull,
194 ///The `freeze` lang item.
195 Freeze,
196 ///The `unsafe_unpin` lang item.
197 UnsafeUnpin,
198 ///The `fn_ptr_trait` lang item.
199 FnPtrTrait,
200 ///The `fn_ptr_as_ptr` lang item.
201 FnPtrAsPtr,
202 ///The `fn_ptr_from_ptr` lang item.
203 FnPtrFromPtr,
204 ///The `code` lang item.
205 Code,
206 ///The `drop` lang item.
207 Drop,
208 ///The `destruct` lang item.
209 Destruct,
210 ///The `async_drop` lang item.
211 AsyncDrop,
212 ///The `async_drop_in_place` lang item.
213 AsyncDropInPlace,
214 ///The `coerce_unsized` lang item.
215 CoerceUnsized,
216 ///The `dispatch_from_dyn` lang item.
217 DispatchFromDyn,
218 ///The `try_as_dyn` lang item.
219 TryAsDyn,
220 ///The `transmute_opts` lang item.
221 TransmuteOpts,
222 ///The `transmute_trait` lang item.
223 TransmuteTrait,
224 ///The `add` lang item.
225 Add,
226 ///The `sub` lang item.
227 Sub,
228 ///The `mul` lang item.
229 Mul,
230 ///The `div` lang item.
231 Div,
232 ///The `rem` lang item.
233 Rem,
234 ///The `neg` lang item.
235 Neg,
236 ///The `not` lang item.
237 Not,
238 ///The `bitxor` lang item.
239 BitXor,
240 ///The `bitand` lang item.
241 BitAnd,
242 ///The `bitor` lang item.
243 BitOr,
244 ///The `shl` lang item.
245 Shl,
246 ///The `shr` lang item.
247 Shr,
248 ///The `add_assign` lang item.
249 AddAssign,
250 ///The `sub_assign` lang item.
251 SubAssign,
252 ///The `mul_assign` lang item.
253 MulAssign,
254 ///The `div_assign` lang item.
255 DivAssign,
256 ///The `rem_assign` lang item.
257 RemAssign,
258 ///The `bitxor_assign` lang item.
259 BitXorAssign,
260 ///The `bitand_assign` lang item.
261 BitAndAssign,
262 ///The `bitor_assign` lang item.
263 BitOrAssign,
264 ///The `shl_assign` lang item.
265 ShlAssign,
266 ///The `shr_assign` lang item.
267 ShrAssign,
268 ///The `index` lang item.
269 Index,
270 ///The `index_mut` lang item.
271 IndexMut,
272 ///The `unsafe_cell` lang item.
273 UnsafeCell,
274 ///The `covariant_unsafe_cell` lang item.
275 CovariantUnsafeCell,
276 ///The `unsafe_pinned` lang item.
277 UnsafePinned,
278 ///The `va_arg_safe` lang item.
279 VaArgSafe,
280 ///The `va_list` lang item.
281 VaList,
282 ///The `complex` lang item.
283 Complex,
284 ///The `deref` lang item.
285 Deref,
286 ///The `deref_mut` lang item.
287 DerefMut,
288 ///The `deref_pure` lang item.
289 DerefPure,
290 ///The `deref_target` lang item.
291 DerefTarget,
292 ///The `receiver` lang item.
293 Receiver,
294 ///The `receiver_target` lang item.
295 ReceiverTarget,
296 ///The `legacy_receiver` lang item.
297 LegacyReceiver,
298 ///The `Fn` lang item.
299 Fn,
300 ///The `fn_mut` lang item.
301 FnMut,
302 ///The `fn_once` lang item.
303 FnOnce,
304 ///The `fn_static` lang item.
305 FnStatic,
306 ///The `async_fn` lang item.
307 AsyncFn,
308 ///The `async_fn_mut` lang item.
309 AsyncFnMut,
310 ///The `async_fn_once` lang item.
311 AsyncFnOnce,
312 ///The `async_fn_once_output` lang item.
313 AsyncFnOnceOutput,
314 ///The `call_once_future` lang item.
315 CallOnceFuture,
316 ///The `call_ref_future` lang item.
317 CallRefFuture,
318 ///The `async_fn_kind_helper` lang item.
319 AsyncFnKindHelper,
320 ///The `async_fn_kind_upvars` lang item.
321 AsyncFnKindUpvars,
322 ///The `fn_once_output` lang item.
323 FnOnceOutput,
324 ///The `iterator` lang item.
325 Iterator,
326 ///The `fused_iterator` lang item.
327 FusedIterator,
328 ///The `future_trait` lang item.
329 Future,
330 ///The `future_output` lang item.
331 FutureOutput,
332 ///The `async_iterator` lang item.
333 AsyncIterator,
334 ///The `coroutine_state` lang item.
335 CoroutineState,
336 ///The `coroutine` lang item.
337 Coroutine,
338 ///The `coroutine_return` lang item.
339 CoroutineReturn,
340 ///The `coroutine_yield` lang item.
341 CoroutineYield,
342 ///The `coroutine_resume` lang item.
343 CoroutineResume,
344 ///The `unpin` lang item.
345 Unpin,
346 ///The `Pin` lang item.
347 Pin,
348 ///The `Ordering` lang item.
349 OrderingEnum,
350 ///The `eq` lang item.
351 PartialEq,
352 ///The `partial_ord` lang item.
353 PartialOrd,
354 ///The `c_void` lang item.
355 CVoid,
356 ///The `type_info` lang item.
357 Type,
358 ///The `type_info_generic` lang item.
359 TypeGeneric,
360 ///The `type_id` lang item.
361 TypeId,
362 ///The `panic` lang item.
363 Panic,
364 ///The `panic_nounwind` lang item.
365 PanicNounwind,
366 ///The `panic_fmt` lang item.
367 PanicFmt,
368 ///The `panic_display` lang item.
369 PanicDisplay,
370 ///The `const_panic_fmt` lang item.
371 ConstPanicFmt,
372 ///The `panic_bounds_check` lang item.
373 PanicBoundsCheck,
374 ///The `panic_misaligned_pointer_dereference` lang item.
375 PanicMisalignedPointerDereference,
376 ///The `panic_info` lang item.
377 PanicInfo,
378 ///The `panic_location` lang item.
379 PanicLocation,
380 ///The `panic_impl` lang item.
381 PanicImpl,
382 ///The `panic_cannot_unwind` lang item.
383 PanicCannotUnwind,
384 ///The `panic_in_cleanup` lang item.
385 PanicInCleanup,
386 ///The `panic_const_add_overflow` lang item.
387 /// Constant panic messages, used for codegen of MIR asserts.
388 PanicAddOverflow,
389 ///The `panic_const_sub_overflow` lang item.
390 PanicSubOverflow,
391 ///The `panic_const_mul_overflow` lang item.
392 PanicMulOverflow,
393 ///The `panic_const_div_overflow` lang item.
394 PanicDivOverflow,
395 ///The `panic_const_rem_overflow` lang item.
396 PanicRemOverflow,
397 ///The `panic_const_neg_overflow` lang item.
398 PanicNegOverflow,
399 ///The `panic_const_shr_overflow` lang item.
400 PanicShrOverflow,
401 ///The `panic_const_shl_overflow` lang item.
402 PanicShlOverflow,
403 ///The `panic_const_div_by_zero` lang item.
404 PanicDivZero,
405 ///The `panic_const_rem_by_zero` lang item.
406 PanicRemZero,
407 ///The `panic_const_coroutine_resumed` lang item.
408 PanicCoroutineResumed,
409 ///The `panic_const_async_fn_resumed` lang item.
410 PanicAsyncFnResumed,
411 ///The `panic_const_async_gen_fn_resumed` lang item.
412 PanicAsyncGenFnResumed,
413 ///The `panic_const_gen_fn_none` lang item.
414 PanicGenFnNone,
415 ///The `panic_const_coroutine_resumed_panic` lang item.
416 PanicCoroutineResumedPanic,
417 ///The `panic_const_async_fn_resumed_panic` lang item.
418 PanicAsyncFnResumedPanic,
419 ///The `panic_const_async_gen_fn_resumed_panic` lang item.
420 PanicAsyncGenFnResumedPanic,
421 ///The `panic_const_gen_fn_none_panic` lang item.
422 PanicGenFnNonePanic,
423 ///The `panic_null_pointer_dereference` lang item.
424 PanicNullPointerDereference,
425 ///The `panic_null_reference_constructed` lang item.
426 PanicNullReferenceConstructed,
427 ///The `panic_invalid_enum_construction` lang item.
428 PanicInvalidEnumConstruction,
429 ///The `panic_const_coroutine_resumed_drop` lang item.
430 PanicCoroutineResumedDrop,
431 ///The `panic_const_async_fn_resumed_drop` lang item.
432 PanicAsyncFnResumedDrop,
433 ///The `panic_const_async_gen_fn_resumed_drop` lang item.
434 PanicAsyncGenFnResumedDrop,
435 ///The `panic_const_gen_fn_none_drop` lang item.
436 PanicGenFnNoneDrop,
437 ///The `begin_panic` lang item.
438 /// libstd panic entry point. Necessary for const eval to be able to catch it
439 BeginPanic,
440 ///The `format_argument` lang item.
441 FormatArgument,
442 ///The `format_arguments` lang item.
443 FormatArguments,
444 ///The `drop_glue` lang item.
445 DropGlue,
446 ///The `alloc_layout` lang item.
447 AllocLayout,
448 ///The `start` lang item.
449 /// For all binary crates without `#![no_main]`, Rust will generate a "main" function.
450 /// The exact name and signature are target-dependent. The "main" function will invoke
451 /// this lang item, passing it the `argc` and `argv` (or null, if those don't exist
452 /// on the current target) as well as the user-defined `fn main` from the binary crate.
453 Start,
454 ///The `eh_personality` lang item.
455 EhPersonality,
456 ///The `compiler_move` lang item.
457 CompilerMove,
458 ///The `compiler_copy` lang item.
459 CompilerCopy,
460 ///The `owned_box` lang item.
461 OwnedBox,
462 ///The `global_alloc_ty` lang item.
463 GlobalAlloc,
464 ///The `phantom_data` lang item.
465 PhantomData,
466 ///The `manually_drop` lang item.
467 ManuallyDrop,
468 ///The `maybe_dangling` lang item.
469 MaybeDangling,
470 ///The `bikeshed_guaranteed_no_drop` lang item.
471 BikeshedGuaranteedNoDrop,
472 ///The `maybe_uninit` lang item.
473 MaybeUninit,
474 ///The `termination` lang item.
475 Termination,
476 ///The `Try` lang item.
477 Try,
478 ///The `tuple_trait` lang item.
479 Tuple,
480 ///The `slice_len_fn` lang item.
481 SliceLen,
482 ///The `from_residual` lang item.
483 TryTraitFromResidual,
484 ///The `from_output` lang item.
485 TryTraitFromOutput,
486 ///The `branch` lang item.
487 TryTraitBranch,
488 ///The `from_yeet` lang item.
489 TryTraitFromYeet,
490 ///The `into_try_type` lang item.
491 ResidualIntoTryType,
492 ///The `coerce_pointee_validated` lang item.
493 CoercePointeeValidated,
494 ///The `const_param_ty` lang item.
495 ConstParamTy,
496 ///The `Poll` lang item.
497 Poll,
498 ///The `Ready` lang item.
499 PollReady,
500 ///The `Pending` lang item.
501 PollPending,
502 ///The `AsyncGenReady` lang item.
503 AsyncGenReady,
504 ///The `AsyncGenPending` lang item.
505 AsyncGenPending,
506 ///The `AsyncGenFinished` lang item.
507 AsyncGenFinished,
508 ///The `ResumeTy` lang item.
509 ResumeTy,
510 ///The `get_context` lang item.
511 GetContext,
512 ///The `Context` lang item.
513 Context,
514 ///The `poll` lang item.
515 FuturePoll,
516 ///The `async_iterator_poll_next` lang item.
517 AsyncIteratorPollNext,
518 ///The `into_async_iter_into_iter` lang item.
519 IntoAsyncIterIntoIter,
520 ///The `Option` lang item.
521 Option,
522 ///The `Some` lang item.
523 OptionSome,
524 ///The `None` lang item.
525 OptionNone,
526 ///The `Ok` lang item.
527 ResultOk,
528 ///The `Err` lang item.
529 ResultErr,
530 ///The `Continue` lang item.
531 ControlFlowContinue,
532 ///The `Break` lang item.
533 ControlFlowBreak,
534 ///The `into_future` lang item.
535 IntoFutureIntoFuture,
536 ///The `into_iter` lang item.
537 IntoIterIntoIter,
538 ///The `next` lang item.
539 IteratorNext,
540 ///The `new_unchecked` lang item.
541 PinNewUnchecked,
542 ///The `RangeFrom` lang item.
543 RangeFrom,
544 ///The `RangeFull` lang item.
545 RangeFull,
546 ///The `RangeInclusive` lang item.
547 RangeInclusiveStruct,
548 ///The `range_inclusive_new` lang item.
549 RangeInclusiveNew,
550 ///The `Range` lang item.
551 Range,
552 ///The `RangeToInclusive` lang item.
553 RangeToInclusive,
554 ///The `RangeTo` lang item.
555 RangeTo,
556 ///The `RangeMax` lang item.
557 RangeMax,
558 ///The `RangeMin` lang item.
559 RangeMin,
560 ///The `RangeSub` lang item.
561 RangeSub,
562 ///The `RangeFromCopy` lang item.
563 RangeFromCopy,
564 ///The `RangeCopy` lang item.
565 RangeCopy,
566 ///The `RangeInclusiveCopy` lang item.
567 RangeInclusiveCopy,
568 ///The `RangeToInclusiveCopy` lang item.
569 RangeToInclusiveCopy,
570 ///The `String` lang item.
571 String,
572 ///The `CStr` lang item.
573 CStr,
574 ///The `contract_build_check_ensures` lang item.
575 ContractBuildCheckEnsures,
576 ///The `contract_check_requires` lang item.
577 ContractCheckRequires,
578 ///The `default_trait4` lang item.
579 DefaultTrait4,
580 ///The `default_trait3` lang item.
581 DefaultTrait3,
582 ///The `default_trait2` lang item.
583 DefaultTrait2,
584 ///The `default_trait1` lang item.
585 DefaultTrait1,
586 ///The `contract_check_ensures` lang item.
587 ContractCheckEnsures,
588 ///The `reborrow` lang item.
589 Reborrow,
590 ///The `coerce_shared` lang item.
591 CoerceShared,
592 ///The `field_representing_type` lang item.
593 FieldRepresentingType,
594 ///The `field` lang item.
595 Field,
596 ///The `field_base` lang item.
597 FieldBase,
598 ///The `field_type` lang item.
599 FieldType,
600 ///The `field_offset` lang item.
601 FieldOffset,
602 ///The `From` lang item.
603 From,
604 ///The `from` lang item.
605 FromFn,
606 ///The `FnPtr` lang item.
607 FnPtr,
608}
609
610#[derive(Debug, Clone, PartialEq, Eq)]
611#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
612#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcArch"))]
613#[cfg_attr(feature = "charon_on_charon", charon::variants_prefix("RustcArch"))]
614pub enum Arch {
615 AArch64,
616 AmdGpu,
617 Arm,
618 Arm64EC,
619 Avr,
620 Bpf,
621 CSky,
622 Hexagon,
623 LoongArch32,
624 LoongArch64,
625 M68k,
626 Mips,
627 Mips32r6,
628 Mips64,
629 Mips64r6,
630 Msp430,
631 Nvptx64,
632 PowerPC,
633 PowerPC64,
634 RiscV32,
635 RiscV64,
636 S390x,
637 Sparc,
638 Sparc64,
639 SpirV,
640 Wasm32,
641 Wasm64,
642 X86,
643 X86_64,
644 Xtensa,
645 /// The vast majority of the time, the compiler deals with a fixed
646 /// set of values, so it is convenient for them to be represented in
647 /// an enum. However, it is possible to have arbitrary values in a
648 /// target JSON file (which can be parsed when `--target` is
649 /// specified). This might occur, for example, for an out-of-tree
650 /// codegen backend that supports a value (e.g. architecture or OS)
651 /// that rustc currently doesn't know about. This variant exists as
652 /// an escape hatch for such cases.
653 Other(Ustr),
654}
655
656#[derive(Debug, Clone, PartialEq, Eq)]
657#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
658#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcOs"))]
659#[cfg_attr(feature = "charon_on_charon", charon::variants_prefix("RustcOs"))]
660pub enum Os {
661 Aix,
662 AmdHsa,
663 Android,
664 Cuda,
665 Cygwin,
666 Dragonfly,
667 Emscripten,
668 EspIdf,
669 FreeBsd,
670 Fuchsia,
671 Haiku,
672 HelenOs,
673 Hermit,
674 Horizon,
675 Hurd,
676 Illumos,
677 IOs,
678 L4Re,
679 Linux,
680 LynxOs178,
681 MacOs,
682 Managarm,
683 Motor,
684 NetBsd,
685 None,
686 Nto,
687 NuttX,
688 OpenBsd,
689 Ps3,
690 Psp,
691 Psx,
692 Qnx,
693 Qurt,
694 Redox,
695 Rtems,
696 Solaris,
697 SolidAsp3,
698 TeeOs,
699 Trusty,
700 TvOs,
701 Uefi,
702 VexOs,
703 VisionOs,
704 Vita,
705 VxWorks,
706 Wasi,
707 WatchOs,
708 Windows,
709 Xous,
710 Zkvm,
711 Unknown,
712 /// The vast majority of the time, the compiler deals with a fixed
713 /// set of values, so it is convenient for them to be represented in
714 /// an enum. However, it is possible to have arbitrary values in a
715 /// target JSON file (which can be parsed when `--target` is
716 /// specified). This might occur, for example, for an out-of-tree
717 /// codegen backend that supports a value (e.g. architecture or OS)
718 /// that rustc currently doesn't know about. This variant exists as
719 /// an escape hatch for such cases.
720 Other(Ustr),
721}
722
723#[derive(Debug, Clone, PartialEq, Eq)]
724#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
725#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcEnv"))]
726#[cfg_attr(feature = "charon_on_charon", charon::variants_prefix("RustcEnv"))]
727pub enum Env {
728 Gnu,
729 MacAbi,
730 Mlibc,
731 Msvc,
732 Musl,
733 Newlib,
734 Nto70,
735 Nto71,
736 Nto71IoSock,
737 Ohos,
738 Relibc,
739 Sgx,
740 Sim,
741 P1,
742 P2,
743 P3,
744 Uclibc,
745 V5,
746 Unspecified,
747 /// The vast majority of the time, the compiler deals with a fixed
748 /// set of values, so it is convenient for them to be represented in
749 /// an enum. However, it is possible to have arbitrary values in a
750 /// target JSON file (which can be parsed when `--target` is
751 /// specified). This might occur, for example, for an out-of-tree
752 /// codegen backend that supports a value (e.g. architecture or OS)
753 /// that rustc currently doesn't know about. This variant exists as
754 /// an escape hatch for such cases.
755 Other(Ustr),
756}
757
758/// An enum representing possible values for `cfg(target_abi)`.
759/// This field is not forwarded to LLVM so it does not by itself affect codegen.
760/// See the `cfg_abi` field of [`TargetOptions`] for more details.
761#[derive(Debug, Clone, PartialEq, Eq)]
762#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
763#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcCfgAbi"))]
764#[cfg_attr(feature = "charon_on_charon", charon::variants_prefix("RustcCfgAbi"))]
765pub enum CfgAbi {
766 Abi64,
767 AbiV2,
768 AbiV2Hf,
769 Eabi,
770 EabiHf,
771 ElfV1,
772 ElfV2,
773 Fortanix,
774 Ilp32,
775 Ilp32e,
776 Llvm,
777 MacAbi,
778 Pauthtest,
779 Sim,
780 SoftFloat,
781 Spe,
782 Uwp,
783 VecDefault,
784 VecExtAbi,
785 X32,
786 V8Plus,
787 Unspecified,
788 /// The vast majority of the time, the compiler deals with a fixed
789 /// set of values, so it is convenient for them to be represented in
790 /// an enum. However, it is possible to have arbitrary values in a
791 /// target JSON file (which can be parsed when `--target` is
792 /// specified). This might occur, for example, for an out-of-tree
793 /// codegen backend that supports a value (e.g. architecture or OS)
794 /// that rustc currently doesn't know about. This variant exists as
795 /// an escape hatch for such cases.
796 Other(Ustr),
797}
798
799#[derive(Debug, Clone, PartialEq, Eq)]
800#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
801#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcBinaryFormat"))]
802#[cfg_attr(
803 feature = "charon_on_charon",
804 charon::variants_prefix("RustcBinaryFormat")
805)]
806pub enum BinaryFormat {
807 Coff,
808 Elf,
809 MachO,
810 Wasm,
811 Xcoff,
812}
813
814#[derive(Debug, Clone, PartialEq, Eq)]
815#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
816#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcDeprecation"))]
817pub struct Deprecation {
818 pub since: DeprecatedSince,
819 /// The note to issue a reason.
820 pub note: Option<Ident>,
821 /// A text snippet used to completely replace any use of the deprecated item in an expression.
822 ///
823 /// This is currently unstable.
824 pub suggestion: Option<Ustr>,
825}
826
827#[derive(Debug, Clone, PartialEq, Eq)]
828#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
829#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcInlineAttr"))]
830#[cfg_attr(
831 feature = "charon_on_charon",
832 charon::variants_prefix("RustcInlineAttr")
833)]
834pub enum InlineAttr {
835 None,
836 Hint,
837 Always,
838 Never,
839 /// `#[rustc_force_inline]` forces inlining to happen in the MIR inliner - it reports an error
840 /// if the inlining cannot happen. It is limited to only free functions so that the calls
841 /// can always be resolved.
842 Force {
843 attr_span: Span,
844 reason: Option<Ustr>,
845 },
846}
847
848/// Possible values for the `#[linkage]` attribute, allowing to specify the
849/// linkage type for a `MonoItem`.
850///
851/// See <https://llvm.org/docs/LangRef.html#linkage-types> for more details about these variants.
852#[derive(Debug, Clone, PartialEq, Eq)]
853#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
854#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcLinkage"))]
855#[cfg_attr(feature = "charon_on_charon", charon::variants_prefix("RustcLinkage"))]
856pub enum Linkage {
857 AvailableExternally,
858 Common,
859 ExternalWeak,
860 External,
861 Internal,
862 LinkOnceAny,
863 LinkOnceODR,
864 WeakAny,
865 WeakODR,
866}
867
868#[derive(Debug, Clone, PartialEq, Eq)]
869#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
870#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcOptimizeAttr"))]
871#[cfg_attr(
872 feature = "charon_on_charon",
873 charon::variants_prefix("RustcOptimizeAttr")
874)]
875pub enum OptimizeAttr {
876 /// No `#[optimize(..)]` attribute
877 Default,
878 /// `#[optimize(none)]`
879 DoNotOptimize,
880 /// `#[optimize(speed)]`
881 Speed,
882 /// `#[optimize(size)]`
883 Size,
884}
885
886/// Release in which an API is deprecated.
887#[derive(Debug, Clone, PartialEq, Eq)]
888#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
889#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcDeprecatedSince"))]
890#[cfg_attr(
891 feature = "charon_on_charon",
892 charon::variants_prefix("RustcDeprecatedSince")
893)]
894pub enum DeprecatedSince {
895 RustcVersion(RustcVersion),
896 /// Deprecated in the future ("to be determined").
897 Future,
898 /// `feature(staged_api)` is off. Deprecation versions outside the standard
899 /// library are allowed to be arbitrary strings, for better or worse.
900 NonStandard(Ustr),
901 /// Deprecation version is unspecified but optional.
902 Unspecified,
903 /// Failed to parse a deprecation version, or the deprecation version is
904 /// unspecified and required. An error has already been emitted.
905 Err,
906}
907
908#[derive(Debug, Clone, PartialEq, Eq)]
909#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
910#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcIdent"))]
911pub struct Ident {
912 /// `name` should never be the empty symbol. If you are considering that,
913 /// you are probably conflating "empty identifier with "no identifier" and
914 /// you should use `Option<Ident>` instead.
915 /// Trying to construct an `Ident` with an empty name will trigger debug assertions.
916 pub name: Ustr,
917 pub span: Span,
918}
919
920#[derive(Debug, Clone, PartialEq, Eq)]
921#[derive(Serialize, Deserialize, Drive, DriveMut, DriveTwo)]
922#[cfg_attr(feature = "charon_on_charon", charon::rename("RustcRustcVersion"))]
923pub struct RustcVersion {
924 pub major: u16,
925 pub minor: u16,
926 pub patch: u16,
927}