1use rustc_middle::ty::Ty;
4use rustc_middle::{bug, mir, ty};
5use rustc_public_bridge::Tables;
6use rustc_public_bridge::context::CompilerCtxt;
7
8use crate::alloc;
9use crate::compiler_interface::BridgeTys;
10use crate::ty::{
11 AdtKind, FloatTy, GenericArgs, GenericParamDef, IntTy, Region, RigidTy, TyKind, UintTy,
12};
13use crate::unstable::Stable;
14
15impl<'tcx> Stable<'tcx> for ty::AliasTyKind<'tcx> {
16 type T = crate::ty::AliasKind;
17 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
18 match self {
19 ty::Projection { .. } => crate::ty::AliasKind::Projection,
20 ty::Inherent { .. } => crate::ty::AliasKind::Inherent,
21 ty::Opaque { .. } => crate::ty::AliasKind::Opaque,
22 ty::Free { .. } => crate::ty::AliasKind::Free,
23 }
24 }
25}
26
27impl<'tcx> Stable<'tcx> for ty::AliasTy<'tcx> {
28 type T = crate::ty::AliasTy;
29 fn stable<'cx>(
30 &self,
31 tables: &mut Tables<'cx, BridgeTys>,
32 cx: &CompilerCtxt<'cx, BridgeTys>,
33 ) -> Self::T {
34 let ty::AliasTy { args, kind, .. } = self;
35 crate::ty::AliasTy {
36 def_id: tables.alias_def(kind.def_id()),
37 args: args.stable(tables, cx),
38 }
39 }
40}
41
42impl<'tcx> Stable<'tcx> for ty::AliasTerm<'tcx> {
43 type T = crate::ty::AliasTerm;
44 fn stable<'cx>(
45 &self,
46 tables: &mut Tables<'cx, BridgeTys>,
47 cx: &CompilerCtxt<'cx, BridgeTys>,
48 ) -> Self::T {
49 let ty::AliasTerm { args, def_id, .. } = self;
50 crate::ty::AliasTerm { def_id: tables.alias_def(*def_id), args: args.stable(tables, cx) }
51 }
52}
53
54impl<'tcx> Stable<'tcx> for ty::ExistentialPredicate<'tcx> {
55 type T = crate::ty::ExistentialPredicate;
56
57 fn stable<'cx>(
58 &self,
59 tables: &mut Tables<'cx, BridgeTys>,
60 cx: &CompilerCtxt<'cx, BridgeTys>,
61 ) -> Self::T {
62 use crate::ty::ExistentialPredicate::*;
63 match self {
64 ty::ExistentialPredicate::Trait(existential_trait_ref) => {
65 Trait(existential_trait_ref.stable(tables, cx))
66 }
67 ty::ExistentialPredicate::Projection(existential_projection) => {
68 Projection(existential_projection.stable(tables, cx))
69 }
70 ty::ExistentialPredicate::AutoTrait(def_id) => AutoTrait(tables.trait_def(*def_id)),
71 }
72 }
73}
74
75impl<'tcx> Stable<'tcx> for ty::ExistentialTraitRef<'tcx> {
76 type T = crate::ty::ExistentialTraitRef;
77
78 fn stable<'cx>(
79 &self,
80 tables: &mut Tables<'cx, BridgeTys>,
81 cx: &CompilerCtxt<'cx, BridgeTys>,
82 ) -> Self::T {
83 let ty::ExistentialTraitRef { def_id, args, .. } = self;
84 crate::ty::ExistentialTraitRef {
85 def_id: tables.trait_def(*def_id),
86 generic_args: args.stable(tables, cx),
87 }
88 }
89}
90
91impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> {
92 type T = crate::ty::TermKind;
93
94 fn stable<'cx>(
95 &self,
96 tables: &mut Tables<'cx, BridgeTys>,
97 cx: &CompilerCtxt<'cx, BridgeTys>,
98 ) -> Self::T {
99 use crate::ty::TermKind;
100 match self {
101 ty::TermKind::Ty(ty) => TermKind::Type(ty.stable(tables, cx)),
102 ty::TermKind::Const(cnst) => {
103 let cnst = cnst.stable(tables, cx);
104 TermKind::Const(cnst)
105 }
106 }
107 }
108}
109
110impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> {
111 type T = crate::ty::ExistentialProjection;
112
113 fn stable<'cx>(
114 &self,
115 tables: &mut Tables<'cx, BridgeTys>,
116 cx: &CompilerCtxt<'cx, BridgeTys>,
117 ) -> Self::T {
118 let ty::ExistentialProjection { def_id, args, term, .. } = self;
119 crate::ty::ExistentialProjection {
120 def_id: tables.trait_def(*def_id),
121 generic_args: args.stable(tables, cx),
122 term: term.kind().stable(tables, cx),
123 }
124 }
125}
126
127impl<'tcx> Stable<'tcx> for ty::adjustment::PointerCoercion {
128 type T = crate::mir::PointerCoercion;
129 fn stable<'cx>(
130 &self,
131 tables: &mut Tables<'cx, BridgeTys>,
132 cx: &CompilerCtxt<'cx, BridgeTys>,
133 ) -> Self::T {
134 use rustc_middle::ty::adjustment::PointerCoercion;
135 match self {
136 PointerCoercion::ReifyFnPointer(safety) => {
137 crate::mir::PointerCoercion::ReifyFnPointer(safety.stable(tables, cx))
138 }
139 PointerCoercion::UnsafeFnPointer => crate::mir::PointerCoercion::UnsafeFnPointer,
140 PointerCoercion::ClosureFnPointer(safety) => {
141 crate::mir::PointerCoercion::ClosureFnPointer(safety.stable(tables, cx))
142 }
143 PointerCoercion::MutToConstPointer => crate::mir::PointerCoercion::MutToConstPointer,
144 PointerCoercion::ArrayToPointer => crate::mir::PointerCoercion::ArrayToPointer,
145 PointerCoercion::Unsize => crate::mir::PointerCoercion::Unsize,
146 }
147 }
148}
149
150impl<'tcx> Stable<'tcx> for ty::UserTypeAnnotationIndex {
151 type T = usize;
152 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
153 self.as_usize()
154 }
155}
156
157impl<'tcx> Stable<'tcx> for ty::AdtKind {
158 type T = AdtKind;
159
160 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
161 match self {
162 ty::AdtKind::Struct => AdtKind::Struct,
163 ty::AdtKind::Union => AdtKind::Union,
164 ty::AdtKind::Enum => AdtKind::Enum,
165 }
166 }
167}
168
169impl<'tcx> Stable<'tcx> for ty::FieldDef {
170 type T = crate::ty::FieldDef;
171
172 fn stable<'cx>(
173 &self,
174 tables: &mut Tables<'cx, BridgeTys>,
175 cx: &CompilerCtxt<'cx, BridgeTys>,
176 ) -> Self::T {
177 crate::ty::FieldDef {
178 def: tables.create_def_id(self.did),
179 name: self.name.stable(tables, cx),
180 }
181 }
182}
183
184impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
185 type T = crate::ty::GenericArgs;
186 fn stable<'cx>(
187 &self,
188 tables: &mut Tables<'cx, BridgeTys>,
189 cx: &CompilerCtxt<'cx, BridgeTys>,
190 ) -> Self::T {
191 GenericArgs(self.iter().map(|arg| arg.kind().stable(tables, cx)).collect())
192 }
193}
194
195impl<'tcx> Stable<'tcx> for ty::GenericArgKind<'tcx> {
196 type T = crate::ty::GenericArgKind;
197
198 fn stable<'cx>(
199 &self,
200 tables: &mut Tables<'cx, BridgeTys>,
201 cx: &CompilerCtxt<'cx, BridgeTys>,
202 ) -> Self::T {
203 use crate::ty::GenericArgKind;
204 match self {
205 ty::GenericArgKind::Lifetime(region) => {
206 GenericArgKind::Lifetime(region.stable(tables, cx))
207 }
208 ty::GenericArgKind::Type(ty) => GenericArgKind::Type(ty.stable(tables, cx)),
209 ty::GenericArgKind::Const(cnst) => GenericArgKind::Const(cnst.stable(tables, cx)),
210 }
211 }
212}
213
214impl<'tcx, S, V> Stable<'tcx> for ty::Binder<'tcx, S>
215where
216 S: Stable<'tcx, T = V>,
217{
218 type T = crate::ty::Binder<V>;
219
220 fn stable<'cx>(
221 &self,
222 tables: &mut Tables<'cx, BridgeTys>,
223 cx: &CompilerCtxt<'cx, BridgeTys>,
224 ) -> Self::T {
225 use crate::ty::Binder;
226
227 Binder {
228 value: self.as_ref().skip_binder().stable(tables, cx),
229 bound_vars: self
230 .bound_vars()
231 .iter()
232 .map(|bound_var| bound_var.stable(tables, cx))
233 .collect(),
234 }
235 }
236}
237
238impl<'tcx, S, V> Stable<'tcx> for ty::EarlyBinder<'tcx, S>
239where
240 S: Stable<'tcx, T = V>,
241{
242 type T = crate::ty::EarlyBinder<V>;
243
244 fn stable<'cx>(
245 &self,
246 tables: &mut Tables<'cx, BridgeTys>,
247 cx: &CompilerCtxt<'cx, BridgeTys>,
248 ) -> Self::T {
249 use crate::ty::EarlyBinder;
250
251 EarlyBinder { value: self.as_ref().skip_binder().stable(tables, cx) }
252 }
253}
254
255impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
256 type T = crate::ty::FnSig;
257 fn stable<'cx>(
258 &self,
259 tables: &mut Tables<'cx, BridgeTys>,
260 cx: &CompilerCtxt<'cx, BridgeTys>,
261 ) -> Self::T {
262 use crate::ty::FnSig;
263
264 FnSig {
265 inputs_and_output: self
266 .inputs_and_output
267 .iter()
268 .map(|ty| ty.stable(tables, cx))
269 .collect(),
270 c_variadic: self.c_variadic,
271 safety: self.safety.stable(tables, cx),
272 abi: self.abi.stable(tables, cx),
273 }
274 }
275}
276
277impl<'tcx> Stable<'tcx> for ty::BoundTyKind<'tcx> {
278 type T = crate::ty::BoundTyKind;
279
280 fn stable<'cx>(
281 &self,
282 tables: &mut Tables<'cx, BridgeTys>,
283 cx: &CompilerCtxt<'cx, BridgeTys>,
284 ) -> Self::T {
285 use crate::ty::BoundTyKind;
286
287 match self {
288 ty::BoundTyKind::Anon => BoundTyKind::Anon,
289 ty::BoundTyKind::Param(def_id) => {
290 BoundTyKind::Param(tables.param_def(*def_id), cx.tcx.item_name(*def_id).to_string())
291 }
292 }
293 }
294}
295
296impl<'tcx> Stable<'tcx> for ty::BoundRegionKind<'tcx> {
297 type T = crate::ty::BoundRegionKind;
298
299 fn stable<'cx>(
300 &self,
301 tables: &mut Tables<'cx, BridgeTys>,
302 cx: &CompilerCtxt<'cx, BridgeTys>,
303 ) -> Self::T {
304 use crate::ty::BoundRegionKind;
305
306 match self {
307 ty::BoundRegionKind::Anon => BoundRegionKind::BrAnon,
308 ty::BoundRegionKind::Named(def_id) => BoundRegionKind::BrNamed(
309 tables.br_named_def(*def_id),
310 cx.tcx.item_name(*def_id).to_string(),
311 ),
312 ty::BoundRegionKind::ClosureEnv => BoundRegionKind::BrEnv,
313 ty::BoundRegionKind::NamedForPrinting(_) => ::rustc_middle::util::bug::bug_fmt(format_args!("only used for pretty printing"))bug!("only used for pretty printing"),
314 }
315 }
316}
317
318impl<'tcx> Stable<'tcx> for ty::BoundVariableKind<'tcx> {
319 type T = crate::ty::BoundVariableKind;
320
321 fn stable<'cx>(
322 &self,
323 tables: &mut Tables<'cx, BridgeTys>,
324 cx: &CompilerCtxt<'cx, BridgeTys>,
325 ) -> Self::T {
326 use crate::ty::BoundVariableKind;
327
328 match self {
329 ty::BoundVariableKind::Ty(bound_ty_kind) => {
330 BoundVariableKind::Ty(bound_ty_kind.stable(tables, cx))
331 }
332 ty::BoundVariableKind::Region(bound_region_kind) => {
333 BoundVariableKind::Region(bound_region_kind.stable(tables, cx))
334 }
335 ty::BoundVariableKind::Const => BoundVariableKind::Const,
336 }
337 }
338}
339
340impl<'tcx> Stable<'tcx> for ty::IntTy {
341 type T = IntTy;
342
343 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
344 match self {
345 ty::IntTy::Isize => IntTy::Isize,
346 ty::IntTy::I8 => IntTy::I8,
347 ty::IntTy::I16 => IntTy::I16,
348 ty::IntTy::I32 => IntTy::I32,
349 ty::IntTy::I64 => IntTy::I64,
350 ty::IntTy::I128 => IntTy::I128,
351 }
352 }
353}
354
355impl<'tcx> Stable<'tcx> for ty::UintTy {
356 type T = UintTy;
357
358 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
359 match self {
360 ty::UintTy::Usize => UintTy::Usize,
361 ty::UintTy::U8 => UintTy::U8,
362 ty::UintTy::U16 => UintTy::U16,
363 ty::UintTy::U32 => UintTy::U32,
364 ty::UintTy::U64 => UintTy::U64,
365 ty::UintTy::U128 => UintTy::U128,
366 }
367 }
368}
369
370impl<'tcx> Stable<'tcx> for ty::FloatTy {
371 type T = FloatTy;
372
373 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
374 match self {
375 ty::FloatTy::F16 => FloatTy::F16,
376 ty::FloatTy::F32 => FloatTy::F32,
377 ty::FloatTy::F64 => FloatTy::F64,
378 ty::FloatTy::F128 => FloatTy::F128,
379 }
380 }
381}
382
383impl<'tcx> Stable<'tcx> for Ty<'tcx> {
384 type T = crate::ty::Ty;
385 fn stable<'cx>(
386 &self,
387 tables: &mut Tables<'cx, BridgeTys>,
388 cx: &CompilerCtxt<'cx, BridgeTys>,
389 ) -> Self::T {
390 tables.intern_ty(cx.lift(*self).unwrap())
391 }
392}
393
394impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> {
395 type T = crate::ty::TyKind;
396 fn stable<'cx>(
397 &self,
398 tables: &mut Tables<'cx, BridgeTys>,
399 cx: &CompilerCtxt<'cx, BridgeTys>,
400 ) -> Self::T {
401 match self {
402 ty::Bool => TyKind::RigidTy(RigidTy::Bool),
403 ty::Char => TyKind::RigidTy(RigidTy::Char),
404 ty::Int(int_ty) => TyKind::RigidTy(RigidTy::Int(int_ty.stable(tables, cx))),
405 ty::Uint(uint_ty) => TyKind::RigidTy(RigidTy::Uint(uint_ty.stable(tables, cx))),
406 ty::Float(float_ty) => TyKind::RigidTy(RigidTy::Float(float_ty.stable(tables, cx))),
407 ty::Adt(adt_def, generic_args) => TyKind::RigidTy(RigidTy::Adt(
408 tables.adt_def(adt_def.did()),
409 generic_args.stable(tables, cx),
410 )),
411 ty::Foreign(def_id) => TyKind::RigidTy(RigidTy::Foreign(tables.foreign_def(*def_id))),
412 ty::Str => TyKind::RigidTy(RigidTy::Str),
413 ty::Array(ty, constant) => {
414 TyKind::RigidTy(RigidTy::Array(ty.stable(tables, cx), constant.stable(tables, cx)))
415 }
416 ty::Pat(ty, pat) => {
417 TyKind::RigidTy(RigidTy::Pat(ty.stable(tables, cx), pat.stable(tables, cx)))
418 }
419 ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(ty.stable(tables, cx))),
420 ty::RawPtr(ty, mutbl) => {
421 TyKind::RigidTy(RigidTy::RawPtr(ty.stable(tables, cx), mutbl.stable(tables, cx)))
422 }
423 ty::Ref(region, ty, mutbl) => TyKind::RigidTy(RigidTy::Ref(
424 region.stable(tables, cx),
425 ty.stable(tables, cx),
426 mutbl.stable(tables, cx),
427 )),
428 ty::FnDef(def_id, generic_args) => TyKind::RigidTy(RigidTy::FnDef(
429 tables.fn_def(*def_id),
430 generic_args.stable(tables, cx),
431 )),
432 ty::FnPtr(sig_tys, hdr) => {
433 TyKind::RigidTy(RigidTy::FnPtr(sig_tys.with(*hdr).stable(tables, cx)))
434 }
435 ty::UnsafeBinder(_) => ::core::panicking::panic("not yet implemented")todo!(),
437 ty::Dynamic(existential_predicates, region) => TyKind::RigidTy(RigidTy::Dynamic(
438 existential_predicates
439 .iter()
440 .map(|existential_predicate| existential_predicate.stable(tables, cx))
441 .collect(),
442 region.stable(tables, cx),
443 )),
444 ty::Closure(def_id, generic_args) => TyKind::RigidTy(RigidTy::Closure(
445 tables.closure_def(*def_id),
446 generic_args.stable(tables, cx),
447 )),
448 ty::CoroutineClosure(..) => {
::core::panicking::panic_fmt(format_args!("not yet implemented: {0}",
format_args!("FIXME(async_closures): Lower these to SMIR")));
}todo!("FIXME(async_closures): Lower these to SMIR"),
449 ty::Coroutine(def_id, generic_args) => TyKind::RigidTy(RigidTy::Coroutine(
450 tables.coroutine_def(*def_id),
451 generic_args.stable(tables, cx),
452 )),
453 ty::Never => TyKind::RigidTy(RigidTy::Never),
454 ty::Tuple(fields) => TyKind::RigidTy(RigidTy::Tuple(
455 fields.iter().map(|ty| ty.stable(tables, cx)).collect(),
456 )),
457 ty::Alias(_alias_ty) => {
458 ::core::panicking::panic("not yet implemented")todo!()
459 }
460 ty::Param(param_ty) => TyKind::Param(param_ty.stable(tables, cx)),
461 ty::Bound(ty::BoundVarIndexKind::Canonical, _) => {
462 ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
463 }
464 ty::Bound(ty::BoundVarIndexKind::Bound(debruijn_idx), bound_ty) => {
465 TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables, cx))
466 }
467 ty::CoroutineWitness(def_id, args) => TyKind::RigidTy(RigidTy::CoroutineWitness(
468 tables.coroutine_witness_def(*def_id),
469 args.stable(tables, cx),
470 )),
471 ty::Placeholder(..) | ty::Infer(_) | ty::Error(_) => {
472 ::core::panicking::panic("internal error: entered unreachable code");unreachable!();
473 }
474 }
475 }
476}
477
478impl<'tcx> Stable<'tcx> for ty::Pattern<'tcx> {
479 type T = crate::ty::Pattern;
480
481 fn stable<'cx>(
482 &self,
483 tables: &mut Tables<'cx, BridgeTys>,
484 cx: &CompilerCtxt<'cx, BridgeTys>,
485 ) -> Self::T {
486 match **self {
487 ty::PatternKind::Range { start, end } => crate::ty::Pattern::Range {
488 start: Some(start.stable(tables, cx)),
490 end: Some(end.stable(tables, cx)),
491 include_end: true,
492 },
493 ty::PatternKind::NotNull => ::core::panicking::panic("not yet implemented")todo!(),
494 ty::PatternKind::Or(_) => ::core::panicking::panic("not yet implemented")todo!(),
495 }
496 }
497}
498
499impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
500 type T = crate::ty::TyConst;
501
502 fn stable<'cx>(
503 &self,
504 tables: &mut Tables<'cx, BridgeTys>,
505 cx: &CompilerCtxt<'cx, BridgeTys>,
506 ) -> Self::T {
507 let ct = cx.lift(*self).unwrap();
508 let kind = match ct.kind() {
509 ty::ConstKind::Value(cv) => {
510 let const_val = cx.valtree_to_const_val(cv);
511 if #[allow(non_exhaustive_omitted_patterns)] match const_val {
mir::ConstValue::ZeroSized => true,
_ => false,
}matches!(const_val, mir::ConstValue::ZeroSized) {
512 crate::ty::TyConstKind::ZSTValue(cv.ty.stable(tables, cx))
513 } else {
514 crate::ty::TyConstKind::Value(
515 cv.ty.stable(tables, cx),
516 alloc::new_allocation(cv.ty, const_val, tables, cx),
517 )
518 }
519 }
520 ty::ConstKind::Param(param) => crate::ty::TyConstKind::Param(param.stable(tables, cx)),
521 ty::ConstKind::Unevaluated(uv) => crate::ty::TyConstKind::Unevaluated(
522 tables.const_def(uv.def),
523 uv.args.stable(tables, cx),
524 ),
525 ty::ConstKind::Error(_) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
526 ty::ConstKind::Infer(_) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
527 ty::ConstKind::Bound(_, _) => ::core::panicking::panic("not implemented")unimplemented!(),
528 ty::ConstKind::Placeholder(_) => ::core::panicking::panic("not implemented")unimplemented!(),
529 ty::ConstKind::Expr(_) => ::core::panicking::panic("not implemented")unimplemented!(),
530 };
531 let id = tables.intern_ty_const(ct);
532 crate::ty::TyConst::new(kind, id)
533 }
534}
535
536impl<'tcx> Stable<'tcx> for ty::ParamConst {
537 type T = crate::ty::ParamConst;
538 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
539 use crate::ty::ParamConst;
540 ParamConst { index: self.index, name: self.name.to_string() }
541 }
542}
543
544impl<'tcx> Stable<'tcx> for ty::ParamTy {
545 type T = crate::ty::ParamTy;
546 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
547 use crate::ty::ParamTy;
548 ParamTy { index: self.index, name: self.name.to_string() }
549 }
550}
551
552impl<'tcx> Stable<'tcx> for ty::BoundTy<'tcx> {
553 type T = crate::ty::BoundTy;
554 fn stable<'cx>(
555 &self,
556 tables: &mut Tables<'cx, BridgeTys>,
557 cx: &CompilerCtxt<'cx, BridgeTys>,
558 ) -> Self::T {
559 use crate::ty::BoundTy;
560 BoundTy { var: self.var.as_usize(), kind: self.kind.stable(tables, cx) }
561 }
562}
563
564impl<'tcx> Stable<'tcx> for ty::trait_def::TraitSpecializationKind {
565 type T = crate::ty::TraitSpecializationKind;
566 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
567 use crate::ty::TraitSpecializationKind;
568
569 match self {
570 ty::trait_def::TraitSpecializationKind::None => TraitSpecializationKind::None,
571 ty::trait_def::TraitSpecializationKind::Marker => TraitSpecializationKind::Marker,
572 ty::trait_def::TraitSpecializationKind::AlwaysApplicable => {
573 TraitSpecializationKind::AlwaysApplicable
574 }
575 }
576 }
577}
578
579impl<'tcx> Stable<'tcx> for ty::TraitDef {
580 type T = crate::ty::TraitDecl;
581 fn stable<'cx>(
582 &self,
583 tables: &mut Tables<'cx, BridgeTys>,
584 cx: &CompilerCtxt<'cx, BridgeTys>,
585 ) -> Self::T {
586 use crate::opaque;
587 use crate::ty::TraitDecl;
588
589 TraitDecl {
590 def_id: tables.trait_def(self.def_id),
591 safety: self.safety.stable(tables, cx),
592 paren_sugar: self.paren_sugar,
593 has_auto_impl: self.has_auto_impl,
594 is_marker: self.is_marker,
595 is_coinductive: self.is_coinductive,
596 skip_array_during_method_dispatch: self.skip_array_during_method_dispatch,
597 skip_boxed_slice_during_method_dispatch: self.skip_boxed_slice_during_method_dispatch,
598 specialization_kind: self.specialization_kind.stable(tables, cx),
599 must_implement_one_of: self
600 .must_implement_one_of
601 .as_ref()
602 .map(|idents| idents.iter().map(|ident| opaque(ident)).collect()),
603 force_dyn_incompatible: self.force_dyn_incompatible.stable(tables, cx),
604 deny_explicit_impl: self.deny_explicit_impl,
605 }
606 }
607}
608
609impl<'tcx> Stable<'tcx> for ty::TraitRef<'tcx> {
610 type T = crate::ty::TraitRef;
611 fn stable<'cx>(
612 &self,
613 tables: &mut Tables<'cx, BridgeTys>,
614 cx: &CompilerCtxt<'cx, BridgeTys>,
615 ) -> Self::T {
616 use crate::ty::TraitRef;
617
618 TraitRef::try_new(tables.trait_def(self.def_id), self.args.stable(tables, cx)).unwrap()
619 }
620}
621
622impl<'tcx> Stable<'tcx> for ty::Generics {
623 type T = crate::ty::Generics;
624
625 fn stable<'cx>(
626 &self,
627 tables: &mut Tables<'cx, BridgeTys>,
628 cx: &CompilerCtxt<'cx, BridgeTys>,
629 ) -> Self::T {
630 use crate::ty::Generics;
631
632 let params: Vec<_> = self.own_params.iter().map(|param| param.stable(tables, cx)).collect();
633 let param_def_id_to_index =
634 params.iter().map(|param| (param.def_id, param.index)).collect();
635
636 Generics {
637 parent: self.parent.map(|did| tables.generic_def(did)),
638 parent_count: self.parent_count,
639 params,
640 param_def_id_to_index,
641 has_self: self.has_self,
642 has_late_bound_regions: self
643 .has_late_bound_regions
644 .as_ref()
645 .map(|late_bound_regions| late_bound_regions.stable(tables, cx)),
646 }
647 }
648}
649
650impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDefKind {
651 type T = crate::ty::GenericParamDefKind;
652
653 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
654 use crate::ty::GenericParamDefKind;
655 match *self {
656 ty::GenericParamDefKind::Lifetime => GenericParamDefKind::Lifetime,
657 ty::GenericParamDefKind::Type { has_default, synthetic } => {
658 GenericParamDefKind::Type { has_default, synthetic }
659 }
660 ty::GenericParamDefKind::Const { has_default } => {
661 GenericParamDefKind::Const { has_default }
662 }
663 }
664 }
665}
666
667impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDef {
668 type T = crate::ty::GenericParamDef;
669
670 fn stable<'cx>(
671 &self,
672 tables: &mut Tables<'cx, BridgeTys>,
673 cx: &CompilerCtxt<'cx, BridgeTys>,
674 ) -> Self::T {
675 GenericParamDef {
676 name: self.name.to_string(),
677 def_id: tables.generic_def(self.def_id),
678 index: self.index,
679 pure_wrt_drop: self.pure_wrt_drop,
680 kind: self.kind.stable(tables, cx),
681 }
682 }
683}
684
685impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> {
686 type T = crate::ty::PredicateKind;
687
688 fn stable<'cx>(
689 &self,
690 tables: &mut Tables<'cx, BridgeTys>,
691 cx: &CompilerCtxt<'cx, BridgeTys>,
692 ) -> Self::T {
693 use rustc_middle::ty::PredicateKind;
694 match self {
695 PredicateKind::Clause(clause_kind) => {
696 crate::ty::PredicateKind::Clause(clause_kind.stable(tables, cx))
697 }
698 PredicateKind::DynCompatible(did) => {
699 crate::ty::PredicateKind::DynCompatible(tables.trait_def(*did))
700 }
701 PredicateKind::Subtype(subtype_predicate) => {
702 crate::ty::PredicateKind::SubType(subtype_predicate.stable(tables, cx))
703 }
704 PredicateKind::Coerce(coerce_predicate) => {
705 crate::ty::PredicateKind::Coerce(coerce_predicate.stable(tables, cx))
706 }
707 PredicateKind::ConstEquate(a, b) => {
708 crate::ty::PredicateKind::ConstEquate(a.stable(tables, cx), b.stable(tables, cx))
709 }
710 PredicateKind::Ambiguous => crate::ty::PredicateKind::Ambiguous,
711 PredicateKind::NormalizesTo(_pred) => ::core::panicking::panic("not implemented")unimplemented!(),
712 PredicateKind::AliasRelate(a, b, alias_relation_direction) => {
713 crate::ty::PredicateKind::AliasRelate(
714 a.kind().stable(tables, cx),
715 b.kind().stable(tables, cx),
716 alias_relation_direction.stable(tables, cx),
717 )
718 }
719 }
720 }
721}
722
723impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> {
724 type T = crate::ty::ClauseKind;
725
726 fn stable<'cx>(
727 &self,
728 tables: &mut Tables<'cx, BridgeTys>,
729 cx: &CompilerCtxt<'cx, BridgeTys>,
730 ) -> Self::T {
731 use rustc_middle::ty::ClauseKind;
732 match *self {
733 ClauseKind::Trait(trait_object) => {
734 crate::ty::ClauseKind::Trait(trait_object.stable(tables, cx))
735 }
736 ClauseKind::RegionOutlives(region_outlives) => {
737 crate::ty::ClauseKind::RegionOutlives(region_outlives.stable(tables, cx))
738 }
739 ClauseKind::TypeOutlives(type_outlives) => {
740 let ty::OutlivesPredicate::<_, _>(a, b) = type_outlives;
741 crate::ty::ClauseKind::TypeOutlives(crate::ty::OutlivesPredicate(
742 a.stable(tables, cx),
743 b.stable(tables, cx),
744 ))
745 }
746 ClauseKind::Projection(projection_predicate) => {
747 crate::ty::ClauseKind::Projection(projection_predicate.stable(tables, cx))
748 }
749 ClauseKind::ConstArgHasType(const_, ty) => crate::ty::ClauseKind::ConstArgHasType(
750 const_.stable(tables, cx),
751 ty.stable(tables, cx),
752 ),
753 ClauseKind::WellFormed(term) => {
754 crate::ty::ClauseKind::WellFormed(term.kind().stable(tables, cx))
755 }
756 ClauseKind::ConstEvaluatable(const_) => {
757 crate::ty::ClauseKind::ConstEvaluatable(const_.stable(tables, cx))
758 }
759 ClauseKind::HostEffect(..) => {
760 ::core::panicking::panic("not yet implemented")todo!()
761 }
762 ClauseKind::UnstableFeature(_) => {
763 ::core::panicking::panic("not yet implemented")todo!()
764 }
765 }
766 }
767}
768
769impl<'tcx> Stable<'tcx> for ty::ClosureKind {
770 type T = crate::ty::ClosureKind;
771
772 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
773 use rustc_middle::ty::ClosureKind::*;
774 match self {
775 Fn => crate::ty::ClosureKind::Fn,
776 FnMut => crate::ty::ClosureKind::FnMut,
777 FnOnce => crate::ty::ClosureKind::FnOnce,
778 }
779 }
780}
781
782impl<'tcx> Stable<'tcx> for ty::SubtypePredicate<'tcx> {
783 type T = crate::ty::SubtypePredicate;
784
785 fn stable<'cx>(
786 &self,
787 tables: &mut Tables<'cx, BridgeTys>,
788 cx: &CompilerCtxt<'cx, BridgeTys>,
789 ) -> Self::T {
790 let ty::SubtypePredicate { a, b, a_is_expected: _ } = self;
791 crate::ty::SubtypePredicate { a: a.stable(tables, cx), b: b.stable(tables, cx) }
792 }
793}
794
795impl<'tcx> Stable<'tcx> for ty::CoercePredicate<'tcx> {
796 type T = crate::ty::CoercePredicate;
797
798 fn stable<'cx>(
799 &self,
800 tables: &mut Tables<'cx, BridgeTys>,
801 cx: &CompilerCtxt<'cx, BridgeTys>,
802 ) -> Self::T {
803 let ty::CoercePredicate { a, b } = self;
804 crate::ty::CoercePredicate { a: a.stable(tables, cx), b: b.stable(tables, cx) }
805 }
806}
807
808impl<'tcx> Stable<'tcx> for ty::AliasRelationDirection {
809 type T = crate::ty::AliasRelationDirection;
810
811 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
812 use rustc_middle::ty::AliasRelationDirection::*;
813 match self {
814 Equate => crate::ty::AliasRelationDirection::Equate,
815 Subtype => crate::ty::AliasRelationDirection::Subtype,
816 }
817 }
818}
819
820impl<'tcx> Stable<'tcx> for ty::TraitPredicate<'tcx> {
821 type T = crate::ty::TraitPredicate;
822
823 fn stable<'cx>(
824 &self,
825 tables: &mut Tables<'cx, BridgeTys>,
826 cx: &CompilerCtxt<'cx, BridgeTys>,
827 ) -> Self::T {
828 let ty::TraitPredicate { trait_ref, polarity } = self;
829 crate::ty::TraitPredicate {
830 trait_ref: trait_ref.stable(tables, cx),
831 polarity: polarity.stable(tables, cx),
832 }
833 }
834}
835
836impl<'tcx, T> Stable<'tcx> for ty::OutlivesPredicate<'tcx, T>
837where
838 T: Stable<'tcx>,
839{
840 type T = crate::ty::OutlivesPredicate<T::T, Region>;
841
842 fn stable<'cx>(
843 &self,
844 tables: &mut Tables<'cx, BridgeTys>,
845 cx: &CompilerCtxt<'cx, BridgeTys>,
846 ) -> Self::T {
847 let ty::OutlivesPredicate(a, b) = self;
848 crate::ty::OutlivesPredicate(a.stable(tables, cx), b.stable(tables, cx))
849 }
850}
851
852impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> {
853 type T = crate::ty::ProjectionPredicate;
854
855 fn stable<'cx>(
856 &self,
857 tables: &mut Tables<'cx, BridgeTys>,
858 cx: &CompilerCtxt<'cx, BridgeTys>,
859 ) -> Self::T {
860 let ty::ProjectionPredicate { projection_term, term } = self;
861 crate::ty::ProjectionPredicate {
862 projection_term: projection_term.stable(tables, cx),
863 term: term.kind().stable(tables, cx),
864 }
865 }
866}
867
868impl<'tcx> Stable<'tcx> for ty::ImplPolarity {
869 type T = crate::ty::ImplPolarity;
870
871 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
872 use rustc_middle::ty::ImplPolarity::*;
873 match self {
874 Positive => crate::ty::ImplPolarity::Positive,
875 Negative => crate::ty::ImplPolarity::Negative,
876 Reservation => crate::ty::ImplPolarity::Reservation,
877 }
878 }
879}
880
881impl<'tcx> Stable<'tcx> for ty::PredicatePolarity {
882 type T = crate::ty::PredicatePolarity;
883
884 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
885 use rustc_middle::ty::PredicatePolarity::*;
886 match self {
887 Positive => crate::ty::PredicatePolarity::Positive,
888 Negative => crate::ty::PredicatePolarity::Negative,
889 }
890 }
891}
892
893impl<'tcx> Stable<'tcx> for ty::Region<'tcx> {
894 type T = crate::ty::Region;
895
896 fn stable<'cx>(
897 &self,
898 tables: &mut Tables<'cx, BridgeTys>,
899 cx: &CompilerCtxt<'cx, BridgeTys>,
900 ) -> Self::T {
901 Region { kind: self.kind().stable(tables, cx) }
902 }
903}
904
905impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
906 type T = crate::ty::RegionKind;
907
908 fn stable<'cx>(
909 &self,
910 tables: &mut Tables<'cx, BridgeTys>,
911 cx: &CompilerCtxt<'cx, BridgeTys>,
912 ) -> Self::T {
913 use crate::ty::{BoundRegion, EarlyParamRegion, RegionKind};
914 match self {
915 ty::ReEarlyParam(early_reg) => RegionKind::ReEarlyParam(EarlyParamRegion {
916 index: early_reg.index,
917 name: early_reg.name.to_string(),
918 }),
919 ty::ReBound(ty::BoundVarIndexKind::Bound(db_index), bound_reg) => RegionKind::ReBound(
920 db_index.as_u32(),
921 BoundRegion {
922 var: bound_reg.var.as_u32(),
923 kind: bound_reg.kind.stable(tables, cx),
924 },
925 ),
926 ty::ReStatic => RegionKind::ReStatic,
927 ty::RePlaceholder(place_holder) => RegionKind::RePlaceholder(crate::ty::Placeholder {
928 universe: place_holder.universe.as_u32(),
929 bound: BoundRegion {
930 var: place_holder.bound.var.as_u32(),
931 kind: place_holder.bound.kind.stable(tables, cx),
932 },
933 }),
934 ty::ReErased => RegionKind::ReErased,
935 _ => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("{0:?}", self)));
}unreachable!("{self:?}"),
936 }
937 }
938}
939
940impl<'tcx> Stable<'tcx> for ty::Instance<'tcx> {
941 type T = crate::mir::mono::Instance;
942
943 fn stable<'cx>(
944 &self,
945 tables: &mut Tables<'cx, BridgeTys>,
946 cx: &CompilerCtxt<'cx, BridgeTys>,
947 ) -> Self::T {
948 let def = tables.instance_def(cx.lift(*self).unwrap());
949 let kind = match self.def {
950 ty::InstanceKind::Item(..) => crate::mir::mono::InstanceKind::Item,
951 ty::InstanceKind::Intrinsic(..) => crate::mir::mono::InstanceKind::Intrinsic,
952 ty::InstanceKind::Virtual(_def_id, idx) => {
953 crate::mir::mono::InstanceKind::Virtual { idx }
954 }
955 ty::InstanceKind::VTableShim(..)
956 | ty::InstanceKind::ReifyShim(..)
957 | ty::InstanceKind::FnPtrAddrShim(..)
958 | ty::InstanceKind::ClosureOnceShim { .. }
959 | ty::InstanceKind::ConstructCoroutineInClosureShim { .. }
960 | ty::InstanceKind::ThreadLocalShim(..)
961 | ty::InstanceKind::DropGlue(..)
962 | ty::InstanceKind::CloneShim(..)
963 | ty::InstanceKind::FnPtrShim(..)
964 | ty::InstanceKind::FutureDropPollShim(..)
965 | ty::InstanceKind::AsyncDropGlue(..)
966 | ty::InstanceKind::AsyncDropGlueCtorShim(..) => crate::mir::mono::InstanceKind::Shim,
967 };
968 crate::mir::mono::Instance { def, kind }
969 }
970}
971
972impl<'tcx> Stable<'tcx> for ty::Variance {
973 type T = crate::mir::Variance;
974 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
975 match self {
976 ty::Bivariant => crate::mir::Variance::Bivariant,
977 ty::Contravariant => crate::mir::Variance::Contravariant,
978 ty::Covariant => crate::mir::Variance::Covariant,
979 ty::Invariant => crate::mir::Variance::Invariant,
980 }
981 }
982}
983
984impl<'tcx> Stable<'tcx> for ty::Movability {
985 type T = crate::ty::Movability;
986
987 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
988 match self {
989 ty::Movability::Static => crate::ty::Movability::Static,
990 ty::Movability::Movable => crate::ty::Movability::Movable,
991 }
992 }
993}
994
995impl<'tcx> Stable<'tcx> for rustc_abi::ExternAbi {
996 type T = crate::ty::Abi;
997
998 fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
999 use rustc_abi::ExternAbi;
1000
1001 use crate::ty::Abi;
1002 match *self {
1003 ExternAbi::Rust => Abi::Rust,
1004 ExternAbi::C { unwind } => Abi::C { unwind },
1005 ExternAbi::Cdecl { unwind } => Abi::Cdecl { unwind },
1006 ExternAbi::Stdcall { unwind } => Abi::Stdcall { unwind },
1007 ExternAbi::Fastcall { unwind } => Abi::Fastcall { unwind },
1008 ExternAbi::Vectorcall { unwind } => Abi::Vectorcall { unwind },
1009 ExternAbi::Thiscall { unwind } => Abi::Thiscall { unwind },
1010 ExternAbi::Aapcs { unwind } => Abi::Aapcs { unwind },
1011 ExternAbi::Win64 { unwind } => Abi::Win64 { unwind },
1012 ExternAbi::SysV64 { unwind } => Abi::SysV64 { unwind },
1013 ExternAbi::PtxKernel => Abi::PtxKernel,
1014 ExternAbi::GpuKernel => Abi::GpuKernel,
1015 ExternAbi::Msp430Interrupt => Abi::Msp430Interrupt,
1016 ExternAbi::X86Interrupt => Abi::X86Interrupt,
1017 ExternAbi::EfiApi => Abi::EfiApi,
1018 ExternAbi::AvrInterrupt => Abi::AvrInterrupt,
1019 ExternAbi::AvrNonBlockingInterrupt => Abi::AvrNonBlockingInterrupt,
1020 ExternAbi::CmseNonSecureCall => Abi::CCmseNonSecureCall,
1021 ExternAbi::CmseNonSecureEntry => Abi::CCmseNonSecureEntry,
1022 ExternAbi::System { unwind } => Abi::System { unwind },
1023 ExternAbi::RustCall => Abi::RustCall,
1024 ExternAbi::Unadjusted => Abi::Unadjusted,
1025 ExternAbi::RustCold => Abi::RustCold,
1026 ExternAbi::RustPreserveNone => Abi::RustPreserveNone,
1027 ExternAbi::RustInvalid => Abi::RustInvalid,
1028 ExternAbi::RiscvInterruptM => Abi::RiscvInterruptM,
1029 ExternAbi::RiscvInterruptS => Abi::RiscvInterruptS,
1030 ExternAbi::Custom => Abi::Custom,
1031 }
1032 }
1033}
1034
1035impl<'tcx> Stable<'tcx> for rustc_session::cstore::ForeignModule {
1036 type T = crate::ty::ForeignModule;
1037
1038 fn stable<'cx>(
1039 &self,
1040 tables: &mut Tables<'cx, BridgeTys>,
1041 cx: &CompilerCtxt<'cx, BridgeTys>,
1042 ) -> Self::T {
1043 crate::ty::ForeignModule {
1044 def_id: tables.foreign_module_def(self.def_id),
1045 abi: self.abi.stable(tables, cx),
1046 }
1047 }
1048}
1049
1050impl<'tcx> Stable<'tcx> for ty::AssocKind {
1051 type T = crate::ty::AssocKind;
1052
1053 fn stable<'cx>(
1054 &self,
1055 tables: &mut Tables<'cx, BridgeTys>,
1056 cx: &CompilerCtxt<'cx, BridgeTys>,
1057 ) -> Self::T {
1058 use crate::ty::{AssocKind, AssocTypeData};
1059 match *self {
1060 ty::AssocKind::Const { name, .. } => AssocKind::Const { name: name.to_string() },
1061 ty::AssocKind::Fn { name, has_self } => {
1062 AssocKind::Fn { name: name.to_string(), has_self }
1063 }
1064 ty::AssocKind::Type { data } => AssocKind::Type {
1065 data: match data {
1066 ty::AssocTypeData::Normal(name) => AssocTypeData::Normal(name.to_string()),
1067 ty::AssocTypeData::Rpitit(rpitit) => {
1068 AssocTypeData::Rpitit(rpitit.stable(tables, cx))
1069 }
1070 },
1071 },
1072 }
1073 }
1074}
1075
1076impl<'tcx> Stable<'tcx> for ty::AssocContainer {
1077 type T = crate::ty::AssocContainer;
1078
1079 fn stable(
1080 &self,
1081 tables: &mut Tables<'_, BridgeTys>,
1082 _: &CompilerCtxt<'_, BridgeTys>,
1083 ) -> Self::T {
1084 use crate::ty::AssocContainer;
1085 match self {
1086 ty::AssocContainer::Trait => AssocContainer::Trait,
1087 ty::AssocContainer::InherentImpl => AssocContainer::InherentImpl,
1088 ty::AssocContainer::TraitImpl(trait_item_id) => {
1089 AssocContainer::TraitImpl(tables.assoc_def(trait_item_id.unwrap()))
1090 }
1091 }
1092 }
1093}
1094
1095impl<'tcx> Stable<'tcx> for ty::AssocItem {
1096 type T = crate::ty::AssocItem;
1097
1098 fn stable<'cx>(
1099 &self,
1100 tables: &mut Tables<'cx, BridgeTys>,
1101 cx: &CompilerCtxt<'cx, BridgeTys>,
1102 ) -> Self::T {
1103 crate::ty::AssocItem {
1104 def_id: tables.assoc_def(self.def_id),
1105 kind: self.kind.stable(tables, cx),
1106 container: self.container.stable(tables, cx),
1107 }
1108 }
1109}
1110
1111impl<'tcx> Stable<'tcx> for ty::ImplTraitInTraitData {
1112 type T = crate::ty::ImplTraitInTraitData;
1113
1114 fn stable<'cx>(
1115 &self,
1116 tables: &mut Tables<'cx, BridgeTys>,
1117 _: &CompilerCtxt<'cx, BridgeTys>,
1118 ) -> Self::T {
1119 use crate::ty::ImplTraitInTraitData;
1120 match self {
1121 ty::ImplTraitInTraitData::Trait { fn_def_id, opaque_def_id } => {
1122 ImplTraitInTraitData::Trait {
1123 fn_def_id: tables.fn_def(*fn_def_id),
1124 opaque_def_id: tables.opaque_def(*opaque_def_id),
1125 }
1126 }
1127 ty::ImplTraitInTraitData::Impl { fn_def_id } => {
1128 ImplTraitInTraitData::Impl { fn_def_id: tables.fn_def(*fn_def_id) }
1129 }
1130 }
1131 }
1132}
1133
1134impl<'tcx> Stable<'tcx> for rustc_middle::ty::util::Discr<'tcx> {
1135 type T = crate::ty::Discr;
1136
1137 fn stable<'cx>(
1138 &self,
1139 tables: &mut Tables<'cx, BridgeTys>,
1140 cx: &CompilerCtxt<'cx, BridgeTys>,
1141 ) -> Self::T {
1142 crate::ty::Discr { val: self.val, ty: self.ty.stable(tables, cx) }
1143 }
1144}
1145
1146impl<'tcx> Stable<'tcx> for rustc_middle::ty::VtblEntry<'tcx> {
1147 type T = crate::ty::VtblEntry;
1148
1149 fn stable<'cx>(
1150 &self,
1151 tables: &mut Tables<'cx, BridgeTys>,
1152 cx: &CompilerCtxt<'cx, BridgeTys>,
1153 ) -> Self::T {
1154 use crate::ty::VtblEntry;
1155 match self {
1156 ty::VtblEntry::MetadataDropInPlace => VtblEntry::MetadataDropInPlace,
1157 ty::VtblEntry::MetadataSize => VtblEntry::MetadataSize,
1158 ty::VtblEntry::MetadataAlign => VtblEntry::MetadataAlign,
1159 ty::VtblEntry::Vacant => VtblEntry::Vacant,
1160 ty::VtblEntry::Method(instance) => VtblEntry::Method(instance.stable(tables, cx)),
1161 ty::VtblEntry::TraitVPtr(trait_ref) => {
1162 VtblEntry::TraitVPtr(trait_ref.stable(tables, cx))
1163 }
1164 }
1165 }
1166}