stable_mir/unstable/internal_cx/
mod.rs1use rustc_middle::ty::{List, Ty, TyCtxt};
4use rustc_middle::{mir, ty};
5pub(crate) use traits::*;
6
7use super::InternalCx;
8
9pub(crate) mod traits;
10
11impl<'tcx, T: InternalCx<'tcx>> SmirExistentialProjection<'tcx> for T {
12 fn new_from_args(
13 &self,
14 def_id: rustc_span::def_id::DefId,
15 args: ty::GenericArgsRef<'tcx>,
16 term: ty::Term<'tcx>,
17 ) -> ty::ExistentialProjection<'tcx> {
18 ty::ExistentialProjection::new_from_args(self.tcx(), def_id, args, term)
19 }
20}
21
22impl<'tcx, T: InternalCx<'tcx>> SmirExistentialTraitRef<'tcx> for T {
23 fn new_from_args(
24 &self,
25 trait_def_id: rustc_span::def_id::DefId,
26 args: ty::GenericArgsRef<'tcx>,
27 ) -> ty::ExistentialTraitRef<'tcx> {
28 ty::ExistentialTraitRef::new_from_args(self.tcx(), trait_def_id, args)
29 }
30}
31
32impl<'tcx, T: InternalCx<'tcx>> SmirTraitRef<'tcx> for T {
33 fn new_from_args(
34 &self,
35 trait_def_id: rustc_span::def_id::DefId,
36 args: ty::GenericArgsRef<'tcx>,
37 ) -> ty::TraitRef<'tcx> {
38 ty::TraitRef::new_from_args(self.tcx(), trait_def_id, args)
39 }
40}
41
42impl<'tcx> InternalCx<'tcx> for TyCtxt<'tcx> {
43 fn tcx(self) -> TyCtxt<'tcx> {
44 self
45 }
46
47 fn lift<T: ty::Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
48 TyCtxt::lift(self, value)
49 }
50
51 fn mk_args_from_iter<I, T>(self, iter: I) -> T::Output
52 where
53 I: Iterator<Item = T>,
54 T: ty::CollectAndApply<ty::GenericArg<'tcx>, ty::GenericArgsRef<'tcx>>,
55 {
56 TyCtxt::mk_args_from_iter(self, iter)
57 }
58
59 fn mk_pat(self, v: ty::PatternKind<'tcx>) -> ty::Pattern<'tcx> {
60 TyCtxt::mk_pat(self, v)
61 }
62
63 fn mk_poly_existential_predicates(
64 self,
65 eps: &[ty::PolyExistentialPredicate<'tcx>],
66 ) -> &'tcx List<ty::PolyExistentialPredicate<'tcx>> {
67 TyCtxt::mk_poly_existential_predicates(self, eps)
68 }
69
70 fn mk_type_list(self, v: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
71 TyCtxt::mk_type_list(self, v)
72 }
73
74 fn lifetimes_re_erased(self) -> ty::Region<'tcx> {
75 self.lifetimes.re_erased
76 }
77
78 fn mk_bound_variable_kinds_from_iter<I, T>(self, iter: I) -> T::Output
79 where
80 I: Iterator<Item = T>,
81 T: ty::CollectAndApply<ty::BoundVariableKind, &'tcx List<ty::BoundVariableKind>>,
82 {
83 TyCtxt::mk_bound_variable_kinds_from_iter(self, iter)
84 }
85
86 fn mk_place_elems(self, v: &[mir::PlaceElem<'tcx>]) -> &'tcx List<mir::PlaceElem<'tcx>> {
87 TyCtxt::mk_place_elems(self, v)
88 }
89
90 fn adt_def(self, def_id: rustc_hir::def_id::DefId) -> ty::AdtDef<'tcx> {
91 self.adt_def(def_id)
92 }
93}