mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Allow optional RET type annotation
This commit is contained in:
parent
ab9bb3ea36
commit
9da1da94ef
@ -342,6 +342,7 @@ define!(
|
||||
#[rustc_macro_transparency = "transparent"]
|
||||
pub macro mir {
|
||||
(
|
||||
$(type RET = $ret_ty:ty ;)?
|
||||
$(let $local_decl:ident $(: $local_decl_ty:ty)? ;)*
|
||||
|
||||
{
|
||||
@ -362,7 +363,7 @@ pub macro mir {
|
||||
{
|
||||
// Now all locals
|
||||
#[allow(non_snake_case)]
|
||||
let RET;
|
||||
let RET $(: $ret_ty)?;
|
||||
$(
|
||||
let $local_decl $(: $local_decl_ty)? ;
|
||||
)*
|
||||
|
21
tests/mir-opt/building/custom/composite_return.rs
Normal file
21
tests/mir-opt/building/custom/composite_return.rs
Normal file
@ -0,0 +1,21 @@
|
||||
#![feature(custom_mir, core_intrinsics)]
|
||||
|
||||
extern crate core;
|
||||
use core::intrinsics::mir::*;
|
||||
|
||||
// EMIT_MIR composite_return.tuple.built.after.mir
|
||||
#[custom_mir(dialect = "runtime", phase = "optimized")]
|
||||
fn tuple() -> (i32, bool) {
|
||||
mir!(
|
||||
type RET = (i32, bool);
|
||||
{
|
||||
RET.0 = 1;
|
||||
RET.1 = true;
|
||||
Return()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(tuple(), (1, true));
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
// MIR for `tuple` after built
|
||||
|
||||
fn tuple() -> (i32, bool) {
|
||||
let mut _0: (i32, bool); // return place in scope 0 at $DIR/composite_return.rs:+0:15: +0:26
|
||||
|
||||
bb0: {
|
||||
(_0.0: i32) = const 1_i32; // scope 0 at $DIR/composite_return.rs:+4:13: +4:22
|
||||
(_0.1: bool) = const true; // scope 0 at $DIR/composite_return.rs:+5:13: +5:25
|
||||
return; // scope 0 at $DIR/composite_return.rs:+6:13: +6:21
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user