Skip to main content

charon_driver/translate/
translate_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::deref_addrof,
6    clippy::just_underscores_and_digits,
7    clippy::large_enum_variant,
8    clippy::needless_borrow,
9    clippy::needless_question_mark,
10    unreachable_patterns
11)]
12
13use super::translate_ctx::TranslateCtx;
14use charon_lib::ast::from_rustc::{self, FromRustcError};
15use rustc_hir::attrs::lang_items::*;
16use rustc_hir::attrs::*;
17use rustc_span::symbol::*;
18use rustc_target::spec::*;
19
20impl<'tcx> TranslateCtx<'tcx> {
21    pub(crate) fn translate_rustc_attribute_kind(
22        &mut self,
23        value: &AttributeKind,
24    ) -> Result<from_rustc::AttributeKind, FromRustcError> {
25        self.translate_attribute_kind_from_rustc(value)
26    }
27
28    pub(crate) fn translate_rustc_lang_item(
29        &mut self,
30        value: &LangItem,
31    ) -> Result<from_rustc::LangItem, FromRustcError> {
32        self.translate_lang_item_from_rustc(value)
33    }
34
35    pub(crate) fn translate_rustc_arch(
36        &mut self,
37        value: &Arch,
38    ) -> Result<from_rustc::Arch, FromRustcError> {
39        self.translate_arch_from_rustc(value)
40    }
41
42    pub(crate) fn translate_rustc_os(
43        &mut self,
44        value: &Os,
45    ) -> Result<from_rustc::Os, FromRustcError> {
46        self.translate_os_from_rustc(value)
47    }
48
49    pub(crate) fn translate_rustc_env(
50        &mut self,
51        value: &Env,
52    ) -> Result<from_rustc::Env, FromRustcError> {
53        self.translate_env_from_rustc(value)
54    }
55
56    pub(crate) fn translate_rustc_cfg_abi(
57        &mut self,
58        value: &CfgAbi,
59    ) -> Result<from_rustc::CfgAbi, FromRustcError> {
60        self.translate_cfg_abi_from_rustc(value)
61    }
62
63    pub(crate) fn translate_rustc_binary_format(
64        &mut self,
65        value: &BinaryFormat,
66    ) -> Result<from_rustc::BinaryFormat, FromRustcError> {
67        self.translate_binary_format_from_rustc(value)
68    }
69
70    fn translate_attribute_kind_from_rustc(
71        &mut self,
72        value: &AttributeKind,
73    ) -> Result<from_rustc::AttributeKind, FromRustcError> {
74        match value {
75            AttributeKind::AutomaticallyDerived => {
76                Ok(from_rustc::AttributeKind::AutomaticallyDerived)
77            }
78            AttributeKind::Cold => Ok(from_rustc::AttributeKind::Cold),
79            AttributeKind::Deprecated { deprecation, span } => {
80                Ok(from_rustc::AttributeKind::Deprecated {
81                    deprecation: self.translate_deprecation_from_rustc(deprecation)?,
82                    span: self.translate_span(span),
83                })
84            }
85            AttributeKind::ExportName { name, span } => Ok(from_rustc::AttributeKind::ExportName {
86                name: (name).to_string().into(),
87                span: self.translate_span(span),
88            }),
89            AttributeKind::Fundamental => Ok(from_rustc::AttributeKind::Fundamental),
90            AttributeKind::Ignore { span, reason } => Ok(from_rustc::AttributeKind::Ignore {
91                span: self.translate_span(span),
92                reason: (reason)
93                    .as_ref()
94                    .map(|value| Ok((value).to_string().into()))
95                    .transpose()?,
96            }),
97            AttributeKind::Inline(_0, _1) => Ok(from_rustc::AttributeKind::Inline(
98                self.translate_inline_attr_from_rustc(_0)?,
99                self.translate_span(_1),
100            )),
101            AttributeKind::LinkSection { name } => Ok(from_rustc::AttributeKind::LinkSection {
102                name: (name).to_string().into(),
103            }),
104            AttributeKind::Linkage(_0, _1) => Ok(from_rustc::AttributeKind::Linkage(
105                self.translate_linkage_from_rustc(_0)?,
106                self.translate_span(_1),
107            )),
108            AttributeKind::MayDangle(_0) => Ok(from_rustc::AttributeKind::MayDangle(
109                self.translate_span(_0),
110            )),
111            AttributeKind::Naked(_0) => {
112                Ok(from_rustc::AttributeKind::Naked(self.translate_span(_0)))
113            }
114            AttributeKind::NoLink => Ok(from_rustc::AttributeKind::NoLink),
115            AttributeKind::NoMangle(_0) => {
116                Ok(from_rustc::AttributeKind::NoMangle(self.translate_span(_0)))
117            }
118            AttributeKind::NonExhaustive(_0) => Ok(from_rustc::AttributeKind::NonExhaustive(
119                self.translate_span(_0),
120            )),
121            AttributeKind::Optimize(_0, _1) => Ok(from_rustc::AttributeKind::Optimize(
122                self.translate_optimize_attr_from_rustc(_0)?,
123                self.translate_span(_1),
124            )),
125            AttributeKind::RustcAlign { align, span } => {
126                Ok(from_rustc::AttributeKind::RustcAlign {
127                    align: align.bytes(),
128                    span: self.translate_span(span),
129                })
130            }
131            AttributeKind::RustcIntrinsic => Ok(from_rustc::AttributeKind::RustcIntrinsic),
132            AttributeKind::ShouldPanic { reason } => Ok(from_rustc::AttributeKind::ShouldPanic {
133                reason: (reason)
134                    .as_ref()
135                    .map(|value| Ok((value).to_string().into()))
136                    .transpose()?,
137            }),
138            AttributeKind::TargetFeature {
139                features,
140                attr_span,
141                was_forced,
142            } => Ok(from_rustc::AttributeKind::TargetFeature {
143                features: (features)
144                    .iter()
145                    .map(|value| {
146                        Ok((
147                            (&((value).0)).to_string().into(),
148                            self.translate_span(&((value).1)),
149                        ))
150                    })
151                    .collect::<Result<Vec<_>, FromRustcError>>()?,
152                attr_span: self.translate_span(attr_span),
153                was_forced: *(was_forced),
154            }),
155            AttributeKind::TrackCaller(_0) => Ok(from_rustc::AttributeKind::TrackCaller(
156                self.translate_span(_0),
157            )),
158            _ => Err(FromRustcError),
159        }
160    }
161
162    fn translate_lang_item_from_rustc(
163        &mut self,
164        value: &LangItem,
165    ) -> Result<from_rustc::LangItem, FromRustcError> {
166        match value {
167            LangItem::Sized => Ok(from_rustc::LangItem::Sized),
168            LangItem::MetaSized => Ok(from_rustc::LangItem::MetaSized),
169            LangItem::PointeeSized => Ok(from_rustc::LangItem::PointeeSized),
170            LangItem::Unsize => Ok(from_rustc::LangItem::Unsize),
171            LangItem::AlignOf => Ok(from_rustc::LangItem::AlignOf),
172            LangItem::SizeOf => Ok(from_rustc::LangItem::SizeOf),
173            LangItem::OffsetOf => Ok(from_rustc::LangItem::OffsetOf),
174            LangItem::StructuralPeq => Ok(from_rustc::LangItem::StructuralPeq),
175            LangItem::Copy => Ok(from_rustc::LangItem::Copy),
176            LangItem::Clone => Ok(from_rustc::LangItem::Clone),
177            LangItem::CloneFn => Ok(from_rustc::LangItem::CloneFn),
178            LangItem::UseCloned => Ok(from_rustc::LangItem::UseCloned),
179            LangItem::TrivialClone => Ok(from_rustc::LangItem::TrivialClone),
180            LangItem::Sync => Ok(from_rustc::LangItem::Sync),
181            LangItem::DiscriminantKind => Ok(from_rustc::LangItem::DiscriminantKind),
182            LangItem::Discriminant => Ok(from_rustc::LangItem::Discriminant),
183            LangItem::PointeeTrait => Ok(from_rustc::LangItem::PointeeTrait),
184            LangItem::Metadata => Ok(from_rustc::LangItem::Metadata),
185            LangItem::DynMetadata => Ok(from_rustc::LangItem::DynMetadata),
186            LangItem::NonNull => Ok(from_rustc::LangItem::NonNull),
187            LangItem::Freeze => Ok(from_rustc::LangItem::Freeze),
188            LangItem::UnsafeUnpin => Ok(from_rustc::LangItem::UnsafeUnpin),
189            LangItem::FnPtrTrait => Ok(from_rustc::LangItem::FnPtrTrait),
190            LangItem::FnPtrAsPtr => Ok(from_rustc::LangItem::FnPtrAsPtr),
191            LangItem::FnPtrFromPtr => Ok(from_rustc::LangItem::FnPtrFromPtr),
192            LangItem::Code => Ok(from_rustc::LangItem::Code),
193            LangItem::Drop => Ok(from_rustc::LangItem::Drop),
194            LangItem::Destruct => Ok(from_rustc::LangItem::Destruct),
195            LangItem::AsyncDrop => Ok(from_rustc::LangItem::AsyncDrop),
196            LangItem::AsyncDropInPlace => Ok(from_rustc::LangItem::AsyncDropInPlace),
197            LangItem::CoerceUnsized => Ok(from_rustc::LangItem::CoerceUnsized),
198            LangItem::DispatchFromDyn => Ok(from_rustc::LangItem::DispatchFromDyn),
199            LangItem::TryAsDyn => Ok(from_rustc::LangItem::TryAsDyn),
200            LangItem::TransmuteOpts => Ok(from_rustc::LangItem::TransmuteOpts),
201            LangItem::TransmuteTrait => Ok(from_rustc::LangItem::TransmuteTrait),
202            LangItem::Add => Ok(from_rustc::LangItem::Add),
203            LangItem::Sub => Ok(from_rustc::LangItem::Sub),
204            LangItem::Mul => Ok(from_rustc::LangItem::Mul),
205            LangItem::Div => Ok(from_rustc::LangItem::Div),
206            LangItem::Rem => Ok(from_rustc::LangItem::Rem),
207            LangItem::Neg => Ok(from_rustc::LangItem::Neg),
208            LangItem::Not => Ok(from_rustc::LangItem::Not),
209            LangItem::BitXor => Ok(from_rustc::LangItem::BitXor),
210            LangItem::BitAnd => Ok(from_rustc::LangItem::BitAnd),
211            LangItem::BitOr => Ok(from_rustc::LangItem::BitOr),
212            LangItem::Shl => Ok(from_rustc::LangItem::Shl),
213            LangItem::Shr => Ok(from_rustc::LangItem::Shr),
214            LangItem::AddAssign => Ok(from_rustc::LangItem::AddAssign),
215            LangItem::SubAssign => Ok(from_rustc::LangItem::SubAssign),
216            LangItem::MulAssign => Ok(from_rustc::LangItem::MulAssign),
217            LangItem::DivAssign => Ok(from_rustc::LangItem::DivAssign),
218            LangItem::RemAssign => Ok(from_rustc::LangItem::RemAssign),
219            LangItem::BitXorAssign => Ok(from_rustc::LangItem::BitXorAssign),
220            LangItem::BitAndAssign => Ok(from_rustc::LangItem::BitAndAssign),
221            LangItem::BitOrAssign => Ok(from_rustc::LangItem::BitOrAssign),
222            LangItem::ShlAssign => Ok(from_rustc::LangItem::ShlAssign),
223            LangItem::ShrAssign => Ok(from_rustc::LangItem::ShrAssign),
224            LangItem::Index => Ok(from_rustc::LangItem::Index),
225            LangItem::IndexMut => Ok(from_rustc::LangItem::IndexMut),
226            LangItem::UnsafeCell => Ok(from_rustc::LangItem::UnsafeCell),
227            LangItem::CovariantUnsafeCell => Ok(from_rustc::LangItem::CovariantUnsafeCell),
228            LangItem::UnsafePinned => Ok(from_rustc::LangItem::UnsafePinned),
229            LangItem::VaArgSafe => Ok(from_rustc::LangItem::VaArgSafe),
230            LangItem::VaList => Ok(from_rustc::LangItem::VaList),
231            LangItem::Complex => Ok(from_rustc::LangItem::Complex),
232            LangItem::Deref => Ok(from_rustc::LangItem::Deref),
233            LangItem::DerefMut => Ok(from_rustc::LangItem::DerefMut),
234            LangItem::DerefPure => Ok(from_rustc::LangItem::DerefPure),
235            LangItem::DerefTarget => Ok(from_rustc::LangItem::DerefTarget),
236            LangItem::Receiver => Ok(from_rustc::LangItem::Receiver),
237            LangItem::ReceiverTarget => Ok(from_rustc::LangItem::ReceiverTarget),
238            LangItem::LegacyReceiver => Ok(from_rustc::LangItem::LegacyReceiver),
239            LangItem::Fn => Ok(from_rustc::LangItem::Fn),
240            LangItem::FnMut => Ok(from_rustc::LangItem::FnMut),
241            LangItem::FnOnce => Ok(from_rustc::LangItem::FnOnce),
242            LangItem::FnStatic => Ok(from_rustc::LangItem::FnStatic),
243            LangItem::AsyncFn => Ok(from_rustc::LangItem::AsyncFn),
244            LangItem::AsyncFnMut => Ok(from_rustc::LangItem::AsyncFnMut),
245            LangItem::AsyncFnOnce => Ok(from_rustc::LangItem::AsyncFnOnce),
246            LangItem::AsyncFnOnceOutput => Ok(from_rustc::LangItem::AsyncFnOnceOutput),
247            LangItem::CallOnceFuture => Ok(from_rustc::LangItem::CallOnceFuture),
248            LangItem::CallRefFuture => Ok(from_rustc::LangItem::CallRefFuture),
249            LangItem::AsyncFnKindHelper => Ok(from_rustc::LangItem::AsyncFnKindHelper),
250            LangItem::AsyncFnKindUpvars => Ok(from_rustc::LangItem::AsyncFnKindUpvars),
251            LangItem::FnOnceOutput => Ok(from_rustc::LangItem::FnOnceOutput),
252            LangItem::Iterator => Ok(from_rustc::LangItem::Iterator),
253            LangItem::FusedIterator => Ok(from_rustc::LangItem::FusedIterator),
254            LangItem::Future => Ok(from_rustc::LangItem::Future),
255            LangItem::FutureOutput => Ok(from_rustc::LangItem::FutureOutput),
256            LangItem::AsyncIterator => Ok(from_rustc::LangItem::AsyncIterator),
257            LangItem::CoroutineState => Ok(from_rustc::LangItem::CoroutineState),
258            LangItem::Coroutine => Ok(from_rustc::LangItem::Coroutine),
259            LangItem::CoroutineReturn => Ok(from_rustc::LangItem::CoroutineReturn),
260            LangItem::CoroutineYield => Ok(from_rustc::LangItem::CoroutineYield),
261            LangItem::CoroutineResume => Ok(from_rustc::LangItem::CoroutineResume),
262            LangItem::Unpin => Ok(from_rustc::LangItem::Unpin),
263            LangItem::Pin => Ok(from_rustc::LangItem::Pin),
264            LangItem::OrderingEnum => Ok(from_rustc::LangItem::OrderingEnum),
265            LangItem::PartialEq => Ok(from_rustc::LangItem::PartialEq),
266            LangItem::PartialOrd => Ok(from_rustc::LangItem::PartialOrd),
267            LangItem::CVoid => Ok(from_rustc::LangItem::CVoid),
268            LangItem::Type => Ok(from_rustc::LangItem::Type),
269            LangItem::TypeGeneric => Ok(from_rustc::LangItem::TypeGeneric),
270            LangItem::TypeId => Ok(from_rustc::LangItem::TypeId),
271            LangItem::Panic => Ok(from_rustc::LangItem::Panic),
272            LangItem::PanicNounwind => Ok(from_rustc::LangItem::PanicNounwind),
273            LangItem::PanicFmt => Ok(from_rustc::LangItem::PanicFmt),
274            LangItem::PanicDisplay => Ok(from_rustc::LangItem::PanicDisplay),
275            LangItem::ConstPanicFmt => Ok(from_rustc::LangItem::ConstPanicFmt),
276            LangItem::PanicBoundsCheck => Ok(from_rustc::LangItem::PanicBoundsCheck),
277            LangItem::PanicMisalignedPointerDereference => {
278                Ok(from_rustc::LangItem::PanicMisalignedPointerDereference)
279            }
280            LangItem::PanicInfo => Ok(from_rustc::LangItem::PanicInfo),
281            LangItem::PanicLocation => Ok(from_rustc::LangItem::PanicLocation),
282            LangItem::PanicImpl => Ok(from_rustc::LangItem::PanicImpl),
283            LangItem::PanicCannotUnwind => Ok(from_rustc::LangItem::PanicCannotUnwind),
284            LangItem::PanicInCleanup => Ok(from_rustc::LangItem::PanicInCleanup),
285            LangItem::PanicAddOverflow => Ok(from_rustc::LangItem::PanicAddOverflow),
286            LangItem::PanicSubOverflow => Ok(from_rustc::LangItem::PanicSubOverflow),
287            LangItem::PanicMulOverflow => Ok(from_rustc::LangItem::PanicMulOverflow),
288            LangItem::PanicDivOverflow => Ok(from_rustc::LangItem::PanicDivOverflow),
289            LangItem::PanicRemOverflow => Ok(from_rustc::LangItem::PanicRemOverflow),
290            LangItem::PanicNegOverflow => Ok(from_rustc::LangItem::PanicNegOverflow),
291            LangItem::PanicShrOverflow => Ok(from_rustc::LangItem::PanicShrOverflow),
292            LangItem::PanicShlOverflow => Ok(from_rustc::LangItem::PanicShlOverflow),
293            LangItem::PanicDivZero => Ok(from_rustc::LangItem::PanicDivZero),
294            LangItem::PanicRemZero => Ok(from_rustc::LangItem::PanicRemZero),
295            LangItem::PanicCoroutineResumed => Ok(from_rustc::LangItem::PanicCoroutineResumed),
296            LangItem::PanicAsyncFnResumed => Ok(from_rustc::LangItem::PanicAsyncFnResumed),
297            LangItem::PanicAsyncGenFnResumed => Ok(from_rustc::LangItem::PanicAsyncGenFnResumed),
298            LangItem::PanicGenFnNone => Ok(from_rustc::LangItem::PanicGenFnNone),
299            LangItem::PanicCoroutineResumedPanic => {
300                Ok(from_rustc::LangItem::PanicCoroutineResumedPanic)
301            }
302            LangItem::PanicAsyncFnResumedPanic => {
303                Ok(from_rustc::LangItem::PanicAsyncFnResumedPanic)
304            }
305            LangItem::PanicAsyncGenFnResumedPanic => {
306                Ok(from_rustc::LangItem::PanicAsyncGenFnResumedPanic)
307            }
308            LangItem::PanicGenFnNonePanic => Ok(from_rustc::LangItem::PanicGenFnNonePanic),
309            LangItem::PanicNullPointerDereference => {
310                Ok(from_rustc::LangItem::PanicNullPointerDereference)
311            }
312            LangItem::PanicNullReferenceConstructed => {
313                Ok(from_rustc::LangItem::PanicNullReferenceConstructed)
314            }
315            LangItem::PanicInvalidEnumConstruction => {
316                Ok(from_rustc::LangItem::PanicInvalidEnumConstruction)
317            }
318            LangItem::PanicCoroutineResumedDrop => {
319                Ok(from_rustc::LangItem::PanicCoroutineResumedDrop)
320            }
321            LangItem::PanicAsyncFnResumedDrop => Ok(from_rustc::LangItem::PanicAsyncFnResumedDrop),
322            LangItem::PanicAsyncGenFnResumedDrop => {
323                Ok(from_rustc::LangItem::PanicAsyncGenFnResumedDrop)
324            }
325            LangItem::PanicGenFnNoneDrop => Ok(from_rustc::LangItem::PanicGenFnNoneDrop),
326            LangItem::BeginPanic => Ok(from_rustc::LangItem::BeginPanic),
327            LangItem::FormatArgument => Ok(from_rustc::LangItem::FormatArgument),
328            LangItem::FormatArguments => Ok(from_rustc::LangItem::FormatArguments),
329            LangItem::DropGlue => Ok(from_rustc::LangItem::DropGlue),
330            LangItem::AllocLayout => Ok(from_rustc::LangItem::AllocLayout),
331            LangItem::Start => Ok(from_rustc::LangItem::Start),
332            LangItem::EhPersonality => Ok(from_rustc::LangItem::EhPersonality),
333            LangItem::CompilerMove => Ok(from_rustc::LangItem::CompilerMove),
334            LangItem::CompilerCopy => Ok(from_rustc::LangItem::CompilerCopy),
335            LangItem::OwnedBox => Ok(from_rustc::LangItem::OwnedBox),
336            LangItem::GlobalAlloc => Ok(from_rustc::LangItem::GlobalAlloc),
337            LangItem::PhantomData => Ok(from_rustc::LangItem::PhantomData),
338            LangItem::ManuallyDrop => Ok(from_rustc::LangItem::ManuallyDrop),
339            LangItem::MaybeDangling => Ok(from_rustc::LangItem::MaybeDangling),
340            LangItem::BikeshedGuaranteedNoDrop => {
341                Ok(from_rustc::LangItem::BikeshedGuaranteedNoDrop)
342            }
343            LangItem::MaybeUninit => Ok(from_rustc::LangItem::MaybeUninit),
344            LangItem::Termination => Ok(from_rustc::LangItem::Termination),
345            LangItem::Try => Ok(from_rustc::LangItem::Try),
346            LangItem::Tuple => Ok(from_rustc::LangItem::Tuple),
347            LangItem::SliceLen => Ok(from_rustc::LangItem::SliceLen),
348            LangItem::TryTraitFromResidual => Ok(from_rustc::LangItem::TryTraitFromResidual),
349            LangItem::TryTraitFromOutput => Ok(from_rustc::LangItem::TryTraitFromOutput),
350            LangItem::TryTraitBranch => Ok(from_rustc::LangItem::TryTraitBranch),
351            LangItem::TryTraitFromYeet => Ok(from_rustc::LangItem::TryTraitFromYeet),
352            LangItem::ResidualIntoTryType => Ok(from_rustc::LangItem::ResidualIntoTryType),
353            LangItem::CoercePointeeValidated => Ok(from_rustc::LangItem::CoercePointeeValidated),
354            LangItem::ConstParamTy => Ok(from_rustc::LangItem::ConstParamTy),
355            LangItem::Poll => Ok(from_rustc::LangItem::Poll),
356            LangItem::PollReady => Ok(from_rustc::LangItem::PollReady),
357            LangItem::PollPending => Ok(from_rustc::LangItem::PollPending),
358            LangItem::AsyncGenReady => Ok(from_rustc::LangItem::AsyncGenReady),
359            LangItem::AsyncGenPending => Ok(from_rustc::LangItem::AsyncGenPending),
360            LangItem::AsyncGenFinished => Ok(from_rustc::LangItem::AsyncGenFinished),
361            LangItem::ResumeTy => Ok(from_rustc::LangItem::ResumeTy),
362            LangItem::GetContext => Ok(from_rustc::LangItem::GetContext),
363            LangItem::Context => Ok(from_rustc::LangItem::Context),
364            LangItem::FuturePoll => Ok(from_rustc::LangItem::FuturePoll),
365            LangItem::AsyncIteratorPollNext => Ok(from_rustc::LangItem::AsyncIteratorPollNext),
366            LangItem::IntoAsyncIterIntoIter => Ok(from_rustc::LangItem::IntoAsyncIterIntoIter),
367            LangItem::Option => Ok(from_rustc::LangItem::Option),
368            LangItem::OptionSome => Ok(from_rustc::LangItem::OptionSome),
369            LangItem::OptionNone => Ok(from_rustc::LangItem::OptionNone),
370            LangItem::ResultOk => Ok(from_rustc::LangItem::ResultOk),
371            LangItem::ResultErr => Ok(from_rustc::LangItem::ResultErr),
372            LangItem::ControlFlowContinue => Ok(from_rustc::LangItem::ControlFlowContinue),
373            LangItem::ControlFlowBreak => Ok(from_rustc::LangItem::ControlFlowBreak),
374            LangItem::IntoFutureIntoFuture => Ok(from_rustc::LangItem::IntoFutureIntoFuture),
375            LangItem::IntoIterIntoIter => Ok(from_rustc::LangItem::IntoIterIntoIter),
376            LangItem::IteratorNext => Ok(from_rustc::LangItem::IteratorNext),
377            LangItem::PinNewUnchecked => Ok(from_rustc::LangItem::PinNewUnchecked),
378            LangItem::RangeFrom => Ok(from_rustc::LangItem::RangeFrom),
379            LangItem::RangeFull => Ok(from_rustc::LangItem::RangeFull),
380            LangItem::RangeInclusiveStruct => Ok(from_rustc::LangItem::RangeInclusiveStruct),
381            LangItem::RangeInclusiveNew => Ok(from_rustc::LangItem::RangeInclusiveNew),
382            LangItem::Range => Ok(from_rustc::LangItem::Range),
383            LangItem::RangeToInclusive => Ok(from_rustc::LangItem::RangeToInclusive),
384            LangItem::RangeTo => Ok(from_rustc::LangItem::RangeTo),
385            LangItem::RangeMax => Ok(from_rustc::LangItem::RangeMax),
386            LangItem::RangeMin => Ok(from_rustc::LangItem::RangeMin),
387            LangItem::RangeSub => Ok(from_rustc::LangItem::RangeSub),
388            LangItem::RangeFromCopy => Ok(from_rustc::LangItem::RangeFromCopy),
389            LangItem::RangeCopy => Ok(from_rustc::LangItem::RangeCopy),
390            LangItem::RangeInclusiveCopy => Ok(from_rustc::LangItem::RangeInclusiveCopy),
391            LangItem::RangeToInclusiveCopy => Ok(from_rustc::LangItem::RangeToInclusiveCopy),
392            LangItem::String => Ok(from_rustc::LangItem::String),
393            LangItem::CStr => Ok(from_rustc::LangItem::CStr),
394            LangItem::ContractBuildCheckEnsures => {
395                Ok(from_rustc::LangItem::ContractBuildCheckEnsures)
396            }
397            LangItem::ContractCheckRequires => Ok(from_rustc::LangItem::ContractCheckRequires),
398            LangItem::DefaultTrait4 => Ok(from_rustc::LangItem::DefaultTrait4),
399            LangItem::DefaultTrait3 => Ok(from_rustc::LangItem::DefaultTrait3),
400            LangItem::DefaultTrait2 => Ok(from_rustc::LangItem::DefaultTrait2),
401            LangItem::DefaultTrait1 => Ok(from_rustc::LangItem::DefaultTrait1),
402            LangItem::ContractCheckEnsures => Ok(from_rustc::LangItem::ContractCheckEnsures),
403            LangItem::Reborrow => Ok(from_rustc::LangItem::Reborrow),
404            LangItem::CoerceShared => Ok(from_rustc::LangItem::CoerceShared),
405            LangItem::FieldRepresentingType => Ok(from_rustc::LangItem::FieldRepresentingType),
406            LangItem::Field => Ok(from_rustc::LangItem::Field),
407            LangItem::FieldBase => Ok(from_rustc::LangItem::FieldBase),
408            LangItem::FieldType => Ok(from_rustc::LangItem::FieldType),
409            LangItem::FieldOffset => Ok(from_rustc::LangItem::FieldOffset),
410            LangItem::From => Ok(from_rustc::LangItem::From),
411            LangItem::FromFn => Ok(from_rustc::LangItem::FromFn),
412            LangItem::FnPtr => Ok(from_rustc::LangItem::FnPtr),
413            // If the below is reached, the code is not up-to-date with the rustc version
414            _ => Err(FromRustcError),
415        }
416    }
417
418    fn translate_arch_from_rustc(
419        &mut self,
420        value: &Arch,
421    ) -> Result<from_rustc::Arch, FromRustcError> {
422        match value {
423            Arch::AArch64 => Ok(from_rustc::Arch::AArch64),
424            Arch::AmdGpu => Ok(from_rustc::Arch::AmdGpu),
425            Arch::Arm => Ok(from_rustc::Arch::Arm),
426            Arch::Arm64EC => Ok(from_rustc::Arch::Arm64EC),
427            Arch::Avr => Ok(from_rustc::Arch::Avr),
428            Arch::Bpf => Ok(from_rustc::Arch::Bpf),
429            Arch::CSky => Ok(from_rustc::Arch::CSky),
430            Arch::Hexagon => Ok(from_rustc::Arch::Hexagon),
431            Arch::LoongArch32 => Ok(from_rustc::Arch::LoongArch32),
432            Arch::LoongArch64 => Ok(from_rustc::Arch::LoongArch64),
433            Arch::M68k => Ok(from_rustc::Arch::M68k),
434            Arch::Mips => Ok(from_rustc::Arch::Mips),
435            Arch::Mips32r6 => Ok(from_rustc::Arch::Mips32r6),
436            Arch::Mips64 => Ok(from_rustc::Arch::Mips64),
437            Arch::Mips64r6 => Ok(from_rustc::Arch::Mips64r6),
438            Arch::Msp430 => Ok(from_rustc::Arch::Msp430),
439            Arch::Nvptx64 => Ok(from_rustc::Arch::Nvptx64),
440            Arch::PowerPC => Ok(from_rustc::Arch::PowerPC),
441            Arch::PowerPC64 => Ok(from_rustc::Arch::PowerPC64),
442            Arch::RiscV32 => Ok(from_rustc::Arch::RiscV32),
443            Arch::RiscV64 => Ok(from_rustc::Arch::RiscV64),
444            Arch::S390x => Ok(from_rustc::Arch::S390x),
445            Arch::Sparc => Ok(from_rustc::Arch::Sparc),
446            Arch::Sparc64 => Ok(from_rustc::Arch::Sparc64),
447            Arch::SpirV => Ok(from_rustc::Arch::SpirV),
448            Arch::Wasm32 => Ok(from_rustc::Arch::Wasm32),
449            Arch::Wasm64 => Ok(from_rustc::Arch::Wasm64),
450            Arch::X86 => Ok(from_rustc::Arch::X86),
451            Arch::X86_64 => Ok(from_rustc::Arch::X86_64),
452            Arch::Xtensa => Ok(from_rustc::Arch::Xtensa),
453            Arch::Other(_0) => Ok(from_rustc::Arch::Other((_0).as_ref().into())),
454            // If the below is reached, the code is not up-to-date with the rustc version
455            _ => Err(FromRustcError),
456        }
457    }
458
459    fn translate_os_from_rustc(&mut self, value: &Os) -> Result<from_rustc::Os, FromRustcError> {
460        match value {
461            Os::Aix => Ok(from_rustc::Os::Aix),
462            Os::AmdHsa => Ok(from_rustc::Os::AmdHsa),
463            Os::Android => Ok(from_rustc::Os::Android),
464            Os::Cuda => Ok(from_rustc::Os::Cuda),
465            Os::Cygwin => Ok(from_rustc::Os::Cygwin),
466            Os::Dragonfly => Ok(from_rustc::Os::Dragonfly),
467            Os::Emscripten => Ok(from_rustc::Os::Emscripten),
468            Os::EspIdf => Ok(from_rustc::Os::EspIdf),
469            Os::FreeBsd => Ok(from_rustc::Os::FreeBsd),
470            Os::Fuchsia => Ok(from_rustc::Os::Fuchsia),
471            Os::Haiku => Ok(from_rustc::Os::Haiku),
472            Os::HelenOs => Ok(from_rustc::Os::HelenOs),
473            Os::Hermit => Ok(from_rustc::Os::Hermit),
474            Os::Horizon => Ok(from_rustc::Os::Horizon),
475            Os::Hurd => Ok(from_rustc::Os::Hurd),
476            Os::Illumos => Ok(from_rustc::Os::Illumos),
477            Os::IOs => Ok(from_rustc::Os::IOs),
478            Os::L4Re => Ok(from_rustc::Os::L4Re),
479            Os::Linux => Ok(from_rustc::Os::Linux),
480            Os::LynxOs178 => Ok(from_rustc::Os::LynxOs178),
481            Os::MacOs => Ok(from_rustc::Os::MacOs),
482            Os::Managarm => Ok(from_rustc::Os::Managarm),
483            Os::Motor => Ok(from_rustc::Os::Motor),
484            Os::NetBsd => Ok(from_rustc::Os::NetBsd),
485            Os::None => Ok(from_rustc::Os::None),
486            Os::Nto => Ok(from_rustc::Os::Nto),
487            Os::NuttX => Ok(from_rustc::Os::NuttX),
488            Os::OpenBsd => Ok(from_rustc::Os::OpenBsd),
489            Os::Ps3 => Ok(from_rustc::Os::Ps3),
490            Os::Psp => Ok(from_rustc::Os::Psp),
491            Os::Psx => Ok(from_rustc::Os::Psx),
492            Os::Qnx => Ok(from_rustc::Os::Qnx),
493            Os::Qurt => Ok(from_rustc::Os::Qurt),
494            Os::Redox => Ok(from_rustc::Os::Redox),
495            Os::Rtems => Ok(from_rustc::Os::Rtems),
496            Os::Solaris => Ok(from_rustc::Os::Solaris),
497            Os::SolidAsp3 => Ok(from_rustc::Os::SolidAsp3),
498            Os::TeeOs => Ok(from_rustc::Os::TeeOs),
499            Os::Trusty => Ok(from_rustc::Os::Trusty),
500            Os::TvOs => Ok(from_rustc::Os::TvOs),
501            Os::Uefi => Ok(from_rustc::Os::Uefi),
502            Os::VexOs => Ok(from_rustc::Os::VexOs),
503            Os::VisionOs => Ok(from_rustc::Os::VisionOs),
504            Os::Vita => Ok(from_rustc::Os::Vita),
505            Os::VxWorks => Ok(from_rustc::Os::VxWorks),
506            Os::Wasi => Ok(from_rustc::Os::Wasi),
507            Os::WatchOs => Ok(from_rustc::Os::WatchOs),
508            Os::Windows => Ok(from_rustc::Os::Windows),
509            Os::Xous => Ok(from_rustc::Os::Xous),
510            Os::Zkvm => Ok(from_rustc::Os::Zkvm),
511            Os::Unknown => Ok(from_rustc::Os::Unknown),
512            Os::Other(_0) => Ok(from_rustc::Os::Other((_0).as_ref().into())),
513            // If the below is reached, the code is not up-to-date with the rustc version
514            _ => Err(FromRustcError),
515        }
516    }
517
518    fn translate_env_from_rustc(&mut self, value: &Env) -> Result<from_rustc::Env, FromRustcError> {
519        match value {
520            Env::Gnu => Ok(from_rustc::Env::Gnu),
521            Env::MacAbi => Ok(from_rustc::Env::MacAbi),
522            Env::Mlibc => Ok(from_rustc::Env::Mlibc),
523            Env::Msvc => Ok(from_rustc::Env::Msvc),
524            Env::Musl => Ok(from_rustc::Env::Musl),
525            Env::Newlib => Ok(from_rustc::Env::Newlib),
526            Env::Nto70 => Ok(from_rustc::Env::Nto70),
527            Env::Nto71 => Ok(from_rustc::Env::Nto71),
528            Env::Nto71IoSock => Ok(from_rustc::Env::Nto71IoSock),
529            Env::Ohos => Ok(from_rustc::Env::Ohos),
530            Env::Relibc => Ok(from_rustc::Env::Relibc),
531            Env::Sgx => Ok(from_rustc::Env::Sgx),
532            Env::Sim => Ok(from_rustc::Env::Sim),
533            Env::P1 => Ok(from_rustc::Env::P1),
534            Env::P2 => Ok(from_rustc::Env::P2),
535            Env::P3 => Ok(from_rustc::Env::P3),
536            Env::Uclibc => Ok(from_rustc::Env::Uclibc),
537            Env::V5 => Ok(from_rustc::Env::V5),
538            Env::Unspecified => Ok(from_rustc::Env::Unspecified),
539            Env::Other(_0) => Ok(from_rustc::Env::Other((_0).as_ref().into())),
540            // If the below is reached, the code is not up-to-date with the rustc version
541            _ => Err(FromRustcError),
542        }
543    }
544
545    fn translate_cfg_abi_from_rustc(
546        &mut self,
547        value: &CfgAbi,
548    ) -> Result<from_rustc::CfgAbi, FromRustcError> {
549        match value {
550            CfgAbi::Abi64 => Ok(from_rustc::CfgAbi::Abi64),
551            CfgAbi::AbiV2 => Ok(from_rustc::CfgAbi::AbiV2),
552            CfgAbi::AbiV2Hf => Ok(from_rustc::CfgAbi::AbiV2Hf),
553            CfgAbi::Eabi => Ok(from_rustc::CfgAbi::Eabi),
554            CfgAbi::EabiHf => Ok(from_rustc::CfgAbi::EabiHf),
555            CfgAbi::ElfV1 => Ok(from_rustc::CfgAbi::ElfV1),
556            CfgAbi::ElfV2 => Ok(from_rustc::CfgAbi::ElfV2),
557            CfgAbi::Fortanix => Ok(from_rustc::CfgAbi::Fortanix),
558            CfgAbi::Ilp32 => Ok(from_rustc::CfgAbi::Ilp32),
559            CfgAbi::Ilp32e => Ok(from_rustc::CfgAbi::Ilp32e),
560            CfgAbi::Llvm => Ok(from_rustc::CfgAbi::Llvm),
561            CfgAbi::MacAbi => Ok(from_rustc::CfgAbi::MacAbi),
562            CfgAbi::Pauthtest => Ok(from_rustc::CfgAbi::Pauthtest),
563            CfgAbi::Sim => Ok(from_rustc::CfgAbi::Sim),
564            CfgAbi::SoftFloat => Ok(from_rustc::CfgAbi::SoftFloat),
565            CfgAbi::Spe => Ok(from_rustc::CfgAbi::Spe),
566            CfgAbi::Uwp => Ok(from_rustc::CfgAbi::Uwp),
567            CfgAbi::VecDefault => Ok(from_rustc::CfgAbi::VecDefault),
568            CfgAbi::VecExtAbi => Ok(from_rustc::CfgAbi::VecExtAbi),
569            CfgAbi::X32 => Ok(from_rustc::CfgAbi::X32),
570            CfgAbi::V8Plus => Ok(from_rustc::CfgAbi::V8Plus),
571            CfgAbi::Unspecified => Ok(from_rustc::CfgAbi::Unspecified),
572            CfgAbi::Other(_0) => Ok(from_rustc::CfgAbi::Other((_0).as_ref().into())),
573            // If the below is reached, the code is not up-to-date with the rustc version
574            _ => Err(FromRustcError),
575        }
576    }
577
578    fn translate_binary_format_from_rustc(
579        &mut self,
580        value: &BinaryFormat,
581    ) -> Result<from_rustc::BinaryFormat, FromRustcError> {
582        match value {
583            BinaryFormat::Coff => Ok(from_rustc::BinaryFormat::Coff),
584            BinaryFormat::Elf => Ok(from_rustc::BinaryFormat::Elf),
585            BinaryFormat::MachO => Ok(from_rustc::BinaryFormat::MachO),
586            BinaryFormat::Wasm => Ok(from_rustc::BinaryFormat::Wasm),
587            BinaryFormat::Xcoff => Ok(from_rustc::BinaryFormat::Xcoff),
588            // If the below is reached, the code is not up-to-date with the rustc version
589            _ => Err(FromRustcError),
590        }
591    }
592
593    fn translate_deprecation_from_rustc(
594        &mut self,
595        value: &Deprecation,
596    ) -> Result<from_rustc::Deprecation, FromRustcError> {
597        Ok(from_rustc::Deprecation {
598            since: self.translate_deprecated_since_from_rustc(&value.since)?,
599            note: (&value.note)
600                .as_ref()
601                .map(|value| Ok(self.translate_ident_from_rustc(value)?))
602                .transpose()?,
603            suggestion: (&value.suggestion)
604                .as_ref()
605                .map(|value| Ok((value).to_string().into()))
606                .transpose()?,
607        })
608    }
609
610    fn translate_inline_attr_from_rustc(
611        &mut self,
612        value: &InlineAttr,
613    ) -> Result<from_rustc::InlineAttr, FromRustcError> {
614        match value {
615            InlineAttr::None => Ok(from_rustc::InlineAttr::None),
616            InlineAttr::Hint => Ok(from_rustc::InlineAttr::Hint),
617            InlineAttr::Always => Ok(from_rustc::InlineAttr::Always),
618            InlineAttr::Never => Ok(from_rustc::InlineAttr::Never),
619            InlineAttr::Force { attr_span, reason } => Ok(from_rustc::InlineAttr::Force {
620                attr_span: self.translate_span(attr_span),
621                reason: (reason)
622                    .as_ref()
623                    .map(|value| Ok((value).to_string().into()))
624                    .transpose()?,
625            }),
626            // If the below is reached, the code is not up-to-date with the rustc version
627            _ => Err(FromRustcError),
628        }
629    }
630
631    fn translate_linkage_from_rustc(
632        &mut self,
633        value: &Linkage,
634    ) -> Result<from_rustc::Linkage, FromRustcError> {
635        match value {
636            Linkage::AvailableExternally => Ok(from_rustc::Linkage::AvailableExternally),
637            Linkage::Common => Ok(from_rustc::Linkage::Common),
638            Linkage::ExternalWeak => Ok(from_rustc::Linkage::ExternalWeak),
639            Linkage::External => Ok(from_rustc::Linkage::External),
640            Linkage::Internal => Ok(from_rustc::Linkage::Internal),
641            Linkage::LinkOnceAny => Ok(from_rustc::Linkage::LinkOnceAny),
642            Linkage::LinkOnceODR => Ok(from_rustc::Linkage::LinkOnceODR),
643            Linkage::WeakAny => Ok(from_rustc::Linkage::WeakAny),
644            Linkage::WeakODR => Ok(from_rustc::Linkage::WeakODR),
645            // If the below is reached, the code is not up-to-date with the rustc version
646            _ => Err(FromRustcError),
647        }
648    }
649
650    fn translate_optimize_attr_from_rustc(
651        &mut self,
652        value: &OptimizeAttr,
653    ) -> Result<from_rustc::OptimizeAttr, FromRustcError> {
654        match value {
655            OptimizeAttr::Default => Ok(from_rustc::OptimizeAttr::Default),
656            OptimizeAttr::DoNotOptimize => Ok(from_rustc::OptimizeAttr::DoNotOptimize),
657            OptimizeAttr::Speed => Ok(from_rustc::OptimizeAttr::Speed),
658            OptimizeAttr::Size => Ok(from_rustc::OptimizeAttr::Size),
659            // If the below is reached, the code is not up-to-date with the rustc version
660            _ => Err(FromRustcError),
661        }
662    }
663
664    fn translate_deprecated_since_from_rustc(
665        &mut self,
666        value: &DeprecatedSince,
667    ) -> Result<from_rustc::DeprecatedSince, FromRustcError> {
668        match value {
669            DeprecatedSince::RustcVersion(_0) => Ok(from_rustc::DeprecatedSince::RustcVersion(
670                self.translate_rustc_version_from_rustc(_0)?,
671            )),
672            DeprecatedSince::Future => Ok(from_rustc::DeprecatedSince::Future),
673            DeprecatedSince::NonStandard(_0) => Ok(from_rustc::DeprecatedSince::NonStandard(
674                (_0).to_string().into(),
675            )),
676            DeprecatedSince::Unspecified => Ok(from_rustc::DeprecatedSince::Unspecified),
677            DeprecatedSince::Err => Ok(from_rustc::DeprecatedSince::Err),
678            // If the below is reached, the code is not up-to-date with the rustc version
679            _ => Err(FromRustcError),
680        }
681    }
682
683    fn translate_ident_from_rustc(
684        &mut self,
685        value: &Ident,
686    ) -> Result<from_rustc::Ident, FromRustcError> {
687        Ok(from_rustc::Ident {
688            name: (&value.name).to_string().into(),
689            span: self.translate_span(&value.span),
690        })
691    }
692
693    fn translate_rustc_version_from_rustc(
694        &mut self,
695        value: &RustcVersion,
696    ) -> Result<from_rustc::RustcVersion, FromRustcError> {
697        Ok(from_rustc::RustcVersion {
698            major: *(&value.major),
699            minor: *(&value.minor),
700            patch: *(&value.patch),
701        })
702    }
703}