@@ -15,8 +15,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
1515use crate :: traits:: query:: normalize:: QueryNormalizeExt as _;
1616use crate :: traits:: specialize:: to_pretty_impl_header;
1717use crate :: traits:: NormalizeExt ;
18- use on_unimplemented:: OnUnimplementedNote ;
19- use on_unimplemented:: TypeErrCtxtExt as _;
18+ use on_unimplemented:: { AppendConstMessage , OnUnimplementedNote , TypeErrCtxtExt as _} ;
2019use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
2120use rustc_errors:: {
2221 pluralize, struct_span_err, Applicability , Diagnostic , DiagnosticBuilder , ErrorGuaranteed ,
@@ -707,7 +706,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
707706 conversion on the error value using the `From` trait"
708707 . to_owned ( ) ,
709708 ) ,
710- Some ( None ) ,
709+ Some ( AppendConstMessage :: Default ) ,
711710 )
712711 } else {
713712 ( message, note, append_const_msg)
@@ -1272,7 +1271,7 @@ trait InferCtxtPrivExt<'tcx> {
12721271 trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
12731272 message : Option < String > ,
12741273 predicate_is_const : bool ,
1275- append_const_msg : Option < Option < rustc_span :: Symbol > > ,
1274+ append_const_msg : Option < AppendConstMessage > ,
12761275 post_message : String ,
12771276 ) -> String ;
12781277
@@ -2682,7 +2681,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
26822681 trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
26832682 message : Option < String > ,
26842683 predicate_is_const : bool ,
2685- append_const_msg : Option < Option < rustc_span :: Symbol > > ,
2684+ append_const_msg : Option < AppendConstMessage > ,
26862685 post_message : String ,
26872686 ) -> String {
26882687 message
@@ -2691,17 +2690,19 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
26912690 // do nothing if predicate is not const
26922691 ( false , _) => Some ( cannot_do_this) ,
26932692 // 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+ }
26952696 // 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 }" ) )
26982699 }
26992700 // fallback to generic message
27002701 ( true , None ) => None ,
27012702 }
27022703 } )
27032704 . 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)
27052706 } )
27062707 }
27072708
0 commit comments