diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-04-22 10:04:28 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-22 10:04:28 +0000 |
| commit | 75ac2f6fc0a12a7f75abfd5bcd79e508f5ae8fc7 (patch) | |
| tree | f8ca158263c81e7e0db67b066ffee1ca2608938e /gcc/rust | |
| parent | f0b6dca3fcd6f435a0c0fc5c60c4bfba088930dd (diff) | |
| parent | 639b3d61ab124ab14e0935893abe437ed7f6ad52 (diff) | |
| download | gcc-75ac2f6fc0a12a7f75abfd5bcd79e508f5ae8fc7.zip gcc-75ac2f6fc0a12a7f75abfd5bcd79e508f5ae8fc7.tar.gz gcc-75ac2f6fc0a12a7f75abfd5bcd79e508f5ae8fc7.tar.bz2 | |
Merge #1147
1147: Add missing coercion rule from array to slice r=philberty a=philberty
Arrays are coercible into slices, this adds the missing type-resolution
the rule which works for now. The other part of this fix is described in #1146
for coercion_site to be recursive and reuse the adjustment classes so that
we reuse as much code as possible and handle complex coercion sites.
Fixes #1129
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust')
| -rw-r--r-- | gcc/rust/typecheck/rust-tyty-coercion.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-coercion.h b/gcc/rust/typecheck/rust-tyty-coercion.h index c24f17e..e13c7f8 100644 --- a/gcc/rust/typecheck/rust-tyty-coercion.h +++ b/gcc/rust/typecheck/rust-tyty-coercion.h @@ -886,6 +886,22 @@ public: TyVar (base_resolved->get_ref ())); } + void visit (ArrayType &type) override + { + // check base type + auto base_resolved + = base->get_element_type ()->unify (type.get_element_type ()); + if (base_resolved == nullptr) + { + BaseCoercionRules::visit (type); + return; + } + + resolved = new SliceType (type.get_ref (), type.get_ty_ref (), + type.get_ident ().locus, + TyVar (base_resolved->get_ref ())); + } + private: BaseType *get_base () override { return base; } |
