@@ -290,7 +290,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
290
290
}
291
291
292
292
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 ) )
294
294
{
295
295
err. note ( "`~const Drop` was renamed to `~const Destruct`" ) ;
296
296
err. note ( "See <https://github.com/rust-lang/rust/pull/94901> for more details" ) ;
@@ -2192,27 +2192,29 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
2192
2192
& self ,
2193
2193
trait_predicate : ty:: PolyTraitPredicate < ' tcx > ,
2194
2194
message : Option < String > ,
2195
- predicate_constness : ty:: BoundConstness ,
2195
+ predicate_constness : Option < ty:: BoundConstness > ,
2196
2196
append_const_msg : Option < AppendConstMessage > ,
2197
2197
post_message : String ,
2198
2198
) -> String {
2199
2199
message
2200
2200
. and_then ( |cannot_do_this| {
2201
2201
match ( predicate_constness, append_const_msg) {
2202
2202
// do nothing if predicate is not const
2203
- ( ty :: BoundConstness :: NotConst , _) => Some ( cannot_do_this) ,
2203
+ ( None , _) => Some ( cannot_do_this) ,
2204
2204
// suggested using default post message
2205
2205
(
2206
- ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ,
2206
+ Some ( ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ) ,
2207
2207
Some ( AppendConstMessage :: Default ) ,
2208
2208
) => Some ( format ! ( "{cannot_do_this} in const contexts" ) ) ,
2209
2209
// overridden post message
2210
2210
(
2211
- ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ,
2211
+ Some ( ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst ) ,
2212
2212
Some ( AppendConstMessage :: Custom ( custom_msg, _) ) ,
2213
2213
) => Some ( format ! ( "{cannot_do_this}{custom_msg}" ) ) ,
2214
2214
// 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
+ }
2216
2218
}
2217
2219
} )
2218
2220
. unwrap_or_else ( || {
@@ -2358,26 +2360,27 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
2358
2360
p : ty:: PolyTraitPredicate < ' tcx > ,
2359
2361
leaf : ty:: PolyTraitPredicate < ' tcx > ,
2360
2362
span : Span ,
2361
- ) -> ( ty:: PolyTraitPredicate < ' tcx > , ty:: PolyTraitPredicate < ' tcx > , ty:: BoundConstness ) {
2363
+ ) -> ( ty:: PolyTraitPredicate < ' tcx > , ty:: PolyTraitPredicate < ' tcx > , Option < ty:: BoundConstness > )
2364
+ {
2362
2365
let trait_ref = p. to_poly_trait_ref ( ) ;
2363
2366
if !self . tcx . is_lang_item ( trait_ref. def_id ( ) , LangItem :: EffectsCompat ) {
2364
- return ( p, leaf, ty :: BoundConstness :: NotConst ) ;
2367
+ return ( p, leaf, None ) ;
2365
2368
}
2366
2369
2367
2370
let Some ( ty:: Alias ( ty:: AliasTyKind :: Projection , projection) ) =
2368
2371
trait_ref. self_ty ( ) . no_bound_vars ( ) . map ( Ty :: kind)
2369
2372
else {
2370
- return ( p, leaf, ty :: BoundConstness :: NotConst ) ;
2373
+ return ( p, leaf, None ) ;
2371
2374
} ;
2372
2375
2373
2376
let constness = trait_ref. skip_binder ( ) . args . const_at ( 1 ) ;
2374
2377
2375
2378
let constness = if constness == self . tcx . consts . true_ || constness. is_ct_infer ( ) {
2376
- ty :: BoundConstness :: NotConst
2379
+ None
2377
2380
} else if constness == self . tcx . consts . false_ {
2378
- ty:: BoundConstness :: Const
2381
+ Some ( ty:: BoundConstness :: Const )
2379
2382
} else if matches ! ( constness. kind( ) , ty:: ConstKind :: Param ( _) ) {
2380
- ty:: BoundConstness :: ConstIfConst
2383
+ Some ( ty:: BoundConstness :: ConstIfConst )
2381
2384
} else {
2382
2385
self . dcx ( ) . span_bug ( span, format ! ( "Unknown constness argument: {constness:?}" ) ) ;
2383
2386
} ;
0 commit comments