aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-context.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-07-19 19:32:41 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-07-19 19:38:51 +0100
commitf56781662f82dcbe1780cbe3e7eb4ac17f8156d0 (patch)
treec9119796d4330f6dda5d93f85de80044de723cb4 /gcc/rust/backend/rust-compile-context.h
parent0cbd3afc714a1d874fd829108f9b51a44205c050 (diff)
downloadgcc-f56781662f82dcbe1780cbe3e7eb4ac17f8156d0.zip
gcc-f56781662f82dcbe1780cbe3e7eb4ac17f8156d0.tar.gz
gcc-f56781662f82dcbe1780cbe3e7eb4ac17f8156d0.tar.bz2
Assignments are a coercion site in rust
This implements the reference mutability coercion rules, where the base types must be compatible and the base can turn a mutable reference into a constant one. Address #434 Fixes #576
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r--gcc/rust/backend/rust-compile-context.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h
index d822937..efca267 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -537,6 +537,10 @@ public:
Btype *base_compiled_type
= TyTyResolveCompile::compile (ctx, type.get_base ());
translated = ctx->get_backend ()->reference_type (base_compiled_type);
+ if (!type.is_mutable ())
+ {
+ translated = ctx->get_backend ()->immutable_type (translated);
+ }
}
void visit (TyTy::StrType &type) override