diff options
| author | Andy Wang <cbeuw.andy@gmail.com> | 2023-03-20 15:23:27 +0100 |
|---|---|---|
| committer | Andy Wang <cbeuw.andy@gmail.com> | 2023-03-20 15:23:27 +0100 |
| commit | 9dc275bb54ab088ac85a08dc807984afd57a78c7 (patch) | |
| tree | 55a5064272a3b012cb51a99394a7b78f34036235 | |
| parent | 9da1da94efd45cf28e9e72c81cacbdbcb1aeabd1 (diff) | |
| download | rust-9dc275bb54ab088ac85a08dc807984afd57a78c7.tar.gz rust-9dc275bb54ab088ac85a08dc807984afd57a78c7.zip | |
Add documentation for `type RET = ...`
| -rw-r--r-- | library/core/src/intrinsics/mir.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/library/core/src/intrinsics/mir.rs b/library/core/src/intrinsics/mir.rs index f391474b843..77e207ecc6c 100644 --- a/library/core/src/intrinsics/mir.rs +++ b/library/core/src/intrinsics/mir.rs @@ -49,6 +49,8 @@ //! //! 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 //! 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. @@ -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 |
