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.
This commit is contained in:
commit
6277ac2fb8
18 changed files with 50 additions and 59 deletions
|
@ -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() },
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue