]> gcc.gnu.org Git - gcc.git/commitdiff
Constify GetUsedSubstArgs
authorPhilip Herron <philip.herron@embecosm.com>
Wed, 20 Oct 2021 15:13:16 +0000 (16:13 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Fri, 22 Oct 2021 09:13:06 +0000 (10:13 +0100)
This mapper class does not need mutability and can easily be made const
enforcing ownership.

gcc/rust/typecheck/rust-substitution-mapper.h
gcc/rust/typecheck/rust-tyty.h

index a6e7e8080c26e8fe091e90a6d7e08ee59a3c7794..b7c23fb19c3d768c1d8c9abc63a934baf3af2d23 100644 (file)
@@ -317,51 +317,51 @@ private:
   TyTy::BaseType *resolved;
 };
 
-class GetUsedSubstArgs : public TyTy::TyVisitor
+class GetUsedSubstArgs : public TyTy::TyConstVisitor
 {
 public:
-  static TyTy::SubstitutionArgumentMappings From (TyTy::BaseType *from)
+  static TyTy::SubstitutionArgumentMappings From (const TyTy::BaseType *from)
   {
     GetUsedSubstArgs mapper;
     from->accept_vis (mapper);
     return mapper.args;
   }
 
-  void visit (TyTy::FnType &type) override
+  void visit (const TyTy::FnType &type) override
   {
     args = type.get_substitution_arguments ();
   }
 
-  void visit (TyTy::ADTType &type) override
+  void visit (const TyTy::ADTType &type) override
   {
     args = type.get_substitution_arguments ();
   }
 
-  void visit (TyTy::ClosureType &type) override
+  void visit (const TyTy::ClosureType &type) override
   {
     args = type.get_substitution_arguments ();
   }
 
-  void visit (TyTy::InferType &) override {}
-  void visit (TyTy::TupleType &) override {}
-  void visit (TyTy::FnPtr &) override {}
-  void visit (TyTy::ArrayType &) override {}
-  void visit (TyTy::BoolType &) override {}
-  void visit (TyTy::IntType &) override {}
-  void visit (TyTy::UintType &) override {}
-  void visit (TyTy::FloatType &) override {}
-  void visit (TyTy::USizeType &) override {}
-  void visit (TyTy::ISizeType &) override {}
-  void visit (TyTy::ErrorType &) override {}
-  void visit (TyTy::CharType &) override {}
-  void visit (TyTy::ReferenceType &) override {}
-  void visit (TyTy::PointerType &) override {}
-  void visit (TyTy::ParamType &) override {}
-  void visit (TyTy::StrType &) override {}
-  void visit (TyTy::NeverType &) override {}
-  void visit (TyTy::PlaceholderType &) override {}
-  void visit (TyTy::ProjectionType &) override {}
-  void visit (TyTy::DynamicObjectType &) override {}
+  void visit (const TyTy::InferType &) override {}
+  void visit (const TyTy::TupleType &) override {}
+  void visit (const TyTy::FnPtr &) override {}
+  void visit (const TyTy::ArrayType &) override {}
+  void visit (const TyTy::BoolType &) override {}
+  void visit (const TyTy::IntType &) override {}
+  void visit (const TyTy::UintType &) override {}
+  void visit (const TyTy::FloatType &) override {}
+  void visit (const TyTy::USizeType &) override {}
+  void visit (const TyTy::ISizeType &) override {}
+  void visit (const TyTy::ErrorType &) override {}
+  void visit (const TyTy::CharType &) override {}
+  void visit (const TyTy::ReferenceType &) override {}
+  void visit (const TyTy::PointerType &) override {}
+  void visit (const TyTy::ParamType &) override {}
+  void visit (const TyTy::StrType &) override {}
+  void visit (const TyTy::NeverType &) override {}
+  void visit (const TyTy::PlaceholderType &) override {}
+  void visit (const TyTy::ProjectionType &) override {}
+  void visit (const TyTy::DynamicObjectType &) override {}
 
 private:
   GetUsedSubstArgs () : args (TyTy::SubstitutionArgumentMappings::error ()) {}
index 03e3296c6b54ba40e808b3d417d17a0bec6b46ac..7cd99f24d3d940b65a11f28bd5bffa6c89f5d09c 100644 (file)
@@ -884,7 +884,7 @@ public:
 
   bool was_substituted () const { return !needs_substitution (); }
 
-  SubstitutionArgumentMappings get_substitution_arguments ()
+  SubstitutionArgumentMappings get_substitution_arguments () const
   {
     return used_arguments;
   }
This page took 0.07149 seconds and 5 git commands to generate.