Skip to content

Commit 58f5260

Browse files
committed
Address review comment
1 parent 4973903 commit 58f5260

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,20 @@ impl<'tcx> BorrowExplanation<'tcx> {
417417
self.add_object_lifetime_default_note(tcx, err, unsize_ty);
418418
}
419419

420-
for constraint in path {
421-
if let ConstraintCategory::Predicate(pred) = constraint.category
422-
&& !pred.is_dummy()
423-
{
424-
err.span_note(
425-
pred,
426-
format!("requirement that the value outlives `{region_name}` introduced here"),
427-
);
428-
break;
429-
}
420+
if let Some(pred) = path
421+
.iter()
422+
.filter_map(|constraint| match constraint.category {
423+
ConstraintCategory::Predicate(pred) if !pred.is_dummy() => Some(pred),
424+
_ => None,
425+
})
426+
.next()
427+
{
428+
err.span_note(
429+
pred,
430+
format!(
431+
"requirement that the value outlives `{region_name}` introduced here"
432+
),
433+
);
430434
}
431435

432436
self.add_lifetime_bound_suggestion_to_diagnostic(err, &category, span, region_name);

0 commit comments

Comments
 (0)