diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-07-16 22:30:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-16 22:30:56 +0200 |
| commit | 6277ac2fb8bf97cd910a0a841c6924b246d32c44 (patch) | |
| tree | 2ecfa500407be289cf19a91c39d2ce7bdd511731 /compiler/rustc_middle/src | |
| parent | 0c6e01baffa5eeaa6658f065daffddf9916d0e87 (diff) | |
| parent | c54d4ada26c6a92346076bcc27d628398345ed9e (diff) | |
| download | rust-6277ac2fb8bf97cd910a0a841c6924b246d32c44.tar.gz rust-6277ac2fb8bf97cd910a0a841c6924b246d32c44.zip | |
Rollup merge of #99342 - TaKO8Ki:avoid-symbol-to-string-conversions, r=compiler-errors
Avoid some `Symbol` to `String` conversions This patch removes some Symbol to String conversions.
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 71c93d05792..c41a8318ec5 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1975,7 +1975,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { min_size = field_end; } FieldInfo { - name: name.to_string(), + name, offset: offset.bytes(), size: field_layout.size.bytes(), align: field_layout.align.abi.bytes(), @@ -1984,7 +1984,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { .collect(); VariantInfo { - name: n.map(|n| n.to_string()), + name: n, kind: if layout.is_unsized() { SizeKind::Min } else { SizeKind::Exact }, align: layout.align.abi.bytes(), size: if min_size.bytes() == 0 { layout.size.bytes() } else { min_size.bytes() }, diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 81c4d2ae346..96e84bc8f0a 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1030,11 +1030,11 @@ pub trait PrettyPrinter<'tcx>: } } - fn ty_infer_name(&self, _: ty::TyVid) -> Option<String> { + fn ty_infer_name(&self, _: ty::TyVid) -> Option<Symbol> { None } - fn const_infer_name(&self, _: ty::ConstVid<'tcx>) -> Option<String> { + fn const_infer_name(&self, _: ty::ConstVid<'tcx>) -> Option<Symbol> { None } @@ -1550,8 +1550,8 @@ pub struct FmtPrinterData<'a, 'tcx> { pub region_highlight_mode: RegionHighlightMode<'tcx>, - pub ty_infer_name_resolver: Option<Box<dyn Fn(ty::TyVid) -> Option<String> + 'a>>, - pub const_infer_name_resolver: Option<Box<dyn Fn(ty::ConstVid<'tcx>) -> Option<String> + 'a>>, + pub ty_infer_name_resolver: Option<Box<dyn Fn(ty::TyVid) -> Option<Symbol> + 'a>>, + pub const_infer_name_resolver: Option<Box<dyn Fn(ty::ConstVid<'tcx>) -> Option<Symbol> + 'a>>, } impl<'a, 'tcx> Deref for FmtPrinter<'a, 'tcx> { @@ -1841,11 +1841,11 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { } impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> { - fn ty_infer_name(&self, id: ty::TyVid) -> Option<String> { + fn ty_infer_name(&self, id: ty::TyVid) -> Option<Symbol> { self.0.ty_infer_name_resolver.as_ref().and_then(|func| func(id)) } - fn const_infer_name(&self, id: ty::ConstVid<'tcx>) -> Option<String> { + fn const_infer_name(&self, id: ty::ConstVid<'tcx>) -> Option<Symbol> { self.0.const_infer_name_resolver.as_ref().and_then(|func| func(id)) } |
