@@ -290,7 +290,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
290290 }
291291
292292 if tcx. is_lang_item ( leaf_trait_ref. def_id ( ) , LangItem :: Drop )
293- && matches ! ( predicate_constness, ty:: BoundConstness :: ConstIfConst | ty:: BoundConstness :: Const )
293+ && matches ! ( predicate_constness, Some ( ty:: BoundConstness :: ConstIfConst | ty:: BoundConstness :: Const ) )
294294 {
295295 err. note ( "`~const Drop` was renamed to `~const Destruct`" ) ;
296296 err. note ( "See <https://github.com/rust-lang/rust/pull/94901> for more details" ) ;
@@ -2192,27 +2192,29 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21922192 & self ,
21932193 trait_predicate : ty:: PolyTraitPredicate < ' tcx > ,
21942194 message : Option < String > ,
2195- predicate_constness : ty:: BoundConstness ,
2195+ predicate_constness : Option < ty:: BoundConstness > ,
21962196 append_const_msg : Option < AppendConstMessage > ,
21972197 post_message : String ,
21982198 ) -> String {
21992199 message
22002200 . and_then ( |cannot_do_this| {
22012201 match ( predicate_constness, append_const_msg) {
22022202 // do nothing if predicate is not const
2203- ( ty :: BoundConstness :: NotConst , _) => Some ( cannot_do_this) ,
2203+ ( None , _) => Some ( cannot_do_this) ,
22042204 // suggested using default post message
22052205 (
2206- ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ,
2206+ Some ( ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ) ,
22072207 Some ( AppendConstMessage :: Default ) ,
22082208 ) => Some ( format ! ( "{cannot_do_this} in const contexts" ) ) ,
22092209 // overridden post message
22102210 (
2211- ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ,
2211+ Some ( ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ) ,
22122212 Some ( AppendConstMessage :: Custom ( custom_msg, _) ) ,
22132213 ) => Some ( format ! ( "{cannot_do_this}{custom_msg}" ) ) ,
22142214 // fallback to generic message
2215- ( ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst , None ) => None ,
2215+ ( Some ( ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ) , None ) => {
2216+ None
2217+ }
22162218 }
22172219 } )
22182220 . unwrap_or_else ( || {
@@ -2358,26 +2360,27 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
23582360 p : ty:: PolyTraitPredicate < ' tcx > ,
23592361 leaf : ty:: PolyTraitPredicate < ' tcx > ,
23602362 span : Span ,
2361- ) -> ( ty:: PolyTraitPredicate < ' tcx > , ty:: PolyTraitPredicate < ' tcx > , ty:: BoundConstness ) {
2363+ ) -> ( ty:: PolyTraitPredicate < ' tcx > , ty:: PolyTraitPredicate < ' tcx > , Option < ty:: BoundConstness > )
2364+ {
23622365 let trait_ref = p. to_poly_trait_ref ( ) ;
23632366 if !self . tcx . is_lang_item ( trait_ref. def_id ( ) , LangItem :: EffectsCompat ) {
2364- return ( p, leaf, ty :: BoundConstness :: NotConst ) ;
2367+ return ( p, leaf, None ) ;
23652368 }
23662369
23672370 let Some ( ty:: Alias ( ty:: AliasTyKind :: Projection , projection) ) =
23682371 trait_ref. self_ty ( ) . no_bound_vars ( ) . map ( Ty :: kind)
23692372 else {
2370- return ( p, leaf, ty :: BoundConstness :: NotConst ) ;
2373+ return ( p, leaf, None ) ;
23712374 } ;
23722375
23732376 let constness = trait_ref. skip_binder ( ) . args . const_at ( 1 ) ;
23742377
23752378 let constness = if constness == self . tcx . consts . true_ || constness. is_ct_infer ( ) {
2376- ty :: BoundConstness :: NotConst
2379+ None
23772380 } else if constness == self . tcx . consts . false_ {
2378- ty:: BoundConstness :: Const
2381+ Some ( ty:: BoundConstness :: Const )
23792382 } else if matches ! ( constness. kind( ) , ty:: ConstKind :: Param ( _) ) {
2380- ty:: BoundConstness :: ConstIfConst
2383+ Some ( ty:: BoundConstness :: ConstIfConst )
23812384 } else {
23822385 self . dcx ( ) . span_bug ( span, format ! ( "Unknown constness argument: {constness:?}" ) ) ;
23832386 } ;
0 commit comments