diff options
| author | Mark Mansi <markm@cs.wisc.edu> | 2019-05-24 12:26:30 -0500 |
|---|---|---|
| committer | Mark Mansi <markm@cs.wisc.edu> | 2019-06-02 22:55:29 -0500 |
| commit | b20d96f97f29019404c45f4ec73903af1b9d3699 (patch) | |
| tree | 3e4f78ce06adca3a05af10ecd373678fc0eeaab1 /src/librustc_codegen_ssa | |
| parent | e21d002bd2485fb4bd5a783cc3fe3a1cf2ca2c5a (diff) | |
| download | rust-b20d96f97f29019404c45f4ec73903af1b9d3699.tar.gz rust-b20d96f97f29019404c45f4ec73903af1b9d3699.zip | |
remove as_mono_item
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/mono_item.rs | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/librustc_codegen_ssa/mono_item.rs b/src/librustc_codegen_ssa/mono_item.rs index 1c9c86a5f5d..11e9a48133d 100644 --- a/src/librustc_codegen_ssa/mono_item.rs +++ b/src/librustc_codegen_ssa/mono_item.rs @@ -7,15 +7,24 @@ use crate::traits::*; use rustc::mir::mono::MonoItem; pub trait MonoItemExt<'a, 'tcx: 'a> { - fn as_mono_item(&self) -> &MonoItem<'tcx>; + fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx); + fn predefine<Bx: BuilderMethods<'a, 'tcx>>( + &self, + cx: &'a Bx::CodegenCx, + linkage: Linkage, + visibility: Visibility + ); + fn to_raw_string(&self) -> String; +} +impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> { fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx) { debug!("BEGIN IMPLEMENTING '{} ({})' in cgu {}", - self.as_mono_item().to_string(cx.tcx(), true), - self.as_mono_item().to_raw_string(), + self.to_string(cx.tcx(), true), + self.to_raw_string(), cx.codegen_unit().name()); - match *self.as_mono_item() { + match *self { MonoItem::Static(def_id) => { cx.codegen_static(def_id, cx.tcx().is_mutable_static(def_id)); } @@ -33,8 +42,8 @@ pub trait MonoItemExt<'a, 'tcx: 'a> { } debug!("END IMPLEMENTING '{} ({})' in cgu {}", - self.as_mono_item().to_string(cx.tcx(), true), - self.as_mono_item().to_raw_string(), + self.to_string(cx.tcx(), true), + self.to_raw_string(), cx.codegen_unit().name()); } @@ -45,15 +54,15 @@ pub trait MonoItemExt<'a, 'tcx: 'a> { visibility: Visibility ) { debug!("BEGIN PREDEFINING '{} ({})' in cgu {}", - self.as_mono_item().to_string(cx.tcx(), true), - self.as_mono_item().to_raw_string(), + self.to_string(cx.tcx(), true), + self.to_raw_string(), cx.codegen_unit().name()); - let symbol_name = self.as_mono_item().symbol_name(cx.tcx()).as_str(); + let symbol_name = self.symbol_name(cx.tcx()).as_str(); debug!("symbol {}", &symbol_name); - match *self.as_mono_item() { + match *self { MonoItem::Static(def_id) => { cx.predefine_static(def_id, linkage, visibility, &symbol_name); } @@ -64,13 +73,13 @@ pub trait MonoItemExt<'a, 'tcx: 'a> { } debug!("END PREDEFINING '{} ({})' in cgu {}", - self.as_mono_item().to_string(cx.tcx(), true), - self.as_mono_item().to_raw_string(), + self.to_string(cx.tcx(), true), + self.to_raw_string(), cx.codegen_unit().name()); } fn to_raw_string(&self) -> String { - match *self.as_mono_item() { + match *self { MonoItem::Fn(instance) => { format!("Fn({:?}, {})", instance.def, @@ -85,9 +94,3 @@ pub trait MonoItemExt<'a, 'tcx: 'a> { } } } - -impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> { - fn as_mono_item(&self) -> &MonoItem<'tcx> { - self - } -} |
