diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-10-20 16:13:16 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-10-22 10:13:06 +0100 |
commit | 9cdaff9f5aa4174bad954df3b186865e3b73918b (patch) | |
tree | 118fe53c2fd096f0f2d701abf5da6d2c3895a169 | |
parent | 3eea0076f235e854da519da50f0af4e99d31634b (diff) | |
download | gcc-9cdaff9f5aa4174bad954df3b186865e3b73918b.zip gcc-9cdaff9f5aa4174bad954df3b186865e3b73918b.tar.gz gcc-9cdaff9f5aa4174bad954df3b186865e3b73918b.tar.bz2 |
Constify GetUsedSubstArgs
This mapper class does not need mutability and can easily be made const
enforcing ownership.
-rw-r--r-- | gcc/rust/typecheck/rust-substitution-mapper.h | 50 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.h | 2 |
2 files changed, 26 insertions, 26 deletions
diff --git a/gcc/rust/typecheck/rust-substitution-mapper.h b/gcc/rust/typecheck/rust-substitution-mapper.h index a6e7e80..b7c23fb 100644 --- a/gcc/rust/typecheck/rust-substitution-mapper.h +++ b/gcc/rust/typecheck/rust-substitution-mapper.h @@ -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 ()) {} diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 03e3296..7cd99f2 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -884,7 +884,7 @@ public: bool was_substituted () const { return !needs_substitution (); } - SubstitutionArgumentMappings get_substitution_arguments () + SubstitutionArgumentMappings get_substitution_arguments () const { return used_arguments; } |