rustc_borrowck: fmt
This commit is contained in:
parent
1481ab3f75
commit
f43cdcea22
@ -35,7 +35,7 @@
|
|||||||
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
|
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
|
||||||
};
|
};
|
||||||
use crate::universal_regions::DefiningTy;
|
use crate::universal_regions::DefiningTy;
|
||||||
use crate::{borrowck_errors, fluent_generated, MirBorrowckCtxt};
|
use crate::{borrowck_errors, fluent_generated as fluent, MirBorrowckCtxt};
|
||||||
|
|
||||||
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
|
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
|
||||||
fn description(&self) -> &'static str {
|
fn description(&self) -> &'static str {
|
||||||
@ -250,23 +250,28 @@ fn suggest_static_lifetime_for_gat_from_hrtb(
|
|||||||
debug!(?hrtb_bounds);
|
debug!(?hrtb_bounds);
|
||||||
|
|
||||||
hrtb_bounds.iter().for_each(|bound| {
|
hrtb_bounds.iter().for_each(|bound| {
|
||||||
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
|
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else {
|
||||||
diag.span_note(
|
return;
|
||||||
*trait_span,
|
};
|
||||||
fluent_generated::borrowck_limitations_implies_static,
|
diag.span_note(*trait_span, fluent::borrowck_limitations_implies_static);
|
||||||
);
|
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local())
|
||||||
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
|
else {
|
||||||
let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
|
return;
|
||||||
|
};
|
||||||
|
let Def(_, trait_res_defid) = trait_ref.path.res else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
debug!(?generics_fn);
|
debug!(?generics_fn);
|
||||||
generics_fn.predicates.iter().for_each(|predicate| {
|
generics_fn.predicates.iter().for_each(|predicate| {
|
||||||
let BoundPredicate(
|
let BoundPredicate(WhereBoundPredicate {
|
||||||
WhereBoundPredicate {
|
span: bounded_span,
|
||||||
span: bounded_span,
|
bounded_ty,
|
||||||
bounded_ty,
|
bounds,
|
||||||
bounds,
|
..
|
||||||
..
|
}) = predicate
|
||||||
}
|
else {
|
||||||
) = predicate else { return; };
|
return;
|
||||||
|
};
|
||||||
bounds.iter().for_each(|bd| {
|
bounds.iter().for_each(|bd| {
|
||||||
if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd
|
if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd
|
||||||
&& let Def(_, res_defid) = tr_ref.path.res
|
&& let Def(_, res_defid) = tr_ref.path.res
|
||||||
@ -276,16 +281,17 @@ fn suggest_static_lifetime_for_gat_from_hrtb(
|
|||||||
&& generics_fn.params
|
&& generics_fn.params
|
||||||
.iter()
|
.iter()
|
||||||
.rfind(|param| param.def_id.to_def_id() == defid)
|
.rfind(|param| param.def_id.to_def_id() == defid)
|
||||||
.is_some() {
|
.is_some()
|
||||||
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
|
{
|
||||||
}
|
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if suggestions.len() > 0 {
|
if suggestions.len() > 0 {
|
||||||
suggestions.dedup();
|
suggestions.dedup();
|
||||||
diag.multipart_suggestion_verbose(
|
diag.multipart_suggestion_verbose(
|
||||||
fluent_generated::borrowck_restrict_to_static,
|
fluent::borrowck_restrict_to_static,
|
||||||
suggestions,
|
suggestions,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
@ -992,16 +998,12 @@ fn suggest_constrain_dyn_trait_in_impl(
|
|||||||
debug!("trait spans found: {:?}", traits);
|
debug!("trait spans found: {:?}", traits);
|
||||||
for span in &traits {
|
for span in &traits {
|
||||||
let mut multi_span: MultiSpan = vec![*span].into();
|
let mut multi_span: MultiSpan = vec![*span].into();
|
||||||
multi_span
|
multi_span.push_span_label(*span, fluent::borrowck_implicit_static);
|
||||||
.push_span_label(*span, fluent_generated::borrowck_implicit_static);
|
multi_span.push_span_label(ident.span, fluent::borrowck_implicit_static_introduced);
|
||||||
multi_span.push_span_label(
|
|
||||||
ident.span,
|
|
||||||
fluent_generated::borrowck_implicit_static_introduced,
|
|
||||||
);
|
|
||||||
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
|
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
fluent_generated::borrowck_implicit_static_relax,
|
fluent::borrowck_implicit_static_relax,
|
||||||
" + '_",
|
" + '_",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
@ -1163,7 +1165,7 @@ fn suggest_deref_closure_return(&self, diag: &mut Diag<'_>) {
|
|||||||
if ocx.select_all_or_error().is_empty() && count > 0 {
|
if ocx.select_all_or_error().is_empty() && count > 0 {
|
||||||
diag.span_suggestion_verbose(
|
diag.span_suggestion_verbose(
|
||||||
tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(),
|
tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(),
|
||||||
fluent_generated::borrowck_dereference_suggestion,
|
fluent::borrowck_dereference_suggestion,
|
||||||
"*".repeat(count),
|
"*".repeat(count),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
@ -1209,7 +1211,7 @@ fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
|
|||||||
if let Some(closure_span) = closure_span {
|
if let Some(closure_span) = closure_span {
|
||||||
diag.span_suggestion_verbose(
|
diag.span_suggestion_verbose(
|
||||||
closure_span,
|
closure_span,
|
||||||
fluent_generated::borrowck_move_closure_suggestion,
|
fluent::borrowck_move_closure_suggestion,
|
||||||
"move ",
|
"move ",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user