1
Fork 0

Rollup merge of #106549 - wcampbell0x2a:use-fmt-named-parameters-borrowck, r=estebank

Use fmt named parameters in rustc_borrowck
This commit is contained in:
fee1-dead 2023-01-09 23:35:31 +08:00 committed by GitHub
commit 99529b0cd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 63 additions and 92 deletions

View file

@ -156,7 +156,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.span_note( err.span_note(
MultiSpan::from_spans(reinit_spans), MultiSpan::from_spans(reinit_spans),
&if reinits <= 3 { &if reinits <= 3 {
format!("these {} reinitializations might get skipped", reinits) format!("these {reinits} reinitializations might get skipped")
} else { } else {
format!( format!(
"these 3 reinitializations and {} other{} might get skipped", "these 3 reinitializations and {} other{} might get skipped",
@ -225,9 +225,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.span_label( err.span_label(
span, span,
format!( format!(
"value {} here after {}move", "value {} here after {partial_str}move",
desired_action.as_verb_in_past_tense(), desired_action.as_verb_in_past_tense(),
partial_str
), ),
); );
} }
@ -257,7 +256,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&format!( &format!(
"consider creating a fresh reborrow of {} here", "consider creating a fresh reborrow of {} here",
self.describe_place(moved_place) self.describe_place(moved_place)
.map(|n| format!("`{}`", n)) .map(|n| format!("`{n}`"))
.unwrap_or_else(|| "the mutable reference".to_string()), .unwrap_or_else(|| "the mutable reference".to_string()),
), ),
"&mut *", "&mut *",
@ -271,7 +270,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
DescribePlaceOpt { including_downcast: true, including_tuple_field: true }, DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
); );
let note_msg = match opt_name { let note_msg = match opt_name {
Some(name) => format!("`{}`", name), Some(name) => format!("`{name}`"),
None => "value".to_owned(), None => "value".to_owned(),
}; };
if self.suggest_borrow_fn_like(&mut err, ty, &move_site_vec, &note_msg) { if self.suggest_borrow_fn_like(&mut err, ty, &move_site_vec, &note_msg) {
@ -297,9 +296,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
} = use_spans } = use_spans
{ {
err.note(&format!( err.note(&format!(
"{} occurs due to deref coercion to `{}`", "{} occurs due to deref coercion to `{deref_target_ty}`",
desired_action.as_noun(), desired_action.as_noun(),
deref_target_ty
)); ));
// Check first whether the source is accessible (issue #87060) // Check first whether the source is accessible (issue #87060)

View file

@ -77,7 +77,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
if borrow_span.map(|sp| !sp.overlaps(var_or_use_span)).unwrap_or(true) { if borrow_span.map(|sp| !sp.overlaps(var_or_use_span)).unwrap_or(true) {
err.span_label( err.span_label(
var_or_use_span, var_or_use_span,
format!("{}borrow later {}", borrow_desc, message), format!("{borrow_desc}borrow later {message}"),
); );
} }
} else { } else {
@ -90,7 +90,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
let capture_kind_label = message; let capture_kind_label = message;
err.span_label( err.span_label(
var_or_use_span, var_or_use_span,
format!("{}borrow later {}", borrow_desc, capture_kind_label), format!("{borrow_desc}borrow later {capture_kind_label}"),
); );
err.span_label(path_span, path_label); err.span_label(path_span, path_label);
} }
@ -110,7 +110,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
}; };
// We can use `var_or_use_span` if either `path_span` is not present, or both spans are the same // We can use `var_or_use_span` if either `path_span` is not present, or both spans are the same
if path_span.map(|path_span| path_span == var_or_use_span).unwrap_or(true) { if path_span.map(|path_span| path_span == var_or_use_span).unwrap_or(true) {
err.span_label(var_or_use_span, format!("{}{}", borrow_desc, message)); err.span_label(var_or_use_span, format!("{borrow_desc}{message}"));
} else { } else {
// path_span must be `Some` as otherwise the if condition is true // path_span must be `Some` as otherwise the if condition is true
let path_span = path_span.unwrap(); let path_span = path_span.unwrap();
@ -121,7 +121,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
let capture_kind_label = message; let capture_kind_label = message;
err.span_label( err.span_label(
var_or_use_span, var_or_use_span,
format!("{}borrow later {}", borrow_desc, capture_kind_label), format!("{borrow_desc}borrow later {capture_kind_label}"),
); );
err.span_label(path_span, path_label); err.span_label(path_span, path_label);
} }
@ -160,12 +160,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
match local_names[dropped_local] { match local_names[dropped_local] {
Some(local_name) if !local_decl.from_compiler_desugaring() => { Some(local_name) if !local_decl.from_compiler_desugaring() => {
let message = format!( let message = format!(
"{B}borrow might be used here, when `{LOC}` is dropped \ "{borrow_desc}borrow might be used here, when `{local_name}` is dropped \
and runs the {DTOR} for {TYPE}", and runs the {dtor_desc} for {type_desc}",
B = borrow_desc,
LOC = local_name,
TYPE = type_desc,
DTOR = dtor_desc
); );
err.span_label(body.source_info(drop_loc).span, message); err.span_label(body.source_info(drop_loc).span, message);
@ -180,18 +176,14 @@ impl<'tcx> BorrowExplanation<'tcx> {
err.span_label( err.span_label(
local_decl.source_info.span, local_decl.source_info.span,
format!( format!(
"a temporary with access to the {B}borrow \ "a temporary with access to the {borrow_desc}borrow \
is created here ...", is created here ...",
B = borrow_desc
), ),
); );
let message = format!( let message = format!(
"... and the {B}borrow might be used here, \ "... and the {borrow_desc}borrow might be used here, \
when that temporary is dropped \ when that temporary is dropped \
and runs the {DTOR} for {TYPE}", and runs the {dtor_desc} for {type_desc}",
B = borrow_desc,
TYPE = type_desc,
DTOR = dtor_desc
); );
err.span_label(body.source_info(drop_loc).span, message); err.span_label(body.source_info(drop_loc).span, message);
@ -249,20 +241,16 @@ impl<'tcx> BorrowExplanation<'tcx> {
err.span_label( err.span_label(
span, span,
format!( format!(
"{}requires that `{}` is borrowed for `{}`", "{}requires that `{desc}` is borrowed for `{region_name}`",
category.description(), category.description(),
desc,
region_name,
), ),
); );
} else { } else {
err.span_label( err.span_label(
span, span,
format!( format!(
"{}requires that {}borrow lasts for `{}`", "{}requires that {borrow_desc}borrow lasts for `{region_name}`",
category.description(), category.description(),
borrow_desc,
region_name,
), ),
); );
}; };
@ -296,15 +284,14 @@ impl<'tcx> BorrowExplanation<'tcx> {
if region_name.was_named() { region_name.name } else { kw::UnderscoreLifetime }; if region_name.was_named() { region_name.name } else { kw::UnderscoreLifetime };
let msg = format!( let msg = format!(
"you can add a bound to the {}to make it last less than `'static` and match `{}`", "you can add a bound to the {}to make it last less than `'static` and match `{region_name}`",
category.description(), category.description(),
region_name,
); );
err.span_suggestion_verbose( err.span_suggestion_verbose(
span.shrink_to_hi(), span.shrink_to_hi(),
&msg, &msg,
format!(" + {}", suggestable_name), format!(" + {suggestable_name}"),
Applicability::Unspecified, Applicability::Unspecified,
); );
} }

View file

@ -403,8 +403,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
move_prefix: &str, move_prefix: &str,
) { ) {
let message = format!( let message = format!(
"{}move occurs because {} has type `{}`, which does not implement the `Copy` trait", "{move_prefix}move occurs because {place_desc} has type `{ty}`, which does not implement the `Copy` trait",
move_prefix, place_desc, ty,
); );
if let Some(span) = span { if let Some(span) = span {
err.span_label(span, message); err.span_label(span, message);
@ -739,11 +738,11 @@ impl<'tcx> BorrowedContentSource<'tcx> {
BorrowedContentSource::OverloadedDeref(ty) => ty BorrowedContentSource::OverloadedDeref(ty) => ty
.ty_adt_def() .ty_adt_def()
.and_then(|adt| match tcx.get_diagnostic_name(adt.did())? { .and_then(|adt| match tcx.get_diagnostic_name(adt.did())? {
name @ (sym::Rc | sym::Arc) => Some(format!("an `{}`", name)), name @ (sym::Rc | sym::Arc) => Some(format!("an `{name}`")),
_ => None, _ => None,
}) })
.unwrap_or_else(|| format!("dereference of `{}`", ty)), .unwrap_or_else(|| format!("dereference of `{ty}`")),
BorrowedContentSource::OverloadedIndex(ty) => format!("index of `{}`", ty), BorrowedContentSource::OverloadedIndex(ty) => format!("index of `{ty}`"),
} }
} }
@ -769,11 +768,11 @@ impl<'tcx> BorrowedContentSource<'tcx> {
BorrowedContentSource::OverloadedDeref(ty) => ty BorrowedContentSource::OverloadedDeref(ty) => ty
.ty_adt_def() .ty_adt_def()
.and_then(|adt| match tcx.get_diagnostic_name(adt.did())? { .and_then(|adt| match tcx.get_diagnostic_name(adt.did())? {
name @ (sym::Rc | sym::Arc) => Some(format!("an `{}`", name)), name @ (sym::Rc | sym::Arc) => Some(format!("an `{name}`")),
_ => None, _ => None,
}) })
.unwrap_or_else(|| format!("dereference of `{}`", ty)), .unwrap_or_else(|| format!("dereference of `{ty}`")),
BorrowedContentSource::OverloadedIndex(ty) => format!("an index of `{}`", ty), BorrowedContentSource::OverloadedIndex(ty) => format!("an index of `{ty}`"),
} }
} }
@ -1033,7 +1032,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if let UseSpans::FnSelfUse { var_span, fn_call_span, fn_span, kind } = move_spans { if let UseSpans::FnSelfUse { var_span, fn_call_span, fn_span, kind } = move_spans {
let place_name = self let place_name = self
.describe_place(moved_place.as_ref()) .describe_place(moved_place.as_ref())
.map(|n| format!("`{}`", n)) .map(|n| format!("`{n}`"))
.unwrap_or_else(|| "value".to_owned()); .unwrap_or_else(|| "value".to_owned());
match kind { match kind {
CallKind::FnCall { fn_trait_id, .. } CallKind::FnCall { fn_trait_id, .. }
@ -1042,8 +1041,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.span_label( err.span_label(
fn_call_span, fn_call_span,
&format!( &format!(
"{} {}moved due to this call{}", "{place_name} {partially_str}moved due to this call{loop_message}",
place_name, partially_str, loop_message
), ),
); );
err.span_note( err.span_note(
@ -1056,8 +1054,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.span_label( err.span_label(
fn_call_span, fn_call_span,
&format!( &format!(
"{} {}moved due to usage in operator{}", "{place_name} {partially_str}moved due to usage in operator{loop_message}",
place_name, partially_str, loop_message
), ),
); );
if self.fn_self_span_reported.insert(fn_span) { if self.fn_self_span_reported.insert(fn_span) {
@ -1089,9 +1086,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.span_suggestion_verbose( err.span_suggestion_verbose(
move_span.shrink_to_lo(), move_span.shrink_to_lo(),
&format!( &format!(
"consider iterating over a slice of the `{}`'s content to \ "consider iterating over a slice of the `{ty}`'s content to \
avoid moving into the `for` loop", avoid moving into the `for` loop",
ty,
), ),
"&", "&",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
@ -1101,8 +1097,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.span_label( err.span_label(
fn_call_span, fn_call_span,
&format!( &format!(
"{} {}moved due to this implicit call to `.into_iter()`{}", "{place_name} {partially_str}moved due to this implicit call to `.into_iter()`{loop_message}",
place_name, partially_str, loop_message
), ),
); );
// If the moved place was a `&mut` ref, then we can // If the moved place was a `&mut` ref, then we can
@ -1118,7 +1113,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&format!( &format!(
"consider creating a fresh reborrow of {} here", "consider creating a fresh reborrow of {} here",
self.describe_place(moved_place.as_ref()) self.describe_place(moved_place.as_ref())
.map(|n| format!("`{}`", n)) .map(|n| format!("`{n}`"))
.unwrap_or_else(|| "the mutable reference".to_string()), .unwrap_or_else(|| "the mutable reference".to_string()),
), ),
"&mut *", "&mut *",
@ -1130,8 +1125,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.span_label( err.span_label(
fn_call_span, fn_call_span,
&format!( &format!(
"{} {}moved due to this method call{}", "{place_name} {partially_str}moved due to this method call{loop_message}",
place_name, partially_str, loop_message
), ),
); );
let infcx = tcx.infer_ctxt().build(); let infcx = tcx.infer_ctxt().build();
@ -1206,7 +1200,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if move_span != span || !loop_message.is_empty() { if move_span != span || !loop_message.is_empty() {
err.span_label( err.span_label(
move_span, move_span,
format!("value {}moved{} here{}", partially_str, move_msg, loop_message), format!("value {partially_str}moved{move_msg} here{loop_message}"),
); );
} }
// If the move error occurs due to a loop, don't show // If the move error occurs due to a loop, don't show
@ -1214,7 +1208,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if loop_message.is_empty() { if loop_message.is_empty() {
move_spans.var_span_label( move_spans.var_span_label(
err, err,
format!("variable {}moved due to use{}", partially_str, move_spans.describe()), format!("variable {partially_str}moved due to use{}", move_spans.describe()),
"moved", "moved",
); );
} }

View file

@ -264,7 +264,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
ProjectionElem::Deref, ProjectionElem::Deref,
], ],
} => { } => {
err.span_label(span, format!("cannot {ACT}", ACT = act)); err.span_label(span, format!("cannot {act}"));
if let Some(span) = get_mut_span_in_struct_field( if let Some(span) = get_mut_span_in_struct_field(
self.infcx.tcx, self.infcx.tcx,
@ -290,7 +290,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
.unwrap_or(false) => .unwrap_or(false) =>
{ {
let decl = &self.body.local_decls[local]; let decl = &self.body.local_decls[local];
err.span_label(span, format!("cannot {ACT}", ACT = act)); err.span_label(span, format!("cannot {act}"));
if let Some(mir::Statement { if let Some(mir::Statement {
source_info, source_info,
kind: kind:
@ -639,7 +639,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
} }
PlaceRef { local: _, projection: [.., ProjectionElem::Deref] } => { PlaceRef { local: _, projection: [.., ProjectionElem::Deref] } => {
err.span_label(span, format!("cannot {ACT}", ACT = act)); err.span_label(span, format!("cannot {act}"));
match opt_source { match opt_source {
Some(BorrowedContentSource::OverloadedDeref(ty)) => { Some(BorrowedContentSource::OverloadedDeref(ty)) => {
@ -1212,7 +1212,7 @@ fn suggest_ampmut<'tcx>(
{ {
let lt_name = &src[1..ws_pos]; let lt_name = &src[1..ws_pos];
let ty = &src[ws_pos..]; let ty = &src[ws_pos..];
return (true, highlight_span, format!("&{} mut{}", lt_name, ty)); return (true, highlight_span, format!("&{lt_name} mut{ty}"));
} }
let ty_mut = local_decl.ty.builtin_deref(true).unwrap(); let ty_mut = local_decl.ty.builtin_deref(true).unwrap();

View file

@ -209,14 +209,14 @@ impl OutlivesSuggestionBuilder {
let mut diag = if suggested.len() == 1 { let mut diag = if suggested.len() == 1 {
mbcx.infcx.tcx.sess.diagnostic().struct_help(&match suggested.last().unwrap() { mbcx.infcx.tcx.sess.diagnostic().struct_help(&match suggested.last().unwrap() {
SuggestedConstraint::Outlives(a, bs) => { SuggestedConstraint::Outlives(a, bs) => {
let bs: SmallVec<[String; 2]> = bs.iter().map(|r| format!("{}", r)).collect(); let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect();
format!("add bound `{}: {}`", a, bs.join(" + ")) format!("add bound `{a}: {}`", bs.join(" + "))
} }
SuggestedConstraint::Equal(a, b) => { SuggestedConstraint::Equal(a, b) => {
format!("`{}` and `{}` must be the same: replace one with the other", a, b) format!("`{a}` and `{b}` must be the same: replace one with the other")
} }
SuggestedConstraint::Static(a) => format!("replace `{}` with `'static`", a), SuggestedConstraint::Static(a) => format!("replace `{a}` with `'static`"),
}) })
} else { } else {
// Create a new diagnostic. // Create a new diagnostic.
@ -231,18 +231,16 @@ impl OutlivesSuggestionBuilder {
for constraint in suggested { for constraint in suggested {
match constraint { match constraint {
SuggestedConstraint::Outlives(a, bs) => { SuggestedConstraint::Outlives(a, bs) => {
let bs: SmallVec<[String; 2]> = let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect();
bs.iter().map(|r| format!("{}", r)).collect(); diag.help(&format!("add bound `{a}: {}`", bs.join(" + ")));
diag.help(&format!("add bound `{}: {}`", a, bs.join(" + ")));
} }
SuggestedConstraint::Equal(a, b) => { SuggestedConstraint::Equal(a, b) => {
diag.help(&format!( diag.help(&format!(
"`{}` and `{}` must be the same: replace one with the other", "`{a}` and `{b}` must be the same: replace one with the other",
a, b
)); ));
} }
SuggestedConstraint::Static(a) => { SuggestedConstraint::Static(a) => {
diag.help(&format!("replace `{}` with `'static`", a)); diag.help(&format!("replace `{a}` with `'static`"));
} }
} }
} }

View file

@ -422,7 +422,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
); );
(desc, note) (desc, note)
} }
_ => panic!("Unexpected type {:?}", ty), _ => panic!("Unexpected type {ty:?}"),
}; };
diag.note(&format!("requirement occurs because of {desc}",)); diag.note(&format!("requirement occurs because of {desc}",));
diag.note(&note); diag.note(&note);
@ -725,10 +725,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let lifetime = if f.has_name() { fr_name.name } else { kw::UnderscoreLifetime }; let lifetime = if f.has_name() { fr_name.name } else { kw::UnderscoreLifetime };
let arg = match param.param.pat.simple_ident() { let arg = match param.param.pat.simple_ident() {
Some(simple_ident) => format!("argument `{}`", simple_ident), Some(simple_ident) => format!("argument `{simple_ident}`"),
None => "the argument".to_string(), None => "the argument".to_string(),
}; };
let captures = format!("captures data from {}", arg); let captures = format!("captures data from {arg}");
return nice_region_error::suggest_new_region_bound( return nice_region_error::suggest_new_region_bound(
self.infcx.tcx, self.infcx.tcx,

View file

@ -202,7 +202,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// This is _not_ idempotent. Call `give_region_a_name` when possible. /// This is _not_ idempotent. Call `give_region_a_name` when possible.
pub(crate) fn synthesize_region_name(&self) -> Symbol { pub(crate) fn synthesize_region_name(&self) -> Symbol {
let c = self.next_region_name.replace_with(|counter| *counter + 1); let c = self.next_region_name.replace_with(|counter| *counter + 1);
Symbol::intern(&format!("'{:?}", c)) Symbol::intern(&format!("'{c:?}"))
} }
/// Maps from an internal MIR region vid to something that we can /// Maps from an internal MIR region vid to something that we can
@ -619,7 +619,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
// programs, so we need to use delay_span_bug here. See #82126. // programs, so we need to use delay_span_bug here. See #82126.
self.infcx.tcx.sess.delay_span_bug( self.infcx.tcx.sess.delay_span_bug(
hir_arg.span(), hir_arg.span(),
&format!("unmatched subst and hir arg: found {:?} vs {:?}", kind, hir_arg), &format!("unmatched subst and hir arg: found {kind:?} vs {hir_arg:?}"),
); );
} }
} }
@ -783,8 +783,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
} else { } else {
span_bug!( span_bug!(
hir_ty.span, hir_ty.span,
"bounds from lowered return type of async fn did not match expected format: {:?}", "bounds from lowered return type of async fn did not match expected format: {opaque_ty:?}",
opaque_ty
); );
} }
} }

View file

@ -18,7 +18,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
upvars: &[Upvar<'tcx>], upvars: &[Upvar<'tcx>],
fr: RegionVid, fr: RegionVid,
) -> Option<(Option<Symbol>, Span)> { ) -> Option<(Option<Symbol>, Span)> {
debug!("get_var_name_and_span_for_region(fr={:?})", fr); debug!("get_var_name_and_span_for_region(fr={fr:?})");
assert!(self.universal_regions().is_universal_region(fr)); assert!(self.universal_regions().is_universal_region(fr));
debug!("get_var_name_and_span_for_region: attempting upvar"); debug!("get_var_name_and_span_for_region: attempting upvar");
@ -44,10 +44,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
) -> Option<usize> { ) -> Option<usize> {
let upvar_index = let upvar_index =
self.universal_regions().defining_ty.upvar_tys().position(|upvar_ty| { self.universal_regions().defining_ty.upvar_tys().position(|upvar_ty| {
debug!("get_upvar_index_for_region: upvar_ty={:?}", upvar_ty); debug!("get_upvar_index_for_region: upvar_ty={upvar_ty:?}");
tcx.any_free_region_meets(&upvar_ty, |r| { tcx.any_free_region_meets(&upvar_ty, |r| {
let r = r.to_region_vid(); let r = r.to_region_vid();
debug!("get_upvar_index_for_region: r={:?} fr={:?}", r, fr); debug!("get_upvar_index_for_region: r={r:?} fr={fr:?}");
r == fr r == fr
}) })
})?; })?;
@ -55,8 +55,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let upvar_ty = self.universal_regions().defining_ty.upvar_tys().nth(upvar_index); let upvar_ty = self.universal_regions().defining_ty.upvar_tys().nth(upvar_index);
debug!( debug!(
"get_upvar_index_for_region: found {:?} in upvar {} which has type {:?}", "get_upvar_index_for_region: found {fr:?} in upvar {upvar_index} which has type {upvar_ty:?}",
fr, upvar_index, upvar_ty,
); );
Some(upvar_index) Some(upvar_index)
@ -71,13 +70,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
upvar_index: usize, upvar_index: usize,
) -> (Symbol, Span) { ) -> (Symbol, Span) {
let upvar_hir_id = upvars[upvar_index].place.get_root_variable(); let upvar_hir_id = upvars[upvar_index].place.get_root_variable();
debug!("get_upvar_name_and_span_for_region: upvar_hir_id={:?}", upvar_hir_id); debug!("get_upvar_name_and_span_for_region: upvar_hir_id={upvar_hir_id:?}");
let upvar_name = tcx.hir().name(upvar_hir_id); let upvar_name = tcx.hir().name(upvar_hir_id);
let upvar_span = tcx.hir().span(upvar_hir_id); let upvar_span = tcx.hir().span(upvar_hir_id);
debug!( debug!(
"get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}", "get_upvar_name_and_span_for_region: upvar_name={upvar_name:?} upvar_span={upvar_span:?}",
upvar_name, upvar_span
); );
(upvar_name, upvar_span) (upvar_name, upvar_span)
@ -97,15 +95,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let argument_index = let argument_index =
self.universal_regions().unnormalized_input_tys.iter().skip(implicit_inputs).position( self.universal_regions().unnormalized_input_tys.iter().skip(implicit_inputs).position(
|arg_ty| { |arg_ty| {
debug!("get_argument_index_for_region: arg_ty = {:?}", arg_ty); debug!("get_argument_index_for_region: arg_ty = {arg_ty:?}");
tcx.any_free_region_meets(arg_ty, |r| r.to_region_vid() == fr) tcx.any_free_region_meets(arg_ty, |r| r.to_region_vid() == fr)
}, },
)?; )?;
debug!( debug!(
"get_argument_index_for_region: found {:?} in argument {} which has type {:?}", "get_argument_index_for_region: found {fr:?} in argument {argument_index} which has type {:?}",
fr,
argument_index,
self.universal_regions().unnormalized_input_tys[argument_index], self.universal_regions().unnormalized_input_tys[argument_index],
); );
@ -122,13 +118,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
) -> (Option<Symbol>, Span) { ) -> (Option<Symbol>, Span) {
let implicit_inputs = self.universal_regions().defining_ty.implicit_inputs(); let implicit_inputs = self.universal_regions().defining_ty.implicit_inputs();
let argument_local = Local::new(implicit_inputs + argument_index + 1); let argument_local = Local::new(implicit_inputs + argument_index + 1);
debug!("get_argument_name_and_span_for_region: argument_local={:?}", argument_local); debug!("get_argument_name_and_span_for_region: argument_local={argument_local:?}");
let argument_name = local_names[argument_local]; let argument_name = local_names[argument_local];
let argument_span = body.local_decls[argument_local].source_info.span; let argument_span = body.local_decls[argument_local].source_info.span;
debug!( debug!(
"get_argument_name_and_span_for_region: argument_name={:?} argument_span={:?}", "get_argument_name_and_span_for_region: argument_name={argument_name:?} argument_span={argument_span:?}",
argument_name, argument_span
); );
(argument_name, argument_span) (argument_name, argument_span)

View file

@ -192,7 +192,7 @@ fn write_row(
) -> Result<(), Box<dyn Error>> { ) -> Result<(), Box<dyn Error>> {
for (index, c) in columns.iter().enumerate() { for (index, c) in columns.iter().enumerate() {
let tail = if index == columns.len() - 1 { "\n" } else { "\t" }; let tail = if index == columns.len() - 1 { "\n" } else { "\t" };
write!(out, "{:?}{}", c.to_string(location_table), tail)?; write!(out, "{:?}{tail}", c.to_string(location_table))?;
} }
Ok(()) Ok(())
} }