@@ -4,7 +4,9 @@ use std::collections::BTreeMap;
44
55use rustc_abi:: { FieldIdx , VariantIdx } ;
66use rustc_data_structures:: fx:: FxIndexMap ;
7- use rustc_errors:: { Applicability , Diag , EmissionGuarantee , MultiSpan , listify} ;
7+ use rustc_errors:: {
8+ Applicability , Diag , DiagMessage , EmissionGuarantee , MultiSpan , inline_fluent, listify,
9+ } ;
810use rustc_hir:: def:: { CtorKind , Namespace } ;
911use rustc_hir:: {
1012 self as hir, CoroutineKind , GenericBound , LangItem , WhereBoundPredicate , WherePredicateKind ,
@@ -35,7 +37,6 @@ use tracing::debug;
3537use super :: MirBorrowckCtxt ;
3638use super :: borrow_set:: BorrowData ;
3739use crate :: constraints:: OutlivesConstraint ;
38- use crate :: fluent_generated as fluent;
3940use crate :: nll:: ConstraintDescription ;
4041use crate :: session_diagnostics:: {
4142 CaptureArgLabel , CaptureReasonLabel , CaptureReasonNote , CaptureReasonSuggest , CaptureVarCause ,
@@ -700,7 +701,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
700701 . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == gat_hir_id)
701702 . is_some ( )
702703 {
703- diag. span_note ( pred. span , fluent :: borrowck_limitations_implies_static ) ;
704+ diag. span_note ( pred. span , LIMITATION_NOTE ) ;
704705 return ;
705706 }
706707 for bound in bounds. iter ( ) {
@@ -711,7 +712,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
711712 . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == gat_hir_id)
712713 . is_some ( )
713714 {
714- diag. span_note ( bound. span , fluent :: borrowck_limitations_implies_static ) ;
715+ diag. span_note ( bound. span , LIMITATION_NOTE ) ;
715716 return ;
716717 }
717718 }
@@ -1312,7 +1313,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13121313 let mut span: MultiSpan = spans. clone ( ) . into ( ) ;
13131314 err. arg ( "ty" , param_ty. to_string ( ) ) ;
13141315 let msg = err. dcx . eagerly_translate_to_string (
1315- fluent :: borrowck_moved_a_fn_once_in_call_def ,
1316+ inline_fluent ! ( "`{$ty}` is made to be an `FnOnce` closure here" ) ,
13161317 err. args . iter ( ) ,
13171318 ) ;
13181319 err. remove_arg ( "ty" ) ;
@@ -1321,9 +1322,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13211322 }
13221323 span. push_span_label (
13231324 fn_call_span,
1324- fluent:: borrowck_moved_a_fn_once_in_call,
1325+ inline_fluent ! ( "this value implements `FnOnce`, which causes it to be moved when called" ) ,
1326+ ) ;
1327+ err. span_note (
1328+ span,
1329+ inline_fluent ! ( "`FnOnce` closures can only be called once" ) ,
13251330 ) ;
1326- err. span_note ( span, fluent:: borrowck_moved_a_fn_once_in_call_call) ;
13271331 } else {
13281332 err. subdiagnostic ( CaptureReasonNote :: FnOnceMoveInCall { var_span } ) ;
13291333 }
@@ -1568,3 +1572,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
15681572 self . local_name ( index) . is_none_or ( |name| name. as_str ( ) . starts_with ( '_' ) )
15691573 }
15701574}
1575+
1576+ const LIMITATION_NOTE : DiagMessage = inline_fluent ! (
1577+ "due to a current limitation of the type system, this implies a `'static` lifetime"
1578+ ) ;
0 commit comments