rustc_type_ir/
upcast.rs

1/// An `Into`-like trait that takes `TyCtxt` to perform interner-specific transformations.
2pub trait Upcast<I, T> {
3    fn upcast(self, interner: I) -> T;
4}
5
6impl<I, T, U> Upcast<I, U> for T
7where
8    U: UpcastFrom<I, T>,
9{
10    fn upcast(self, interner: I) -> U {
11        U::upcast_from(self, interner)
12    }
13}
14
15/// A `From`-like trait that takes `TyCtxt` to perform interner-specific transformations.
16pub trait UpcastFrom<I, T> {
17    fn upcast_from(from: T, interner: I) -> Self;
18}
19
20impl<I, T> UpcastFrom<I, T> for T {
21    fn upcast_from(from: T, _tcx: I) -> Self {
22        from
23    }
24}