diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-07-29 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-07-29 13:21:20 +0200 |
| commit | 38c07c7ca5f5a1bc65767b7dd8091b9992fc72a1 (patch) | |
| tree | c3b42334efe409b7e0e3c0624a2d0d0fe71e7994 | |
| parent | 6e0a8bf7901a3fe2e073b1e702e80f58b76d5087 (diff) | |
| download | rust-38c07c7ca5f5a1bc65767b7dd8091b9992fc72a1.tar.gz rust-38c07c7ca5f5a1bc65767b7dd8091b9992fc72a1.zip | |
Implement `Printer` for `&mut SymbolPrinter`
to avoid passing `SymbolPrinter` by value.
| -rw-r--r-- | compiler/rustc_symbol_mangling/src/legacy.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 0c64fe6ea60..1b4e6b4e381 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -55,7 +55,8 @@ pub(super) fn mangle( let hash = get_symbol_hash(tcx, instance, instance_ty, instantiating_crate); - let mut printer = SymbolPrinter { tcx, path: SymbolPath::new(), keep_within_component: false } + let mut printer = SymbolPrinter { tcx, path: SymbolPath::new(), keep_within_component: false }; + printer .print_def_path( def_id, if let ty::InstanceDef::DropGlue(_, _) = instance.def { @@ -198,7 +199,7 @@ struct SymbolPrinter<'tcx> { // `PrettyPrinter` aka pretty printing of e.g. types in paths, // symbol names should have their own printing machinery. -impl Printer<'tcx> for SymbolPrinter<'tcx> { +impl Printer<'tcx> for &mut SymbolPrinter<'tcx> { type Error = fmt::Error; type Path = Self; @@ -242,7 +243,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { Ok(self) } - fn print_const(mut self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error> { + fn print_const(self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error> { // only print integers if let ty::ConstKind::Value(ConstValue::Scalar(Scalar::Int { .. })) = ct.val { if ct.ty.is_integral() { @@ -253,7 +254,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { Ok(self) } - fn path_crate(mut self, cnum: CrateNum) -> Result<Self::Path, Self::Error> { + fn path_crate(self, cnum: CrateNum) -> Result<Self::Path, Self::Error> { self.write_str(&self.tcx.crate_name(cnum).as_str())?; Ok(self) } @@ -344,7 +345,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { } } -impl PrettyPrinter<'tcx> for SymbolPrinter<'tcx> { +impl PrettyPrinter<'tcx> for &mut SymbolPrinter<'tcx> { fn region_should_not_be_omitted(&self, _region: ty::Region<'_>) -> bool { false } |
