Improve spans in custom mir
This commit is contained in:
parent
52ce1f7697
commit
5a34dbf193
10 changed files with 47 additions and 39 deletions
|
@ -74,7 +74,7 @@ pub(super) fn build_custom_mir<'tcx>(
|
|||
let mut pctxt = ParseCtxt {
|
||||
tcx,
|
||||
thir,
|
||||
source_info: SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE },
|
||||
source_scope: OUTERMOST_SOURCE_SCOPE,
|
||||
body: &mut body,
|
||||
local_map: FxHashMap::default(),
|
||||
block_map: FxHashMap::default(),
|
||||
|
@ -128,7 +128,7 @@ fn parse_attribute(attr: &Attribute) -> MirPhase {
|
|||
struct ParseCtxt<'tcx, 'body> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
thir: &'body Thir<'tcx>,
|
||||
source_info: SourceInfo,
|
||||
source_scope: SourceScope,
|
||||
|
||||
body: &'body mut Body<'tcx>,
|
||||
local_map: FxHashMap<LocalVarId, Local>,
|
||||
|
|
|
@ -233,15 +233,23 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
|||
let mut data = BasicBlockData::new(None);
|
||||
for stmt_id in &*block.stmts {
|
||||
let stmt = self.statement_as_expr(*stmt_id)?;
|
||||
let span = self.thir[stmt].span;
|
||||
let statement = self.parse_statement(stmt)?;
|
||||
data.statements.push(Statement { source_info: self.source_info, kind: statement });
|
||||
data.statements.push(Statement {
|
||||
source_info: SourceInfo { span, scope: self.source_scope },
|
||||
kind: statement,
|
||||
});
|
||||
}
|
||||
|
||||
let Some(trailing) = block.expr else {
|
||||
return Err(self.expr_error(expr_id, "terminator"))
|
||||
};
|
||||
let span = self.thir[trailing].span;
|
||||
let terminator = self.parse_terminator(trailing)?;
|
||||
data.terminator = Some(Terminator { source_info: self.source_info, kind: terminator });
|
||||
data.terminator = Some(Terminator {
|
||||
source_info: SourceInfo { span, scope: self.source_scope },
|
||||
kind: terminator,
|
||||
});
|
||||
|
||||
Ok(data)
|
||||
}
|
||||
|
|
|
@ -492,7 +492,7 @@ fn construct_fn<'tcx>(
|
|||
arguments,
|
||||
return_ty,
|
||||
return_ty_span,
|
||||
span,
|
||||
span_with_body,
|
||||
custom_mir_attr,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,17 +6,17 @@ fn arbitrary_let(_1: i32) -> i32 {
|
|||
let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
|
||||
bb0: {
|
||||
_2 = _1; // scope 0 at $DIR/arbitrary_let.rs:+0:1: +0:32
|
||||
goto -> bb2; // scope 0 at $DIR/arbitrary_let.rs:+0:1: +0:32
|
||||
_2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
goto -> bb2; // scope 0 at $DIR/arbitrary_let.rs:+4:13: +4:25
|
||||
}
|
||||
|
||||
bb1: {
|
||||
_0 = _3; // scope 0 at $DIR/arbitrary_let.rs:+0:1: +0:32
|
||||
return; // scope 0 at $DIR/arbitrary_let.rs:+0:1: +0:32
|
||||
_0 = _3; // scope 0 at $DIR/arbitrary_let.rs:+7:13: +7:20
|
||||
return; // scope 0 at $DIR/arbitrary_let.rs:+8:13: +8:21
|
||||
}
|
||||
|
||||
bb2: {
|
||||
_3 = _2; // scope 0 at $DIR/arbitrary_let.rs:+0:1: +0:32
|
||||
goto -> bb1; // scope 0 at $DIR/arbitrary_let.rs:+0:1: +0:32
|
||||
_3 = _2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
goto -> bb1; // scope 0 at $DIR/arbitrary_let.rs:+12:13: +12:24
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// MIR for `consts` after built
|
||||
|
||||
fn consts() -> () {
|
||||
let mut _0: (); // return place in scope 0 at $DIR/consts.rs:10:27: 10:27
|
||||
let mut _0: (); // return place in scope 0 at $DIR/consts.rs:+0:27: +0:27
|
||||
let mut _1: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
let mut _2: i8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
let mut _3: u32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
|
@ -9,14 +9,14 @@ fn consts() -> () {
|
|||
let mut _5: fn() {consts::<10>}; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
|
||||
bb0: {
|
||||
_1 = const 5_u8; // scope 0 at $DIR/consts.rs:+0:1: +0:26
|
||||
_2 = const _; // scope 0 at $DIR/consts.rs:+0:1: +0:26
|
||||
_3 = const C; // scope 0 at $DIR/consts.rs:+0:1: +0:26
|
||||
_4 = const _; // scope 0 at $DIR/consts.rs:+0:1: +0:26
|
||||
_5 = consts::<10>; // scope 0 at $DIR/consts.rs:+0:1: +0:26
|
||||
_1 = const 5_u8; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
_2 = const _; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
_3 = const C; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
_4 = const _; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
_5 = consts::<10>; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
// mir::Constant
|
||||
// + span: $DIR/consts.rs:16:18: 16:30
|
||||
// + literal: Const { ty: fn() {consts::<10>}, val: Value(<ZST>) }
|
||||
return; // scope 0 at $DIR/consts.rs:+0:1: +0:26
|
||||
return; // scope 0 at $DIR/consts.rs:+7:9: +7:17
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
// MIR for `statics` after built
|
||||
|
||||
fn statics() -> () {
|
||||
let mut _0: (); // return place in scope 0 at $DIR/consts.rs:25:14: 25:14
|
||||
let mut _0: (); // return place in scope 0 at $DIR/consts.rs:+0:14: +0:14
|
||||
let mut _1: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
let mut _2: *mut i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
|
||||
bb0: {
|
||||
_1 = const {alloc1: &i32}; // scope 0 at $DIR/consts.rs:+0:1: +0:13
|
||||
_1 = const {alloc1: &i32}; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
// mir::Constant
|
||||
// + span: $DIR/consts.rs:27:31: 27:32
|
||||
// + literal: Const { ty: &i32, val: Value(Scalar(alloc1)) }
|
||||
_2 = const {alloc2: *mut i32}; // scope 0 at $DIR/consts.rs:+0:1: +0:13
|
||||
_2 = const {alloc2: *mut i32}; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
// mir::Constant
|
||||
// + span: $DIR/consts.rs:28:38: 28:39
|
||||
// + literal: Const { ty: *mut i32, val: Value(Scalar(alloc2)) }
|
||||
return; // scope 0 at $DIR/consts.rs:+0:1: +0:13
|
||||
return; // scope 0 at $DIR/consts.rs:+4:9: +4:17
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ fn immut_ref(_1: &i32) -> &i32 {
|
|||
let mut _2: *const i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
|
||||
bb0: {
|
||||
_2 = &raw const (*_1); // scope 0 at $DIR/references.rs:+0:1: +0:34
|
||||
Retag([raw] _2); // scope 0 at $DIR/references.rs:+0:1: +0:34
|
||||
_0 = &(*_2); // scope 0 at $DIR/references.rs:+0:1: +0:34
|
||||
Retag(_0); // scope 0 at $DIR/references.rs:+0:1: +0:34
|
||||
return; // scope 0 at $DIR/references.rs:+0:1: +0:34
|
||||
_2 = &raw const (*_1); // scope 0 at $DIR/references.rs:+5:13: +5:29
|
||||
Retag([raw] _2); // scope 0 at $DIR/references.rs:+6:13: +6:24
|
||||
_0 = &(*_2); // scope 0 at $DIR/references.rs:+7:13: +7:23
|
||||
Retag(_0); // scope 0 at $DIR/references.rs:+8:13: +8:23
|
||||
return; // scope 0 at $DIR/references.rs:+9:13: +9:21
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ fn mut_ref(_1: &mut i32) -> &mut i32 {
|
|||
let mut _2: *mut i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
|
||||
bb0: {
|
||||
_2 = &raw mut (*_1); // scope 0 at $DIR/references.rs:+0:1: +0:40
|
||||
Retag([raw] _2); // scope 0 at $DIR/references.rs:+0:1: +0:40
|
||||
_0 = &mut (*_2); // scope 0 at $DIR/references.rs:+0:1: +0:40
|
||||
Retag(_0); // scope 0 at $DIR/references.rs:+0:1: +0:40
|
||||
return; // scope 0 at $DIR/references.rs:+0:1: +0:40
|
||||
_2 = &raw mut (*_1); // scope 0 at $DIR/references.rs:+5:13: +5:33
|
||||
Retag([raw] _2); // scope 0 at $DIR/references.rs:+6:13: +6:24
|
||||
_0 = &mut (*_2); // scope 0 at $DIR/references.rs:+7:13: +7:26
|
||||
Retag(_0); // scope 0 at $DIR/references.rs:+8:13: +8:23
|
||||
return; // scope 0 at $DIR/references.rs:+9:13: +9:21
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ fn simple(_1: i32) -> i32 {
|
|||
let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
|
||||
bb0: {
|
||||
_2 = _1; // scope 0 at $DIR/simple_assign.rs:+0:1: +0:29
|
||||
goto -> bb1; // scope 0 at $DIR/simple_assign.rs:+0:1: +0:29
|
||||
_2 = _1; // scope 0 at $DIR/simple_assign.rs:+6:13: +6:22
|
||||
goto -> bb1; // scope 0 at $DIR/simple_assign.rs:+7:13: +7:23
|
||||
}
|
||||
|
||||
bb1: {
|
||||
_3 = move _2; // scope 0 at $DIR/simple_assign.rs:+0:1: +0:29
|
||||
_0 = _3; // scope 0 at $DIR/simple_assign.rs:+0:1: +0:29
|
||||
return; // scope 0 at $DIR/simple_assign.rs:+0:1: +0:29
|
||||
_3 = move _2; // scope 0 at $DIR/simple_assign.rs:+11:13: +11:32
|
||||
_0 = _3; // scope 0 at $DIR/simple_assign.rs:+12:13: +12:24
|
||||
return; // scope 0 at $DIR/simple_assign.rs:+13:13: +13:21
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ fn simple_ref(_1: &mut i32) -> &mut i32 {
|
|||
let mut _0: &mut i32; // return place in scope 0 at $DIR/simple_assign.rs:+0:35: +0:43
|
||||
|
||||
bb0: {
|
||||
_0 = move _1; // scope 0 at $DIR/simple_assign.rs:+0:1: +0:43
|
||||
return; // scope 0 at $DIR/simple_assign.rs:+0:1: +0:43
|
||||
_0 = move _1; // scope 0 at $DIR/simple_assign.rs:+2:9: +2:22
|
||||
return; // scope 0 at $DIR/simple_assign.rs:+3:9: +3:17
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue