Skip to content

Commit 9dc275b

Browse files
committed
Add documentation for type RET = ...
1 parent 9da1da9 commit 9dc275b

File tree

1 file changed

+14
-0
lines changed
  • library/core/src/intrinsics

1 file changed

+14
-0
lines changed

library/core/src/intrinsics/mir.rs

+14
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
//!
5050
//! The input to the [`mir!`] macro is:
5151
//!
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.
5254
//! - A possibly empty list of local declarations. Locals can also be declared inline on
5355
//! assignments via `let`. Type inference generally works. Shadowing does not.
5456
//! - A list of basic blocks. The first of these is the start block and is where execution begins.
@@ -124,6 +126,18 @@
124126
//! }
125127
//! )
126128
//! }
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+
//! }
127141
//! ```
128142
//!
129143
//! We can also set off compilation failures that happen in sufficiently late stages of the

0 commit comments

Comments
 (0)