summary refs log tree commit diff
path: root/tests/mir-opt/instsimplify
AgeCommit message (Collapse)AuthorLines
2024-06-03rustfmt `tests/mir-opt`.Nicholas Nethercote-4/+7
The only non-obvious changes: - `building/storage_live_dead_in_statics.rs` has a `#[rustfmt::skip]` attribute to avoid reformating a table of data. - Two `.mir` files have slight changes involving line numbers. - In `unusual_item_types.rs` an `EMIT_MIR` annotation is moved to outside a function, which is the usual spot, because `tidy` complains if such a comment is indented. The commit also tweaks the comments in `rustfmt.toml`.
2024-06-03Reformat `mir!` macro invocations to use braces.Nicholas Nethercote-2/+2
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() } } ```
2024-05-30Also InstSimplify `&raw*`Scott McMurray-0/+156
We do this for `&*` and `&mut*` already; might as well do it for raw pointers too.
2024-04-22Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnayGuillaume Gomez-1/+0
Stabilize generic `NonZero`. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-21InstSimplify `from_raw_parts(p, ())` → `p as _`Scott McMurray-0/+9
2024-04-20mir-opt tests: rename unit-test -> test-mir-passRalf Jung-8/+8
2024-04-18At debuginfo=0, don't inline debuginfo when inliningScott McMurray-3/+0
2024-04-03Remove MIR unsafe checkMatthew Jasper-17/+11
This also remove safety information from MIR.
2024-03-27Eliminate `UbCheck` for non-standard librariesDianQK-0/+75
2024-03-10MIR printing: print the path of uneval'd const; refer to promoteds in a ↵Ralf Jung-1/+1
consistent way
2024-02-25Use generic `NonZero` in tests.Markus Reiter-2/+2
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-9/+9
2024-01-27Update tests.Markus Reiter-2/+2
2023-10-25Never consider raw pointer casts to be trivalNilstrieb-15/+25
HIR typeck tries to figure out which casts are trivial by doing them as coercions and seeing whether this works. Since HIR typeck is oblivious of lifetimes, this doesn't work for pointer casts that only change the lifetime of the pointee, which are, as borrowck will tell you, not trivial. This change makes it so that raw pointer casts are never considered trivial. This also incidentally fixes the "trivial cast" lint false positive on the same code. Unfortunately, "trivial cast" lints are now never emitted on raw pointer casts, even if they truly are trivial. This could be fixed by also doing the lint in borrowck for raw pointers specifically.
2023-10-19FileCheck casts.Camille GILLOT-0/+75
2023-10-19FileCheck combine_transmutes.Camille GILLOT-0/+211
2023-10-19FileCheck duplicate_switch_targets.Camille GILLOT-0/+50
2023-10-19FileCheck intrinsic_asserts.Camille GILLOT-0/+174
2023-10-19FileCheck combine_clone_of_primitives.Camille GILLOT-0/+162
2023-10-19FileCheck bool_compare.Camille GILLOT-0/+356
2023-10-19FileCheck combine_array_len.Camille GILLOT-0/+169