/// Types for locals
type LocalDecls<'tcx> = IndexVec<Local, LocalDecl<'tcx>>;
-pub trait AsLocalDeclsRef<'tcx> {
- fn as_ref(&self) -> &LocalDecls<'tcx>;
+pub trait HasLocalDecls<'tcx> {
+ fn local_decls(&self) -> &LocalDecls<'tcx>;
}
-impl<'tcx> AsLocalDeclsRef<'tcx> for LocalDecls<'tcx> {
- fn as_ref(&self) -> &LocalDecls<'tcx> {
+impl<'tcx> HasLocalDecls<'tcx> for LocalDecls<'tcx> {
+ fn local_decls(&self) -> &LocalDecls<'tcx> {
self
}
}
-impl<'tcx> AsLocalDeclsRef<'tcx> for Mir<'tcx> {
- fn as_ref(&self) -> &LocalDecls<'tcx> {
+impl<'tcx> HasLocalDecls<'tcx> for Mir<'tcx> {
+ fn local_decls(&self) -> &LocalDecls<'tcx> {
&self.local_decls
}
}
}
impl<'tcx> Lvalue<'tcx> {
- pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> LvalueTy<'tcx> {
+ pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> LvalueTy<'tcx> {
match *self {
Lvalue::Local(index) =>
- LvalueTy::Ty { ty: local_decls.as_ref()[index].ty },
+ LvalueTy::Ty { ty: local_decls.local_decls()[index].ty },
Lvalue::Static(ref data) =>
LvalueTy::Ty { ty: data.ty },
Lvalue::Projection(ref proj) =>
}
impl<'tcx> Rvalue<'tcx> {
- pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>
+ pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>
{
match *self {
Rvalue::Use(ref operand) => operand.ty(local_decls, tcx),
}
impl<'tcx> Operand<'tcx> {
- pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
+ pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
match self {
&Operand::Consume(ref l) => l.ty(local_decls, tcx).to_ty(tcx),
&Operand::Constant(ref c) => c.ty,