diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2025-09-28 20:58:44 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-09-28 20:58:44 +0000 |
| commit | 58f5260b960004090bfa9e7ef5068d6554ac9f33 (patch) | |
| tree | 290617e3c69a5eafea6d169d9ea3f72b2d814508 /compiler/rustc_borrowck/src | |
| parent | 4973903cd204dd2cd36e15267de72ed6d954e3a6 (diff) | |
| download | rust-58f5260b960004090bfa9e7ef5068d6554ac9f33.tar.gz rust-58f5260b960004090bfa9e7ef5068d6554ac9f33.zip | |
Address review comment
Diffstat (limited to 'compiler/rustc_borrowck/src')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 66c43a07c80..67e33b37416 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -417,16 +417,20 @@ impl<'tcx> BorrowExplanation<'tcx> { self.add_object_lifetime_default_note(tcx, err, unsize_ty); } - for constraint in path { - if let ConstraintCategory::Predicate(pred) = constraint.category - && !pred.is_dummy() - { - err.span_note( - pred, - format!("requirement that the value outlives `{region_name}` introduced here"), - ); - break; - } + if let Some(pred) = path + .iter() + .filter_map(|constraint| match constraint.category { + ConstraintCategory::Predicate(pred) if !pred.is_dummy() => Some(pred), + _ => None, + }) + .next() + { + err.span_note( + pred, + format!( + "requirement that the value outlives `{region_name}` introduced here" + ), + ); } self.add_lifetime_bound_suggestion_to_diagnostic(err, &category, span, region_name); |
