/// 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.
}
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,
impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
pub(crate) fn mir_def_id(&self) -> hir::def_id::LocalDefId {
- self.body.source.def_id().as_local().unwrap()
+ self.body.source.def_id().expect_local()
}
pub(crate) fn mir_hir_id(&self) -> hir::HirId {
// Can't have BrEnv in functions, constants or generators.
bug!("BrEnv outside of closure.");
};
- let hir::ExprKind::Closure { fn_decl_span, .. }
+ let hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. })
= tcx.hir().expect_expr(self.mir_hir_id()).kind
else {
bug!("Closure is not defined by a closure expr");
Some(RegionName {
name: region_name,
- source: RegionNameSource::SynthesizedFreeEnvRegion(
- fn_decl_span,
- note.to_string(),
- ),
+ source: RegionNameSource::SynthesizedFreeEnvRegion(fn_decl_span, note),
})
}
hir::LifetimeName::Param(_, hir::ParamName::Fresh)
| hir::LifetimeName::ImplicitObjectLifetimeDefault
- | hir::LifetimeName::Implicit
- | hir::LifetimeName::Underscore => {
+ | hir::LifetimeName::Infer => {
// In this case, the user left off the lifetime; so
// they wrote something like:
//
Some(RegionName {
name: region_name,
- source: RegionNameSource::AnonRegionFromUpvar(upvar_span, upvar_name.to_string()),
+ source: RegionNameSource::AnonRegionFromUpvar(upvar_span, upvar_name),
})
}
let (return_span, mir_description, hir_ty) = match hir.get(mir_hir_id) {
hir::Node::Expr(hir::Expr {
- kind: hir::ExprKind::Closure { fn_decl, body, fn_decl_span, .. },
+ kind: hir::ExprKind::Closure(&hir::Closure { fn_decl, body, fn_decl_span, .. }),
..
}) => {
let (mut span, mut hir_ty) = match fn_decl.output {
hir::FnRetTy::DefaultReturn(_) => {
- (tcx.sess.source_map().end_point(*fn_decl_span), None)
+ (tcx.sess.source_map().end_point(fn_decl_span), None)
}
hir::FnRetTy::Return(hir_ty) => (fn_decl.output.span(), Some(hir_ty)),
};
- let mir_description = match hir.body(*body).generator_kind {
+ let mir_description = match hir.body(body).generator_kind {
Some(hir::GeneratorKind::Async(gen)) => match gen {
hir::AsyncGeneratorKind::Block => " of async block",
hir::AsyncGeneratorKind::Closure => " of async closure",
Some(RegionName {
name: self.synthesize_region_name(),
- source: RegionNameSource::AnonRegionFromOutput(highlight, mir_description.to_string()),
+ source: RegionNameSource::AnonRegionFromOutput(highlight, mir_description),
})
}
let yield_span = match tcx.hir().get(self.mir_hir_id()) {
hir::Node::Expr(hir::Expr {
- kind: hir::ExprKind::Closure { fn_decl_span, .. },
+ kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }),
..
- }) => (tcx.sess.source_map().end_point(*fn_decl_span)),
+ }) => tcx.sess.source_map().end_point(fn_decl_span),
_ => self.body.span,
};
}
let mut found = false;
- tcx.fold_regions(tcx.type_of(body_parent_did), &mut true, |r: ty::Region<'tcx>, _| {
+ tcx.fold_regions(tcx.type_of(body_parent_did), |r: ty::Region<'tcx>, _| {
if *r == ty::ReEarlyBound(region) {
found = true;
}