]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_borrowck/src/borrowck_errors.rs
Rollup merge of #106640 - lcnr:update-test, r=jackh726
[rust.git] / compiler / rustc_borrowck / src / borrowck_errors.rs
index e4942f9b666e0e837389503cd2d1099895b318da..a4943d112042dc212d419f0247933a88cecb158a 100644 (file)
@@ -440,15 +440,14 @@ pub(crate) fn cannot_capture_in_long_lived_closure(
         closure_kind: &str,
         borrowed_path: &str,
         capture_span: Span,
+        scope: &str,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
         let mut err = struct_span_err!(
             self,
             closure_span,
             E0373,
-            "{} may outlive the current function, but it borrows {}, which is owned by the current \
-             function",
-            closure_kind,
-            borrowed_path,
+            "{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
+             which is owned by the current {scope}",
         );
         err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))
             .span_label(closure_span, format!("may outlive borrowed value {}", borrowed_path));