mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-01 12:37:37 +00:00
![]() The `mir!` macro has multiple parts: - An optional return type annotation. - A sequence of zero or more local declarations. - A mandatory starting anonymous basic block, which is brace-delimited. - A sequence of zero of more additional named basic blocks. Some `mir!` invocations use braces with a "block" style, like so: ``` mir! { let _unit: (); { let non_copy = S(42); let ptr = std::ptr::addr_of_mut!(non_copy); // Inside `callee`, the first argument and `*ptr` are basically // aliasing places! Call(_unit = callee(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue()) } after_call = { Return() } } ``` Some invocations use parens with a "block" style, like so: ``` mir!( let x: [i32; 2]; let one: i32; { x = [42, 43]; one = 1; x = [one, 2]; RET = Move(x); Return() } ) ``` And some invocations uses parens with a "tighter" style, like so: ``` mir!({ SetDiscriminant(*b, 0); Return() }) ``` This last style is generally used for cases where just the mandatory starting basic block is present. Its braces are placed next to the parens. This commit changes all `mir!` invocations to use braces with a "block" style. Why? - Consistency is good. - The contents of the invocation is a block of code, so it's odd to use parens. They are more normally used for function-like macros. - Most importantly, the next commit will enable rustfmt for `tests/mir-opt/`. rustfmt is more aggressive about formatting macros that use parens than macros that use braces. Without this commit's changes, rustfmt would break a couple of `mir!` macro invocations that use braces within `tests/mir-opt` by inserting an extraneous comma. E.g.: ``` mir!(type RET = (i32, bool);, { // extraneous comma after ';' RET.0 = 1; RET.1 = true; Return() }) ``` Switching those `mir!` invocations to use braces avoids that problem, resulting in this, which is nicer to read as well as being valid syntax: ``` mir! { type RET = (i32, bool); { RET.0 = 1; RET.1 = true; Return() } } ``` |
||
---|---|---|
.. | ||
coroutine | ||
coverage | ||
inline | ||
shim | ||
abort_unwinding_calls.rs | ||
add_call_guards.rs | ||
add_moves_for_packed_drops.rs | ||
add_retag.rs | ||
add_subtyping_projections.rs | ||
check_alignment.rs | ||
check_const_item_mutation.rs | ||
check_packed_ref.rs | ||
cleanup_post_borrowck.rs | ||
const_debuginfo.rs | ||
copy_prop.rs | ||
coroutine.rs | ||
cost_checker.rs | ||
cross_crate_inline.rs | ||
ctfe_limit.rs | ||
dataflow_const_prop.rs | ||
dead_store_elimination.rs | ||
deduce_param_attrs.rs | ||
deduplicate_blocks.rs | ||
deref_separator.rs | ||
dest_prop.rs | ||
dump_mir.rs | ||
early_otherwise_branch.rs | ||
elaborate_box_derefs.rs | ||
elaborate_drops.rs | ||
errors.rs | ||
ffi_unwind_calls.rs | ||
function_item_references.rs | ||
gvn.rs | ||
inline.rs | ||
instsimplify.rs | ||
jump_threading.rs | ||
known_panics_lint.rs | ||
large_enums.rs | ||
lib.rs | ||
lint.rs | ||
lower_intrinsics.rs | ||
lower_slice_len.rs | ||
match_branches.rs | ||
mentioned_items.rs | ||
multiple_return_terminators.rs | ||
normalize_array_len.rs | ||
nrvo.rs | ||
pass_manager.rs | ||
prettify.rs | ||
promote_consts.rs | ||
ref_prop.rs | ||
remove_noop_landing_pads.rs | ||
remove_place_mention.rs | ||
remove_storage_markers.rs | ||
remove_uninit_drops.rs | ||
remove_unneeded_drops.rs | ||
remove_zsts.rs | ||
required_consts.rs | ||
reveal_all.rs | ||
shim.rs | ||
simplify_branches.rs | ||
simplify_comparison_integral.rs | ||
simplify.rs | ||
sroa.rs | ||
ssa.rs | ||
unreachable_enum_branching.rs | ||
unreachable_prop.rs | ||
validate.rs |