- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Open
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Consider this code:
#![feature(custom_mir, core_intrinsics)]
use std::intrinsics::mir::*;
pub struct S(i32);
#[custom_mir(dialect = "runtime", phase = "optimized")]
fn main() {
    mir! {
        let x: i32;
        {
            let _observe = x;
            Return()
        }
    }
}When running it in Miri, I wold expect this to point at the assignment. Instead it points at the entire mir! block:
error: Undefined Behavior: constructing invalid value: encountered uninitialized memory, but expected an integer
  --> src/main.rs:8:5
   |
8  | /     mir! {
9  | |         let x: i32;
10 | |         {
11 | |             let _observe = x;
...  |
14 | |
15 | |     }
   | |_____^ constructing invalid value: encountered uninitialized memory, but expected an integer
I've seen it use proper spans for Call terminators inside mir! blocks so I hope this is just an oversight and easy to fix. :)
Cc @JakobDegen
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.