Skip to content

Commit d6b06c6

Browse files
committed
Auto merge of #45757 - mikhail-m1:change-mir-dump-filename, r=nikomatsakis
change MIR dump filenames from `rustc.nodeN...` to `rustc.<DefPath>` r? @nikomatsakis
2 parents f1ea23e + 0e5c95e commit d6b06c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+161
-134
lines changed

src/librustc/hir/map/definitions.rs

+23
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,29 @@ impl DefPath {
314314

315315
s
316316
}
317+
318+
/// Return filename friendly string of the DefPah without
319+
/// the crate-prefix. This method is useful if you don't have
320+
/// a TyCtxt available.
321+
pub fn to_filename_friendly_no_crate(&self) -> String {
322+
let mut s = String::with_capacity(self.data.len() * 16);
323+
324+
let mut opt_delimiter = None;
325+
for component in &self.data {
326+
opt_delimiter.map(|d| s.push(d));
327+
opt_delimiter = Some('-');
328+
if component.disambiguator == 0 {
329+
write!(s, "{}", component.data.as_interned_str()).unwrap();
330+
} else {
331+
write!(s,
332+
"{}[{}]",
333+
component.data.as_interned_str(),
334+
component.disambiguator)
335+
.unwrap();
336+
}
337+
}
338+
s
339+
}
317340
}
318341

319342
#[derive(Clone, Debug, Eq, PartialEq, Hash, RustcEncodable, RustcDecodable)]

