Add documentation for type RET = ...

This commit is contained in:
Andy Wang 2023-03-20 15:23:27 +01:00
parent 9da1da94ef
commit 9dc275bb54
No known key found for this signature in database
GPG Key ID: 181B49F9F38F3374

View File

@ -49,6 +49,8 @@
//! //!
//! The input to the [`mir!`] macro is: //! The input to the [`mir!`] macro is:
//! //!
//! - An optional return type annotation in the form of `type RET = ...;`. This may be required
//! if the compiler cannot infer the type of RET.
//! - A possibly empty list of local declarations. Locals can also be declared inline on //! - A possibly empty list of local declarations. Locals can also be declared inline on
//! assignments via `let`. Type inference generally works. Shadowing does not. //! assignments via `let`. Type inference generally works. Shadowing does not.
//! - A list of basic blocks. The first of these is the start block and is where execution begins. //! - A list of basic blocks. The first of these is the start block and is where execution begins.
@ -124,6 +126,18 @@
//! } //! }
//! ) //! )
//! } //! }
//!
//! #[custom_mir(dialect = "runtime", phase = "optimized")]
//! fn annotated_return_type() -> (i32, bool) {
//! mir!(
//! type RET = (i32, bool);
//! {
//! RET.0 = 1;
//! RET.1 = true;
//! Return()
//! }
//! )
//! }
//! ``` //! ```
//! //!
//! We can also set off compilation failures that happen in sufficiently late stages of the //! We can also set off compilation failures that happen in sufficiently late stages of the