@@ -37,6 +37,7 @@ use super::MirBorrowckCtxt;
37
37
use super :: borrow_set:: BorrowData ;
38
38
use crate :: constraints:: OutlivesConstraint ;
39
39
use crate :: fluent_generated as fluent;
40
+ use crate :: nll:: ConstraintDescription ;
40
41
use crate :: session_diagnostics:: {
41
42
CaptureArgLabel , CaptureReasonLabel , CaptureReasonNote , CaptureReasonSuggest , CaptureVarCause ,
42
43
CaptureVarKind , CaptureVarPathUseCause , OnClosureNote ,
@@ -647,6 +648,27 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
647
648
err. span_note ( span, "due to current limitations in the borrow checker, this implies a `'static` lifetime" ) ;
648
649
}
649
650
}
651
+
652
+ /// Add a label to region errors and borrow explanations when outlives constraints arise from
653
+ /// proving a type implements `Sized` or `Copy`.
654
+ fn add_sized_or_copy_bound_info (
655
+ & self ,
656
+ err : & mut Diag < ' _ > ,
657
+ blamed_category : ConstraintCategory < ' tcx > ,
658
+ path : & [ OutlivesConstraint < ' tcx > ] ,
659
+ ) {
660
+ for sought_category in [ ConstraintCategory :: SizedBound , ConstraintCategory :: CopyBound ] {
661
+ if sought_category != blamed_category
662
+ && let Some ( sought_constraint) = path. iter ( ) . find ( |c| c. category == sought_category)
663
+ {
664
+ let label = format ! (
665
+ "requirement occurs due to {}" ,
666
+ sought_category. description( ) . trim_end( )
667
+ ) ;
668
+ err. span_label ( sought_constraint. span , label) ;
669
+ }
670
+ }
671
+ }
650
672
}
651
673
652
674
/// The span(s) associated to a use of a place.
0 commit comments