avoid some Symbol to String conversions
This commit is contained in:
@@ -1958,7 +1958,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(),
|
||||
@@ -1967,7 +1967,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() },
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user