Skip to content

Commit b20d96f

Browse files
committed
remove as_mono_item
1 parent e21d002 commit b20d96f

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/librustc_codegen_ssa/mono_item.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ use crate::traits::*;
77
use rustc::mir::mono::MonoItem;
88

99
pub trait MonoItemExt<'a, 'tcx: 'a> {
10-
fn as_mono_item(&self) -> &MonoItem<'tcx>;
10+
fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx);
11+
fn predefine<Bx: BuilderMethods<'a, 'tcx>>(
12+
&self,
13+
cx: &'a Bx::CodegenCx,
14+
linkage: Linkage,
15+
visibility: Visibility
16+
);
17+
fn to_raw_string(&self) -> String;
18+
}
1119

20+
impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
1221
fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx) {
1322
debug!("BEGIN IMPLEMENTING '{} ({})' in cgu {}",
14-
self.as_mono_item().to_string(cx.tcx(), true),
15-
self.as_mono_item().to_raw_string(),
23+
self.to_string(cx.tcx(), true),
24+
self.to_raw_string(),
1625
cx.codegen_unit().name());
1726

18-
match *self.as_mono_item() {
27+
match *self {
1928
MonoItem::Static(def_id) => {
2029
cx.codegen_static(def_id, cx.tcx().is_mutable_static(def_id));
2130
}
@@ -33,8 +42,8 @@ pub trait MonoItemExt<'a, 'tcx: 'a> {
3342
}
3443

3544
debug!("END IMPLEMENTING '{} ({})' in cgu {}",
36-
self.as_mono_item().to_string(cx.tcx(), true),
37-
self.as_mono_item().to_raw_string(),
45+
self.to_string(cx.tcx(), true),
46+
self.to_raw_string(),
3847
cx.codegen_unit().name());
3948
}
4049

@@ -45,15 +54,15 @@ pub trait MonoItemExt<'a, 'tcx: 'a> {
4554
visibility: Visibility
4655
) {
4756
debug!("BEGIN PREDEFINING '{} ({})' in cgu {}",
48-
self.as_mono_item().to_string(cx.tcx(), true),
49-
self.as_mono_item().to_raw_string(),
57+
self.to_string(cx.tcx(), true),
58+
self.to_raw_string(),
5059
cx.codegen_unit().name());
5160

52-
let symbol_name = self.as_mono_item().symbol_name(cx.tcx()).as_str();
61+
let symbol_name = self.symbol_name(cx.tcx()).as_str();
5362

5463
debug!("symbol {}", &symbol_name);
5564

56-
match *self.as_mono_item() {
65+
match *self {
5766
MonoItem::Static(def_id) => {
5867
cx.predefine_static(def_id, linkage, visibility, &symbol_name);
5968
}
@@ -64,13 +73,13 @@ pub trait MonoItemExt<'a, 'tcx: 'a> {
6473
}
6574

6675
debug!("END PREDEFINING '{} ({})' in cgu {}",
67-
self.as_mono_item().to_string(cx.tcx(), true),
68-
self.as_mono_item().to_raw_string(),
76+
self.to_string(cx.tcx(), true),
77+
self.to_raw_string(),
6978
cx.codegen_unit().name());
7079
}
7180

7281
fn to_raw_string(&self) -> String {
73-
match *self.as_mono_item() {
82+
match *self {
7483
MonoItem::Fn(instance) => {
7584
format!("Fn({:?}, {})",
7685
instance.def,
@@ -85,9 +94,3 @@ pub trait MonoItemExt<'a, 'tcx: 'a> {
8594
}
8695
}
8796
}
88-
89-
impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
90-
fn as_mono_item(&self) -> &MonoItem<'tcx> {
91-
self
92-
}
93-
}

0 commit comments

Comments
 (0)