avoid some Symbol
to String
conversions
This commit is contained in:
parent
95e77648e4
commit
c54d4ada26
18 changed files with 50 additions and 59 deletions
|
@ -23,7 +23,7 @@ use rustc_middle::ty::{
|
|||
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
|
||||
use rustc_span::hygiene::DesugaringKind;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_span::{BytePos, Span, Symbol};
|
||||
use rustc_trait_selection::infer::InferCtxtExt;
|
||||
use rustc_trait_selection::traits::TraitEngineExt as _;
|
||||
|
||||
|
@ -1227,8 +1227,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
from_closure: false,
|
||||
region_name:
|
||||
RegionName {
|
||||
source:
|
||||
RegionNameSource::AnonRegionFromUpvar(upvar_span, ref upvar_name),
|
||||
source: RegionNameSource::AnonRegionFromUpvar(upvar_span, upvar_name),
|
||||
..
|
||||
},
|
||||
span,
|
||||
|
@ -1702,7 +1701,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
borrow_span: Span,
|
||||
name: &Option<String>,
|
||||
upvar_span: Span,
|
||||
upvar_name: &str,
|
||||
upvar_name: Symbol,
|
||||
escape_span: Span,
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let tcx = self.infcx.tcx;
|
||||
|
|
|
@ -12,7 +12,7 @@ use rustc_middle::mir::{
|
|||
};
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::{self, RegionVid, TyCtxt};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_span::{sym, DesugaringKind, Span};
|
||||
|
||||
use crate::region_infer::BlameConstraint;
|
||||
|
@ -282,7 +282,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||
) {
|
||||
if let ConstraintCategory::OpaqueType = category {
|
||||
let suggestable_name =
|
||||
if region_name.was_named() { region_name.to_string() } else { "'_".to_string() };
|
||||
if region_name.was_named() { region_name.name } else { kw::UnderscoreLifetime };
|
||||
|
||||
let msg = format!(
|
||||
"you can add a bound to the {}to make it last less than `'static` and match `{}`",
|
||||
|
|
|
@ -19,8 +19,7 @@ use rustc_middle::ty::subst::InternalSubsts;
|
|||
use rustc_middle::ty::Region;
|
||||
use rustc_middle::ty::TypeVisitor;
|
||||
use rustc_middle::ty::{self, RegionVid, Ty};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::borrowck_errors;
|
||||
|
@ -758,7 +757,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
return;
|
||||
};
|
||||
|
||||
let lifetime = if f.has_name() { fr_name.to_string() } else { "'_".to_string() };
|
||||
let lifetime = if f.has_name() { fr_name.name } else { kw::UnderscoreLifetime };
|
||||
|
||||
let arg = match param.param.pat.simple_ident() {
|
||||
Some(simple_ident) => format!("argument `{}`", simple_ident),
|
||||
|
@ -770,7 +769,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
self.infcx.tcx,
|
||||
diag,
|
||||
fn_returns,
|
||||
lifetime,
|
||||
lifetime.to_string(),
|
||||
Some(arg),
|
||||
captures,
|
||||
Some((param.param_ty_span, param.param_ty.to_string())),
|
||||
|
|
|
@ -34,13 +34,13 @@ pub(crate) enum RegionNameSource {
|
|||
/// The `'static` region.
|
||||
Static,
|
||||
/// The free region corresponding to the environment of a closure.
|
||||
SynthesizedFreeEnvRegion(Span, String),
|
||||
SynthesizedFreeEnvRegion(Span, &'static str),
|
||||
/// The region corresponding to an argument.
|
||||
AnonRegionFromArgument(RegionNameHighlight),
|
||||
/// The region corresponding to a closure upvar.
|
||||
AnonRegionFromUpvar(Span, String),
|
||||
AnonRegionFromUpvar(Span, Symbol),
|
||||
/// The region corresponding to the return type of a closure.
|
||||
AnonRegionFromOutput(RegionNameHighlight, String),
|
||||
AnonRegionFromOutput(RegionNameHighlight, &'static str),
|
||||
/// The region from a type yielded by a generator.
|
||||
AnonRegionFromYieldTy(Span, String),
|
||||
/// An anonymous region from an async fn.
|
||||
|
@ -110,7 +110,7 @@ impl RegionName {
|
|||
}
|
||||
RegionNameSource::SynthesizedFreeEnvRegion(span, note) => {
|
||||
diag.span_label(*span, format!("lifetime `{self}` represents this closure's body"));
|
||||
diag.note(note);
|
||||
diag.note(*note);
|
||||
}
|
||||
RegionNameSource::AnonRegionFromArgument(RegionNameHighlight::CannotMatchHirTy(
|
||||
span,
|
||||
|
@ -350,10 +350,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||
|
||||
Some(RegionName {
|
||||
name: region_name,
|
||||
source: RegionNameSource::SynthesizedFreeEnvRegion(
|
||||
fn_decl_span,
|
||||
note.to_string(),
|
||||
),
|
||||
source: RegionNameSource::SynthesizedFreeEnvRegion(fn_decl_span, note),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -678,7 +675,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||
|
||||
Some(RegionName {
|
||||
name: region_name,
|
||||
source: RegionNameSource::AnonRegionFromUpvar(upvar_span, upvar_name.to_string()),
|
||||
source: RegionNameSource::AnonRegionFromUpvar(upvar_span, upvar_name),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -756,7 +753,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||
|
||||
Some(RegionName {
|
||||
name: self.synthesize_region_name(),
|
||||
source: RegionNameSource::AnonRegionFromOutput(highlight, mir_description.to_string()),
|
||||
source: RegionNameSource::AnonRegionFromOutput(highlight, mir_description),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue