Skip to content

Commit 11f0dca

Browse files
committed
Auto merge of rust-lang#109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#109373 (Set LLVM `LLVM_UNREACHABLE_OPTIMIZE` to `OFF`) - rust-lang#109392 (Custom MIR: Allow optional RET type annotation) - rust-lang#109394 (adapt tests/codegen/vec-shrink-panik for LLVM 17) - rust-lang#109412 (rustdoc: Add GUI test for "Auto-hide item contents for large items" setting) - rust-lang#109452 (Ignore the vendor directory for tidy tests.) - rust-lang#109457 (Remove comment about reusing rib allocations) - rust-lang#109461 (rustdoc: remove redundant `.content` prefix from span/a colors) - rust-lang#109477 (`HirId` to `LocalDefId` cleanup) - rust-lang#109489 (More general captures) - rust-lang#109494 (Do not feed param_env for RPITITs impl side) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4fd4e68 + d649fa8 commit 11f0dca

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

core/src/intrinsics/mir.rs

Lines changed: 16 additions & 1 deletion
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
@@ -342,6 +356,7 @@ define!(
342356
#[rustc_macro_transparency = "transparent"]
343357
pub macro mir {
344358
(
359+
$(type RET = $ret_ty:ty ;)?
345360
$(let $local_decl:ident $(: $local_decl_ty:ty)? ;)*
346361

347362
{
@@ -362,7 +377,7 @@ pub macro mir {
362377
{
363378
// Now all locals
364379
#[allow(non_snake_case)]
365-
let RET;
380+
let RET $(: $ret_ty)?;
366381
$(
367382
let $local_decl $(: $local_decl_ty)? ;
368383
)*

0 commit comments

Comments
 (0)