Skip to content

Commit f43cdce

Browse files
committed
rustc_borrowck: fmt
1 parent 1481ab3 commit f43cdce

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+31-29
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::session_diagnostics::{
3535
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
3636
};
3737
use crate::universal_regions::DefiningTy;
38-
use crate::{borrowck_errors, fluent_generated, MirBorrowckCtxt};
38+
use crate::{borrowck_errors, fluent_generated as fluent, MirBorrowckCtxt};
3939

4040
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
4141
fn description(&self) -> &'static str {
@@ -250,23 +250,28 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
250250
debug!(?hrtb_bounds);
251251

252252
hrtb_bounds.iter().for_each(|bound| {
253-
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
254-
diag.span_note(
255-
*trait_span,
256-
fluent_generated::borrowck_limitations_implies_static,
257-
);
258-
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
259-
let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
253+
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else {
254+
return;
255+
};
256+
diag.span_note(*trait_span, fluent::borrowck_limitations_implies_static);
257+
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local())
258+
else {
259+
return;
260+
};
261+
let Def(_, trait_res_defid) = trait_ref.path.res else {
262+
return;
263+
};
260264
debug!(?generics_fn);
261265
generics_fn.predicates.iter().for_each(|predicate| {
262-
let BoundPredicate(
263-
WhereBoundPredicate {
264-
span: bounded_span,
265-
bounded_ty,
266-
bounds,
267-
..
268-
}
269-
) = predicate else { return; };
266+
let BoundPredicate(WhereBoundPredicate {
267+
span: bounded_span,
268+
bounded_ty,
269+
bounds,
270+
..
271+
}) = predicate
272+
else {
273+
return;
274+
};
270275
bounds.iter().for_each(|bd| {
271276
if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd
272277
&& let Def(_, res_defid) = tr_ref.path.res
@@ -276,16 +281,17 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
276281
&& generics_fn.params
277282
.iter()
278283
.rfind(|param| param.def_id.to_def_id() == defid)
279-
.is_some() {
280-
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
281-
}
284+
.is_some()
285+
{
286+
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
287+
}
282288
});
283289
});
284290
});
285291
if suggestions.len() > 0 {
286292
suggestions.dedup();
287293
diag.multipart_suggestion_verbose(
288-
fluent_generated::borrowck_restrict_to_static,
294+
fluent::borrowck_restrict_to_static,
289295
suggestions,
290296
Applicability::MaybeIncorrect,
291297
);
@@ -992,16 +998,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
992998
debug!("trait spans found: {:?}", traits);
993999
for span in &traits {
9941000
let mut multi_span: MultiSpan = vec![*span].into();
995-
multi_span
996-
.push_span_label(*span, fluent_generated::borrowck_implicit_static);
997-
multi_span.push_span_label(
998-
ident.span,
999-
fluent_generated::borrowck_implicit_static_introduced,
1000-
);
1001+
multi_span.push_span_label(*span, fluent::borrowck_implicit_static);
1002+
multi_span.push_span_label(ident.span, fluent::borrowck_implicit_static_introduced);
10011003
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
10021004
err.span_suggestion_verbose(
10031005
span.shrink_to_hi(),
1004-
fluent_generated::borrowck_implicit_static_relax,
1006+
fluent::borrowck_implicit_static_relax,
10051007
" + '_",
10061008
Applicability::MaybeIncorrect,
10071009
);
@@ -1163,7 +1165,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11631165
if ocx.select_all_or_error().is_empty() && count > 0 {
11641166
diag.span_suggestion_verbose(
11651167
tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(),
1166-
fluent_generated::borrowck_dereference_suggestion,
1168+
fluent::borrowck_dereference_suggestion,
11671169
"*".repeat(count),
11681170
Applicability::MachineApplicable,
11691171
);
@@ -1209,7 +1211,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
12091211
if let Some(closure_span) = closure_span {
12101212
diag.span_suggestion_verbose(
12111213
closure_span,
1212-
fluent_generated::borrowck_move_closure_suggestion,
1214+
fluent::borrowck_move_closure_suggestion,
12131215
"move ",
12141216
Applicability::MaybeIncorrect,
12151217
);

0 commit comments

Comments
 (0)