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