diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-04-22 10:24:46 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-04-22 10:24:46 +0100 |
commit | 7915329a0c552245488710d7561a6a76f784c0a7 (patch) | |
tree | 2d96d02b9907a9b28273d60b91c6e10dd58f6ffd /gcc/rust | |
parent | 243ef0dfe713a9fc8d4d80feb488a58b2639f39f (diff) | |
download | gcc-7915329a0c552245488710d7561a6a76f784c0a7.zip gcc-7915329a0c552245488710d7561a6a76f784c0a7.tar.gz gcc-7915329a0c552245488710d7561a6a76f784c0a7.tar.bz2 |
Add support for isize and usize type-hints
This bug turned out to be that we expected a usize for the array capacity
but the specified capacity turned out to be an integer inference variable
which will default to a signed integer. The type resolution was missing
handling the type-hints of isize and usize
Fixes #1152
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-base.cc | 8 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-expr.h | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc b/gcc/rust/typecheck/rust-hir-type-check-base.cc index a924866..4e8fa26 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-base.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc @@ -133,6 +133,14 @@ TypeCheckBase::resolve_literal (const Analysis::NodeMapping &expr_mappings, ok = context->lookup_builtin ("f64", &infered); break; + case CORETYPE_ISIZE: + ok = context->lookup_builtin ("isize", &infered); + break; + + case CORETYPE_USIZE: + ok = context->lookup_builtin ("usize", &infered); + break; + default: ok = true; infered diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h index 5db00a4..630eb60 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.h +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h @@ -619,6 +619,8 @@ public: = (negated_expr_ty->get_kind () == TyTy::TypeKind::INT) || (negated_expr_ty->get_kind () == TyTy::TypeKind::UINT) || (negated_expr_ty->get_kind () == TyTy::TypeKind::FLOAT) + || (negated_expr_ty->get_kind () == TyTy::TypeKind::ISIZE) + || (negated_expr_ty->get_kind () == TyTy::TypeKind::USIZE) || (negated_expr_ty->get_kind () == TyTy::TypeKind::INFER && (((TyTy::InferType *) negated_expr_ty)->get_infer_kind () == TyTy::InferType::INTEGRAL)) |