&& (((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
{
{
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
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
--- /dev/null
+#![feature(rustc_attrs)]
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+ () => {};
+}
+
+fn main() {
+ let mut _num1: i32 = 10;
+ let mut _num2: i32 = 10;
+ unsafe {
+ // This demonstrates that asm!'s is inferred with a unit type is parsed correctly.
+ let _ = asm!("nop");
+
+ // This errors out per rust spec
+ // The asm! block never returns, and its return type is defined as ! (never).
+ // Behavior is undefined if execution falls through past the end of the asm code.
+ // A noreturn asm block behaves just like a function which doesn't return; notably, local variables in scope are not dropped before it is invoked.
+ let _ = asm!("nop", options(noreturn));
+ }
+}