Add ParamConst
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
parent
62f23c2b0b
commit
11c31bb1d3
1 changed files with 20 additions and 0 deletions
|
@ -1061,6 +1061,26 @@ impl<'a, 'gcx, 'tcx> ParamTy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)]
|
||||||
|
pub struct ParamConst {
|
||||||
|
pub index: u32,
|
||||||
|
pub name: InternedString,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'gcx, 'tcx> ParamConst {
|
||||||
|
pub fn new(index: u32, name: InternedString) -> ParamConst {
|
||||||
|
ParamConst { index, name }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn for_def(def: &ty::GenericParamDef) -> ParamConst {
|
||||||
|
ParamConst::new(def.index, def.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_const(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx LazyConst<'tcx> {
|
||||||
|
tcx.mk_const_param(self.index, self.name, ty)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A [De Bruijn index][dbi] is a standard means of representing
|
/// A [De Bruijn index][dbi] is a standard means of representing
|
||||||
/// regions (and perhaps later types) in a higher-ranked setting. In
|
/// regions (and perhaps later types) in a higher-ranked setting. In
|
||||||
/// particular, imagine a type like this:
|
/// particular, imagine a type like this:
|
||||||
|
|
Loading…
Reference in a new issue