aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile.cc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-10-22 09:51:12 +0000
committerGitHub <noreply@github.com>2021-10-22 09:51:12 +0000
commit2cd9855d914e760f4c74ac01ad2f7e9378cd80fa (patch)
tree7f12c08f5759feff35a0bd48cbae6a997c9a4ed5 /gcc/rust/backend/rust-compile.cc
parent9edda157230e0272309ca1133145984385f99e64 (diff)
parenta1b0df02414eb323dac53dc07702861a9d4b63b6 (diff)
downloadgcc-2cd9855d914e760f4c74ac01ad2f7e9378cd80fa.zip
gcc-2cd9855d914e760f4c74ac01ad2f7e9378cd80fa.tar.gz
gcc-2cd9855d914e760f4c74ac01ad2f7e9378cd80fa.tar.bz2
Merge #756
756: Add const to enforce ownership over pointers r=philberty a=philberty This consify's a bunch of interfaces in the code base which helps make the ownership over pointers more clear. These are building blocks from a wider cleanup of the type-checking code to make it more readable. - BaseType::get_root - SubstitutionArgumentMappings::solve_mappings_from_receiver_for_self - Autoderef adjustments - GetUsedSubstArgs - SubstitutionArg field SubstitutionParamMapping - Backend resolve compile interface Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile.cc')
-rw-r--r--gcc/rust/backend/rust-compile.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc
index 23a035f..56d3e40 100644
--- a/gcc/rust/backend/rust-compile.cc
+++ b/gcc/rust/backend/rust-compile.cc
@@ -234,8 +234,8 @@ CompileExpr::visit (HIR::MethodCallExpr &expr)
if (is_dyn_dispatch)
{
- TyTy::DynamicObjectType *dyn
- = static_cast<TyTy::DynamicObjectType *> (receiver->get_root ());
+ const TyTy::DynamicObjectType *dyn
+ = static_cast<const TyTy::DynamicObjectType *> (receiver->get_root ());
size_t offs = 0;
const Resolver::TraitItemReference *ref = nullptr;
@@ -763,8 +763,8 @@ HIRCompileBase::coercion_site (Bexpression *compiled_ref,
if (root_expected_kind == TyTy::TypeKind::DYNAMIC
&& root_actual_kind != TyTy::TypeKind::DYNAMIC)
{
- TyTy::DynamicObjectType *dyn
- = static_cast<TyTy::DynamicObjectType *> (expected->get_root ());
+ const TyTy::DynamicObjectType *dyn
+ = static_cast<const TyTy::DynamicObjectType *> (expected->get_root ());
return coerce_to_dyn_object (compiled_ref, actual, expected, dyn, locus);
}
@@ -773,9 +773,9 @@ HIRCompileBase::coercion_site (Bexpression *compiled_ref,
Bexpression *
HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref,
- TyTy::BaseType *actual,
- TyTy::BaseType *expected,
- TyTy::DynamicObjectType *ty,
+ const TyTy::BaseType *actual,
+ const TyTy::BaseType *expected,
+ const TyTy::DynamicObjectType *ty,
Location locus)
{
Btype *dynamic_object = TyTyResolveCompile::compile (ctx, ty);
@@ -814,7 +814,7 @@ HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref,
std::vector<Resolver::Adjustment> adjustments;
while (e->get_kind () == TyTy::TypeKind::REF)
{
- auto r = static_cast<TyTy::ReferenceType *> (e);
+ auto r = static_cast<const TyTy::ReferenceType *> (e);
e = r->get_base ();
if (r->is_mutable ())
@@ -845,7 +845,8 @@ HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref,
Bexpression *
HIRCompileBase::compute_address_for_trait_item (
- const Resolver::TraitItemReference *trait_item_ref, TyTy::BaseType *receiver)
+ const Resolver::TraitItemReference *trait_item_ref,
+ const TyTy::BaseType *receiver)
{
TyTy::BaseType *item_type = trait_item_ref->get_tyty ();
rust_assert (item_type->get_kind () == TyTy::TypeKind::FNDEF);