Skip to content

Commit 11c31bb

Browse files
varkoryodaldevoid
andcommitted
Add ParamConst
Co-Authored-By: Gabriel Smith <[email protected]>
1 parent 62f23c2 commit 11c31bb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/librustc/ty/sty.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,26 @@ impl<'a, 'gcx, 'tcx> ParamTy {
10611061
}
10621062
}
10631063

1064+
#[derive(Copy, Clone, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)]
1065+
pub struct ParamConst {
1066+
pub index: u32,
1067+
pub name: InternedString,
1068+
}
1069+
1070+
impl<'a, 'gcx, 'tcx> ParamConst {
1071+
pub fn new(index: u32, name: InternedString) -> ParamConst {
1072+
ParamConst { index, name }
1073+
}
1074+
1075+
pub fn for_def(def: &ty::GenericParamDef) -> ParamConst {
1076+
ParamConst::new(def.index, def.name)
1077+
}
1078+
1079+
pub fn to_const(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx LazyConst<'tcx> {
1080+
tcx.mk_const_param(self.index, self.name, ty)
1081+
}
1082+
}
1083+
10641084
/// A [De Bruijn index][dbi] is a standard means of representing
10651085
/// regions (and perhaps later types) in a higher-ranked setting. In
10661086
/// particular, imagine a type like this:

0 commit comments

Comments
 (0)