src/librustc_mir/util/pretty.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,13 @@ where
132132
let p = Path::new(file_dir);
133133
file_path.push(p);
134134
};
135+
135136
let _ = fs::create_dir_all(&file_path);
136-
let file_name = format!("rustc.node{}{}{}.{}.{}.mir",
137-
source.item_id(), promotion_id, pass_num, pass_name, disambiguator);
137+
let function_name = tcx.hir.def_path_from_id(source.item_id())
138+
.map(|d| d.to_filename_friendly_no_crate())
139+
.unwrap_or(format!("node{}", source.item_id()));
140+
let file_name = format!("rustc.{}{}{}.{}.{}.mir",
141+
function_name, promotion_id, pass_num, pass_name, disambiguator);
138142
file_path.push(&file_name);
139143
let _ = fs::File::create(&file_path).and_then(|mut file| {
140144
writeln!(file, "// MIR for `{}`", node_path)?;

src/test/mir-opt/basic_assignment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
}
3737

3838
// END RUST SOURCE
39-
// START rustc.node4.SimplifyCfg-initial.after.mir
39+
// START rustc.main.SimplifyCfg-initial.after.mir
4040
// bb0: {
4141
// StorageLive(_1);
4242
// _1 = const false;
@@ -82,4 +82,4 @@ fn main() {
8282
// StorageDead(_1);
8383
// return;
8484
// }
85-
// END rustc.node4.SimplifyCfg-initial.after.mir
85+
// END rustc.main.SimplifyCfg-initial.after.mir

src/test/mir-opt/box_expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Drop for S {
2828
}
2929

3030
// END RUST SOURCE
31-
// START rustc.node4.ElaborateDrops.before.mir
31+
// START rustc.main.ElaborateDrops.before.mir
3232
// let mut _0: ();
3333
// scope 1 {
3434
// let _1: std::boxed::Box<S>;
@@ -88,4 +88,4 @@ impl Drop for S {
8888
// return;
8989
// }
9090
// }
91-
// END rustc.node4.ElaborateDrops.before.mir
91+
// END rustc.main.ElaborateDrops.before.mir

src/test/mir-opt/copy_propagation.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
}
2020

2121
// END RUST SOURCE
22-
// START rustc.node4.CopyPropagation.before.mir
22+
// START rustc.test.CopyPropagation.before.mir
2323
// bb0: {
2424
// ...
2525
// _3 = _1;
@@ -31,12 +31,12 @@ fn main() {
3131
// ...
3232
// return;
3333
// }
34-
// END rustc.node4.CopyPropagation.before.mir
35-
// START rustc.node4.CopyPropagation.after.mir
34+
// END rustc.test.CopyPropagation.before.mir
35+
// START rustc.test.CopyPropagation.after.mir
3636
// bb0: {
3737
// ...
3838
// _0 = _1;
3939
// ...
4040
// return;
4141
// }
42-
// END rustc.node4.CopyPropagation.after.mir
42+
// END rustc.test.CopyPropagation.after.mir

src/test/mir-opt/deaggregator_test.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
}
2525

2626
// END RUST SOURCE
27-
// START rustc.node13.Deaggregator.before.mir
27+
// START rustc.bar.Deaggregator.before.mir
2828
// bb0: {
2929
// ...
3030
// _2 = _1;
@@ -33,8 +33,8 @@ fn main() {
3333
// ...
3434
// return;
3535
// }
36-
// END rustc.node13.Deaggregator.before.mir
37-
// START rustc.node13.Deaggregator.after.mir
36+
// END rustc.bar.Deaggregator.before.mir
37+
// START rustc.bar.Deaggregator.after.mir
3838
// bb0: {
3939
// ...
4040
// _2 = _1;
@@ -45,4 +45,4 @@ fn main() {
4545
// ...
4646
// return;
4747
// }
48-
// END rustc.node13.Deaggregator.after.mir
48+
// END rustc.bar.Deaggregator.after.mir

src/test/mir-opt/deaggregator_test_enum.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ fn main() {
2626
}
2727

2828
// END RUST SOURCE
29-
// START rustc.node10.Deaggregator.before.mir
29+
// START rustc.bar.Deaggregator.before.mir
3030
// bb0: {
3131
// StorageLive(_2);
3232
// _2 = _1;
3333
// _0 = Baz::Foo { x: _2 };
3434
// StorageDead(_2);
3535
// return;
3636
// }
37-
// END rustc.node10.Deaggregator.before.mir
38-
// START rustc.node10.Deaggregator.after.mir
37+
// END rustc.bar.Deaggregator.before.mir
38+
// START rustc.bar.Deaggregator.after.mir
3939
// bb0: {
4040
// StorageLive(_2);
4141
// _2 = _1;
@@ -44,4 +44,4 @@ fn main() {
4444
// StorageDead(_2);
4545
// return;
4646
// }
47-
// END rustc.node10.Deaggregator.after.mir
47+
// END rustc.bar.Deaggregator.after.mir

src/test/mir-opt/deaggregator_test_enum_2.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
}
3030

3131
// END RUST SOURCE
32-
// START rustc.node12.Deaggregator.before.mir
32+
// START rustc.test1.Deaggregator.before.mir
3333
// bb1: {
3434
// StorageLive(_4);
3535
// _4 = _2;
@@ -44,8 +44,8 @@ fn main() {
4444
// StorageDead(_5);
4545
// goto -> bb3;
4646
// }
47-
// END rustc.node12.Deaggregator.before.mir
48-
// START rustc.node12.Deaggregator.after.mir
47+
// END rustc.test1.Deaggregator.before.mir
48+
// START rustc.test1.Deaggregator.after.mir
4949
// bb1: {
5050
// StorageLive(_4);
5151
// _4 = _2;
@@ -62,5 +62,5 @@ fn main() {
6262
// StorageDead(_5);
6363
// goto -> bb3;
6464
// }
65-
// END rustc.node12.Deaggregator.after.mir
65+
// END rustc.test1.Deaggregator.after.mir
6666
//

src/test/mir-opt/deaggregator_test_multiple.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525
}
2626

2727
// END RUST SOURCE
28-
// START rustc.node10.Deaggregator.before.mir
28+
// START rustc.test.Deaggregator.before.mir
2929
// bb0: {
3030
// ...
3131
// _3 = _1;
@@ -39,8 +39,8 @@ fn main() {
3939
// ...
4040
// return;
4141
// }
42-
// END rustc.node10.Deaggregator.before.mir
43-
// START rustc.node10.Deaggregator.after.mir
42+
// END rustc.test.Deaggregator.before.mir
43+
// START rustc.test.Deaggregator.after.mir
4444
// bb0: {
4545
// ...
4646
// _3 = _1;
@@ -56,4 +56,4 @@ fn main() {
5656
// ...
5757
// return;
5858
// }
59-
// END rustc.node10.Deaggregator.after.mir
59+
// END rustc.test.Deaggregator.after.mir

src/test/mir-opt/end_region_1.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
}
2020

2121
// END RUST SOURCE
22-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
22+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
2323
// let mut _0: ();
2424
// ...
2525
// let _1: i32;
@@ -37,4 +37,4 @@ fn main() {
3737
// StorageDead(_1);
3838
// return;
3939
// }
40-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
40+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir

src/test/mir-opt/end_region_2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
}
2525

2626
// END RUST SOURCE
27-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
27+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
2828
// let mut _0: ();
2929
// ...
3030
// let _2: bool;
@@ -69,4 +69,4 @@ fn main() {
6969
// StorageDead(_2);
7070
// goto -> bb1;
7171
// }
72-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
72+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir

src/test/mir-opt/end_region_3.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525
}
2626

2727
// END RUST SOURCE
28-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
28+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
2929
// let mut _0: ();
3030
// ...
3131
// let mut _1: bool;
@@ -70,4 +70,4 @@ fn main() {
7070
// StorageDead(_3);
7171
// goto -> bb1;
7272
// }
73-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
73+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir

src/test/mir-opt/end_region_4.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn foo(i: i32) {
2929
}
3030

3131
// END RUST SOURCE
32-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
32+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
3333
// let mut _0: ();
3434
// ...
3535
// let _1: D;
@@ -76,4 +76,4 @@ fn foo(i: i32) {
7676
// StorageDead(_1);
7777
// return;
7878
// }
79-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
79+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir

src/test/mir-opt/end_region_5.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
2626
}
2727

2828
// END RUST SOURCE
29-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
29+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
3030
// fn main() -> () {
3131
// ...
3232
// let mut _0: ();
@@ -64,9 +64,9 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
6464
// return;
6565
// }
6666
// }
67-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
67+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
6868

69-
// START rustc.node18.SimplifyCfg-qualify-consts.after.mir
69+
// START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir
7070
// fn main::{{closure}}(_1: [closure@NodeId(18) d:&'14s D]) -> i32 {
7171
// let mut _0: i32;
7272
// let mut _2: i32;
@@ -78,4 +78,4 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
7878
// StorageDead(_2);
7979
// return;
8080
// }
81-
// END rustc.node18.SimplifyCfg-qualify-consts.after.mir
81+
// END rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir

src/test/mir-opt/end_region_6.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
2626
}
2727

2828
// END RUST SOURCE
29-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
29+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
3030
// fn main() -> () {
3131
// let mut _0: ();
3232
// ...
@@ -62,9 +62,9 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
6262
// StorageDead(_1);
6363
// return;
6464
// }
65-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
65+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
6666

67-
// START rustc.node22.SimplifyCfg-qualify-consts.after.mir
67+
// START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir
6868
// fn main::{{closure}}(_1: [closure@NodeId(22) d:&'19s D]) -> i32 {
6969
// let mut _0: i32;
7070
// ...
@@ -82,4 +82,4 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
8282
// StorageDead(_2);
8383
// return;
8484
// }
85-
// END rustc.node22.SimplifyCfg-qualify-consts.after.mir
85+
// END rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir

src/test/mir-opt/end_region_7.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
2626
}
2727

2828
// END RUST SOURCE
29-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
29+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
3030
// fn main() -> () {
3131
// let mut _0: ();
3232
// ...
@@ -70,9 +70,9 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
7070
// return;
7171
// }
7272
// }
73-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
73+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
7474

75-
// START rustc.node22.SimplifyCfg-qualify-consts.after.mir
75+
// START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir
7676
// fn main::{{closure}}(_1: [closure@NodeId(22) d:D]) -> i32 {
7777
// let mut _0: i32;
7878
// ...
@@ -94,4 +94,4 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
9494
// return;
9595
// }
9696
// }
97-
// END rustc.node22.SimplifyCfg-qualify-consts.after.mir
97+
// END rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir

src/test/mir-opt/end_region_8.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
2727
}
2828

2929
// END RUST SOURCE
30-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
30+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
3131
// fn main() -> () {
3232
// let mut _0: ();
3333
// ...
@@ -69,9 +69,9 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
6969
// return;
7070
// }
7171
// }
72-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
72+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
7373

74-
// START rustc.node22.SimplifyCfg-qualify-consts.after.mir
74+
// START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir
7575
// fn main::{{closure}}(_1: [closure@NodeId(22) r:&'21_1rs D]) -> i32 {
7676
// let mut _0: i32;
7777
// let mut _2: i32;
@@ -84,4 +84,4 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
8484
// return;
8585
// }
8686
// }
87-
// END rustc.node22.SimplifyCfg-qualify-consts.after.mir
87+
// END rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir

src/test/mir-opt/end_region_9.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() {
3737
}
3838

3939
// END RUST SOURCE
40-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
40+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
4141
// fn main() -> () {
4242
// let mut _0: ();
4343
// ...
@@ -84,4 +84,4 @@ fn main() {
8484
// goto -> bb1;
8585
// }
8686
// }
87-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
87+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir

0 commit comments

Comments
 (0)