Skip to content

Commit 3be9af1

Browse files
authored
Rollup merge of rust-lang#115000 - RalfJung:custom-mir-call, r=compiler-errors,JakobDegen
custom_mir: change Call() terminator syntax to something more readable I find our current syntax very hard to read -- I cannot even remember the order of arguments, and having the "next block" *before* the actual function call is very counter-intuitive IMO. So I suggest we use `Call(ret_val = function(v), next_block)` instead. r? `@JakobDegen`
2 parents 0d398fe + b6e228c commit 3be9af1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core/src/intrinsics/mir.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,18 @@
104104
//! }
105105
//!
106106
//! #[custom_mir(dialect = "runtime", phase = "optimized")]
107+
#![cfg_attr(bootstrap, doc = "#[cfg(any())]")] // disable the following function in doctests when `bootstrap` is set
107108
//! fn push_and_pop<T>(v: &mut Vec<T>, value: T) {
108109
//! mir!(
109-
//! let unused;
110+
//! let _unused;
110111
//! let popped;
111112
//!
112113
//! {
113-
//! Call(unused, pop, Vec::push(v, value))
114+
//! Call(_unused = Vec::push(v, value), pop)
114115
//! }
115116
//!
116117
//! pop = {
117-
//! Call(popped, drop, Vec::pop(v))
118+
//! Call(popped = Vec::pop(v), drop)
118119
//! }
119120
//!
120121
//! drop = {
@@ -275,7 +276,7 @@ define!("mir_return", fn Return() -> BasicBlock);
275276
define!("mir_goto", fn Goto(destination: BasicBlock) -> BasicBlock);
276277
define!("mir_unreachable", fn Unreachable() -> BasicBlock);
277278
define!("mir_drop", fn Drop<T>(place: T, goto: BasicBlock));
278-
define!("mir_call", fn Call<T>(place: T, goto: BasicBlock, call: T));
279+
define!("mir_call", fn Call(call: (), goto: BasicBlock));
279280
define!("mir_storage_live", fn StorageLive<T>(local: T));
280281
define!("mir_storage_dead", fn StorageDead<T>(local: T));
281282
define!("mir_deinit", fn Deinit<T>(place: T));

0 commit comments

Comments
 (0)