File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 49
49
//!
50
50
//! The input to the [`mir!`] macro is:
51
51
//!
52
+ //! - An optional return type annotation in the form of `type RET = ...;`. This may be required
53
+ //! if the compiler cannot infer the type of RET.
52
54
//! - A possibly empty list of local declarations. Locals can also be declared inline on
53
55
//! assignments via `let`. Type inference generally works. Shadowing does not.
54
56
//! - A list of basic blocks. The first of these is the start block and is where execution begins.
124
126
//! }
125
127
//! )
126
128
//! }
129
+ //!
130
+ //! #[custom_mir(dialect = "runtime", phase = "optimized")]
131
+ //! fn annotated_return_type() -> (i32, bool) {
132
+ //! mir!(
133
+ //! type RET = (i32, bool);
134
+ //! {
135
+ //! RET.0 = 1;
136
+ //! RET.1 = true;
137
+ //! Return()
138
+ //! }
139
+ //! )
140
+ //! }
127
141
//! ```
128
142
//!
129
143
//! We can also set off compilation failures that happen in sufficiently late stages of the
@@ -342,6 +356,7 @@ define!(
342
356
#[ rustc_macro_transparency = "transparent" ]
343
357
pub macro mir {
344
358
(
359
+ $( type RET = $ret_ty: ty ; ) ?
345
360
$( let $local_decl: ident $( : $local_decl_ty: ty) ? ; ) *
346
361
347
362
{
@@ -362,7 +377,7 @@ pub macro mir {
362
377
{
363
378
// Now all locals
364
379
#[ allow( non_snake_case) ]
365
- let RET ;
380
+ let RET $ ( : $ret_ty ) ? ;
366
381
$(
367
382
let $local_decl $( : $local_decl_ty) ? ;
368
383
) *
You can’t perform that action at this time.
0 commit comments