@@ -1418,12 +1418,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1418
1418
substs : SubstsRef < ' tcx > ,
1419
1419
code : impl Fn ( usize , Span ) -> ObligationCauseCode < ' tcx > ,
1420
1420
) {
1421
- let mut param_env = self . param_env ;
1422
- match self . tcx . def_kind ( def_id) {
1421
+ let param_env = self . param_env ;
1422
+
1423
+ let remap = match self . tcx . def_kind ( def_id) {
1423
1424
// Associated consts have `Self: ~const Trait` bounds that should be satisfiable when
1424
1425
// `Self: Trait` is satisfied because it does not matter whether the impl is `const`.
1425
1426
// Therefore we have to remap the param env here to be non-const.
1426
- hir:: def:: DefKind :: AssocConst => param_env = param_env . without_const ( ) ,
1427
+ hir:: def:: DefKind :: AssocConst => true ,
1427
1428
hir:: def:: DefKind :: AssocFn
1428
1429
if self . tcx . def_kind ( self . tcx . parent ( def_id) ) == hir:: def:: DefKind :: Trait =>
1429
1430
{
@@ -1437,19 +1438,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1437
1438
//
1438
1439
// FIXME(fee1-dead) FIXME(const_trait_impl): update this doc when trait methods can satisfy
1439
1440
// `~const FnOnce` or can be coerced to `const fn` pointer.
1440
- param_env = param_env . without_const ( ) ;
1441
+ true
1441
1442
}
1442
- _ => { }
1443
- }
1443
+ _ => false ,
1444
+ } ;
1444
1445
let ( bounds, _) = self . instantiate_bounds ( span, def_id, & substs) ;
1445
1446
1446
- for obligation in traits:: predicates_for_generics (
1447
+ for mut obligation in traits:: predicates_for_generics (
1447
1448
|idx, predicate_span| {
1448
1449
traits:: ObligationCause :: new ( span, self . body_id , code ( idx, predicate_span) )
1449
1450
} ,
1450
1451
param_env,
1451
1452
bounds,
1452
1453
) {
1454
+ if remap {
1455
+ obligation = obligation. without_const ( self . tcx ) ;
1456
+ }
1453
1457
self . register_predicate ( obligation) ;
1454
1458
}
1455
1459
}
0 commit comments