aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorbadumbatish <tanghocle456@gmail.com>2024-08-02 11:36:04 -0700
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-19 15:32:07 +0100
commit8b810b2c5d0e880759280bfa63afe2494d85ff8a (patch)
tree3791ef1ac2a878b8fed3dc26cbaa902302926caf /gcc/rust
parent0bad7500da4f08d03e668cbba8935a9f0803664c (diff)
downloadgcc-8b810b2c5d0e880759280bfa63afe2494d85ff8a.zip
gcc-8b810b2c5d0e880759280bfa63afe2494d85ff8a.tar.gz
gcc-8b810b2c5d0e880759280bfa63afe2494d85ff8a.tar.bz2
gccrs: Added noreturn checking for nevertype, new test
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Added noreturn checking for nevertype gcc/testsuite/ChangeLog: * rust/compile/inline_asm_typecheck.rs: New test.
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index a9255fc..ba22eaf 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
@@ -623,10 +623,9 @@ TypeCheckExpr::visit (HIR::BlockExpr &expr)
&& (((TyTy::InferType *) loop_context_type)->get_infer_kind ()
!= TyTy::InferType::GENERAL));
- infered = loop_context_type_infered
- ? loop_context_type
- : TyTy::TupleType::get_unit_type (
- expr.get_mappings ().get_hirid ());
+ infered = loop_context_type_infered ? loop_context_type
+ : TyTy::TupleType::get_unit_type (
+ expr.get_mappings ().get_hirid ());
}
else
{
@@ -829,9 +828,14 @@ TypeCheckExpr::visit (HIR::InlineAsm &expr)
{
typecheck_inline_asm_operand (expr);
- // TODO: Hoise out if we have noreturn as an option
+ // NOTE: Hoise out if we have noreturn as an option
// to return a never type
- infered = TyTy::TupleType::get_unit_type (expr.get_mappings ().get_hirid ());
+ // TODO : new keyword for memory seems sooooo shaky
+ if (expr.options.count (AST::InlineAsmOption::NORETURN) == 1)
+ infered = new TyTy::NeverType (expr.get_mappings ().get_hirid ());
+ else
+ infered
+ = TyTy::TupleType::get_unit_type (expr.get_mappings ().get_hirid ());
}
void
@@ -1625,7 +1629,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
TyTy::TyVar result_type
= expr.has_return_type ()
? TyTy::TyVar (
- TypeCheckType::Resolve (expr.get_return_type ().get ())->get_ref ())
+ TypeCheckType::Resolve (expr.get_return_type ().get ())->get_ref ())
: TyTy::TyVar::get_implicit_infer_var (expr.get_locus ());
// resolve the block