]> git.lizzy.rs Git - rust.git/commitdiff
rename trait to conform with 'getter trait' pattern
authorRalf Jung <post@ralfj.de>
Wed, 12 Jul 2017 20:15:29 +0000 (13:15 -0700)
committerRalf Jung <post@ralfj.de>
Wed, 12 Jul 2017 20:15:29 +0000 (13:15 -0700)
src/librustc/mir/mod.rs
src/librustc/mir/tcx.rs

index ba38d97d09261737a020f666a5ee899359faa0b2..d176ae761e181aa03460c7dc92262196fa8aa7b9 100644 (file)
@@ -69,18 +69,18 @@ fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
 /// 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
     }
 }
index c99fffe2198b8a12de74d38d95215e285b91cc9b..d3b87c1201dcfacd444b027dd3ac4b4bd1528baa 100644 (file)
@@ -121,10 +121,10 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
 }
 
 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) =>
@@ -134,7 +134,7 @@ pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtx
 }
 
 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),
@@ -206,7 +206,7 @@ pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtx
 }
 
 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,