@@ -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 ,
@@ -664,6 +665,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
664665 diag : & mut Diag < ' _ , G > ,
665666 path : & [ OutlivesConstraint < ' tcx > ] ,
666667 ) {
668+ const BORROWCK_LIMITATION_IMPLIES_STATIC : DiagMessage = inline_fluent ! (
669+ "due to a current limitation of the type system, this implies a `'static` lifetime"
670+ ) ;
671+
667672 let tcx = self . infcx . tcx ;
668673 let Some ( ( gat_hir_id, generics) ) = path. iter ( ) . find_map ( |constraint| {
669674 let outlived = constraint. sub ;
@@ -700,7 +705,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
700705 . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == gat_hir_id)
701706 . is_some ( )
702707 {
703- diag. span_note ( pred. span , fluent :: borrowck_limitations_implies_static ) ;
708+ diag. span_note ( pred. span , BORROWCK_LIMITATION_IMPLIES_STATIC ) ;
704709 return ;
705710 }
706711 for bound in bounds. iter ( ) {
@@ -711,7 +716,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
711716 . rfind ( |bgp| tcx. local_def_id_to_hir_id ( bgp. def_id ) == gat_hir_id)
712717 . is_some ( )
713718 {
714- diag. span_note ( bound. span , fluent :: borrowck_limitations_implies_static ) ;
719+ diag. span_note ( bound. span , BORROWCK_LIMITATION_IMPLIES_STATIC ) ;
715720 return ;
716721 }
717722 }
@@ -1312,7 +1317,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13121317 let mut span: MultiSpan = spans. clone ( ) . into ( ) ;
13131318 err. arg ( "ty" , param_ty. to_string ( ) ) ;
13141319 let msg = err. dcx . eagerly_translate_to_string (
1315- fluent :: borrowck_moved_a_fn_once_in_call_def ,
1320+ inline_fluent ! ( "`{$ty}` is made to be an `FnOnce` closure here" ) ,
13161321 err. args . iter ( ) ,
13171322 ) ;
13181323 err. remove_arg ( "ty" ) ;
@@ -1321,9 +1326,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13211326 }
13221327 span. push_span_label (
13231328 fn_call_span,
1324- fluent:: borrowck_moved_a_fn_once_in_call,
1329+ inline_fluent ! ( "this value implements `FnOnce`, which causes it to be moved when called" ) ,
1330+ ) ;
1331+ err. span_note (
1332+ span,
1333+ inline_fluent ! ( "`FnOnce` closures can only be called once" ) ,
13251334 ) ;
1326- err. span_note ( span, fluent:: borrowck_moved_a_fn_once_in_call_call) ;
13271335 } else {
13281336 err. subdiagnostic ( CaptureReasonNote :: FnOnceMoveInCall { var_span } ) ;
13291337 }
0 commit comments