@@ -15,8 +15,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
15
15
use crate :: traits:: query:: normalize:: QueryNormalizeExt as _;
16
16
use crate :: traits:: specialize:: to_pretty_impl_header;
17
17
use crate :: traits:: NormalizeExt ;
18
- use on_unimplemented:: OnUnimplementedNote ;
19
- use on_unimplemented:: TypeErrCtxtExt as _;
18
+ use on_unimplemented:: { AppendConstMessage , OnUnimplementedNote , TypeErrCtxtExt as _} ;
20
19
use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
21
20
use rustc_errors:: {
22
21
pluralize, struct_span_err, Applicability , Diagnostic , DiagnosticBuilder , ErrorGuaranteed ,
@@ -707,7 +706,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
707
706
conversion on the error value using the `From` trait"
708
707
. to_owned ( ) ,
709
708
) ,
710
- Some ( None ) ,
709
+ Some ( AppendConstMessage :: Default ) ,
711
710
)
712
711
} else {
713
712
( message, note, append_const_msg)
@@ -1272,7 +1271,7 @@ trait InferCtxtPrivExt<'tcx> {
1272
1271
trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
1273
1272
message : Option < String > ,
1274
1273
predicate_is_const : bool ,
1275
- append_const_msg : Option < Option < rustc_span :: Symbol > > ,
1274
+ append_const_msg : Option < AppendConstMessage > ,
1276
1275
post_message : String ,
1277
1276
) -> String ;
1278
1277
@@ -2682,7 +2681,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2682
2681
trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
2683
2682
message : Option < String > ,
2684
2683
predicate_is_const : bool ,
2685
- append_const_msg : Option < Option < rustc_span :: Symbol > > ,
2684
+ append_const_msg : Option < AppendConstMessage > ,
2686
2685
post_message : String ,
2687
2686
) -> String {
2688
2687
message
@@ -2691,17 +2690,19 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2691
2690
// do nothing if predicate is not const
2692
2691
( false , _) => Some ( cannot_do_this) ,
2693
2692
// suggested using default post message
2694
- ( true , Some ( None ) ) => Some ( format ! ( "{cannot_do_this} in const contexts" ) ) ,
2693
+ ( true , Some ( AppendConstMessage :: Default ) ) => {
2694
+ Some ( format ! ( "{cannot_do_this} in const contexts" ) )
2695
+ }
2695
2696
// overridden post message
2696
- ( true , Some ( Some ( post_message ) ) ) => {
2697
- Some ( format ! ( "{cannot_do_this}{post_message }" ) )
2697
+ ( true , Some ( AppendConstMessage :: Custom ( custom_msg ) ) ) => {
2698
+ Some ( format ! ( "{cannot_do_this}{custom_msg }" ) )
2698
2699
}
2699
2700
// fallback to generic message
2700
2701
( true , None ) => None ,
2701
2702
}
2702
2703
} )
2703
2704
. unwrap_or_else ( || {
2704
- format ! ( "the trait bound `{}` is not satisfied{}" , trait_predicate, post_message, )
2705
+ format ! ( "the trait bound `{}` is not satisfied{}" , trait_predicate, post_message)
2705
2706
} )
2706
2707
}
2707
2708
0 commit comments