From 08d27441ecc96a56e1b0e72c0accbced2ce6a7d3 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 10 Dec 2018 16:10:22 +0200 Subject: rustc: move the formatter into ty::print::PrintCx. --- src/librustc_codegen_utils/lib.rs | 1 + src/librustc_codegen_utils/symbol_names.rs | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/librustc_codegen_utils') diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index 2b70141894b..466cf40a157 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -4,6 +4,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] +#![feature(arbitrary_self_types)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(custom_attribute)] diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 56ef15b12a0..6bd9b159775 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -225,8 +225,7 @@ fn get_symbol_hash<'a, 'tcx>( fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName { item_path::with_forced_absolute_paths(|| { - let mut cx = PrintCx::new(tcx); - SymbolPathPrinter::print_item_path(&mut cx, def_id).into_interned() + PrintCx::new(tcx, SymbolPathPrinter).print_item_path(def_id).into_interned() }) } @@ -401,17 +400,21 @@ struct SymbolPathPrinter; impl ItemPathPrinter for SymbolPathPrinter { type Path = SymbolPath; - fn path_crate(cx: &mut PrintCx<'_, '_, '_>, cnum: CrateNum) -> Self::Path { - let mut path = SymbolPath::new(cx.tcx); - path.push(&cx.tcx.original_crate_name(cnum).as_str()); + fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path { + let mut path = SymbolPath::new(self.tcx); + path.push(&self.tcx.original_crate_name(cnum).as_str()); path } - fn path_impl(cx: &mut PrintCx<'_, '_, '_>, text: &str) -> Self::Path { - let mut path = SymbolPath::new(cx.tcx); + fn path_impl(self: &mut PrintCx<'_, '_, '_, Self>, text: &str) -> Self::Path { + let mut path = SymbolPath::new(self.tcx); path.push(text); path } - fn path_append(mut path: Self::Path, text: &str) -> Self::Path { + fn path_append( + self: &mut PrintCx<'_, '_, '_, Self>, + mut path: Self::Path, + text: &str, + ) -> Self::Path { path.push(text); path } -- cgit 1.4.1-3-g733a5