Skip to content

Commit

Permalink
rustc_mir: don't throw away inlined locals' spans.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Oct 21, 2020
1 parent 387e31c commit 2bfb462
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 58 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_mir/src/transform/inline.rs
Expand Up @@ -469,7 +469,6 @@ impl Inliner<'tcx> {
let mut local = callee_body.local_decls[loc].clone();

local.source_info.scope = scope_map[local.source_info.scope];
local.source_info.span = callsite.source_info.span;

let idx = caller_body.local_decls.push(local);
local_map.push(idx);
Expand Down
Expand Up @@ -27,7 +27,7 @@ fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 1
debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:11:13: 11:15
}
scope 2 (inlined String::new) { // at $DIR/generator-drop-cleanup.rs:11:18: 11:31
let mut _6: std::vec::Vec<u8>; // in scope 2 at $DIR/generator-drop-cleanup.rs:11:18: 11:31
let mut _6: std::vec::Vec<u8>; // in scope 2 at $SRC_DIR/alloc/src/string.rs:LL:COL
scope 3 (inlined Vec::<u8>::new) { // at $SRC_DIR/alloc/src/string.rs:LL:COL
}
}
Expand Down
Expand Up @@ -11,8 +11,8 @@ fn bar() -> bool {
scope 2 (inlined foo) { // at $DIR/inline-any-operand.rs:12:5: 12:13
debug x => _5; // in scope 2 at $DIR/inline-any-operand.rs:16:8: 16:9
debug y => _6; // in scope 2 at $DIR/inline-any-operand.rs:16:16: 16:17
let mut _3: i32; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13
let mut _4: i32; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13
let mut _3: i32; // in scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6
let mut _4: i32; // in scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11
}
}

Expand Down
Expand Up @@ -16,7 +16,7 @@ fn foo(_1: T, _2: &i32) -> i32 {
scope 2 (inlined foo::<T>::{closure#0}) { // at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
debug r => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:14: 12:15
debug _s => _10; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:23: 12:25
let _8: &i32; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
let _8: &i32; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21
scope 3 {
debug variable => _8; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21
}
Expand Down
Expand Up @@ -17,7 +17,7 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
debug _q => _10; // in scope 2 at $DIR/inline-closure-captures.rs:11:14: 11:16
debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:10:23: 10:24
debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18
let mut _9: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
let mut _9: T; // in scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir
Expand Up @@ -17,8 +17,8 @@ fn bar() -> bool {
scope 2 (inlined foo) { // at $DIR/inline-retag.rs:12:5: 12:15
debug x => _3; // in scope 2 at $DIR/inline-retag.rs:16:8: 16:9
debug y => _6; // in scope 2 at $DIR/inline-retag.rs:16:17: 16:18
let mut _11: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15
let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15
let mut _11: i32; // in scope 2 at $DIR/inline-retag.rs:17:5: 17:7
let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:17:11: 17:13
}
}

Expand Down
Expand Up @@ -7,7 +7,7 @@ fn test2(_1: &dyn X) -> bool {
let mut _3: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11
scope 1 (inlined test) { // at $DIR/inline-trait-method_2.rs:5:5: 5:12
debug x => _2; // in scope 1 at $DIR/inline-trait-method_2.rs:9:9: 9:10
let mut _4: &dyn X; // in scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12
let mut _4: &dyn X; // in scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:6
}

bb0: {
Expand Down
Expand Up @@ -8,7 +8,7 @@ fn a(_1: &mut [T]) -> &mut [T] {
let mut _4: &mut [T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:6
scope 1 (inlined <[T] as AsMut<[T]>>::as_mut) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15
debug self => _4; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
let mut _5: &mut [T]; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15
let mut _5: &mut [T]; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
}

bb0: {
Expand Down
Expand Up @@ -8,8 +8,8 @@ fn b(_1: &mut Box<T>) -> &mut T {
let mut _4: &mut std::boxed::Box<T>; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:6
scope 1 (inlined <Box<T> as AsMut<T>>::as_mut) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15
debug self => _4; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
let mut _5: &mut T; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15
let mut _6: &mut T; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15
let mut _5: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
let mut _6: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
}

bb0: {
Expand Down
Expand Up @@ -11,7 +11,7 @@ fn main() -> () {
debug f => _1; // in scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:5:9: 5:10
scope 2 (inlined main::{closure#0}) { // at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
debug x => _6; // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:14: 5:15
let _5: (); // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
let _5: (); // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:23: 5:24
scope 3 {
debug y => _5; // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:5:23: 5:24
}
Expand Down
18 changes: 9 additions & 9 deletions src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff
Expand Up @@ -38,28 +38,28 @@
scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug x => _25; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug f => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _25: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _25: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
scope 7 {
}
}
scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug x => _28; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug f => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _28: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _28: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
scope 9 {
}
}
}
scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug pieces => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug args => _31; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _29: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _29: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff
Expand Up @@ -38,28 +38,28 @@
scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug x => _25; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug f => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _25: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _25: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
scope 7 {
}
}
scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug x => _28; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug f => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _28: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _28: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
scope 9 {
}
}
}
scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug pieces => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug args => _31; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _29: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _29: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff
Expand Up @@ -61,30 +61,30 @@
scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug x => _39; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug f => _40; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _49: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _49: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
scope 7 {
}
}
scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug x => _42; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug f => _43; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _53: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _53: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
scope 9 {
}
}
}
scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL
debug pieces => _23; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
debug args => _27; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _54: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _54: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
}
}
}
Expand Down

0 comments on commit 2bfb462

Please sign in to comment.