rust/tests/mir-opt/building
Matthias Krüger 9545ab8e12
Rollup merge of #109392 - cbeuw:composite-ret, r=JakobDegen
Custom MIR: Allow optional RET type annotation

This currently doesn't compile because the type of `RET` is inferred, which fails if RET is a composite type and fields are initialised separately.
```rust
#![feature(custom_mir, core_intrinsics)]
extern crate core;
use core::intrinsics::mir::*;
#[custom_mir(dialect = "runtime", phase = "optimized")]
fn fn0() -> (i32, bool) {
    mir! ({
        RET.0 = 0;
        RET.1 = true;
        Return()
    })
}
```
```
error[E0282]: type annotations needed
 --> src/lib.rs:8:9
  |
8 |         RET.0 = 0;
  |         ^^^ cannot infer type

For more information about this error, try `rustc --explain E0282`.
```

This PR allows the user to manually specify the return type with `type RET = ...;` if required:

```rust
#[custom_mir(dialect = "runtime", phase = "optimized")]
fn fn0() -> (i32, bool) {
    mir! (
        type RET = (i32, bool);
        {
            RET.0 = 0;
            RET.1 = true;
            Return()
        }
    )
}
```

The syntax is not optimal, I'm happy to see other suggestions. Ideally I wanted it to be a normal type annotation like `let RET: ...;`, but this runs into the multiple parsing options error during macro expansion, as it can be parsed as a normal `let` declaration as well.

r? ```@oli-obk``` or ```@tmiasko``` or ```@JakobDegen```
2023-03-22 20:08:01 +01:00
..
custom Rollup merge of #109392 - cbeuw:composite-ret, r=JakobDegen 2023-03-22 20:08:01 +01:00
async_await.a-{closure#0}.generator_resume.0.mir Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
async_await.b-{closure#0}.generator_resume.0.mir Remove identity_future indirection 2023-03-08 15:37:14 +01:00
async_await.rs Transform async ResumeTy in generator transform 2023-01-19 09:03:05 +01:00
enum_cast.bar.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
enum_cast.boo.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
enum_cast.droppy.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
enum_cast.foo.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
enum_cast.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_49232.main.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_49232.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_101867.main.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_101867.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
match_false_edges.full_tested_match.built.after.mir Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
match_false_edges.full_tested_match2.built.after.mir Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
match_false_edges.main.built.after.mir Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
match_false_edges.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
receiver_ptr_mutability.main.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
receiver_ptr_mutability.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simple_match.match_bool.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simple_match.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
storage_live_dead_in_statics.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
storage_live_dead_in_statics.XXX.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uniform_array_move_out.move_out_by_subslice.built.after.mir Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
uniform_array_move_out.move_out_from_end.built.after.mir Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
uniform_array_move_out.rs Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00