@@ -424,31 +424,19 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
424
424
}
425
425
426
426
if let ty:: FnDef ( def_id, substs) = * constant. literal . ty ( ) . kind ( ) {
427
- // N.B.: When instantiating a trait method as a function item, it does not actually matter
428
- // whether the trait is `const` or not, or whether `where T: ~const Tr` needs to be satisfied
429
- // as `const`. If we were to introduce instantiating trait methods as `const fn`s, we would
430
- // check that after this, either via a bound `where F: ~const FnOnce` or when coercing to a
431
- // `const fn` pointer.
432
- //
433
- // FIXME(fee1-dead) FIXME(const_trait_impl): update this doc when trait methods can satisfy
434
- // `~const FnOnce` or can be coerced to `const fn` pointer.
435
- let const_norm = self . tcx ( ) . def_kind ( def_id) == hir:: def:: DefKind :: AssocFn
436
- && self . tcx ( ) . def_kind ( ty:: DefIdTree :: parent ( self . tcx ( ) , def_id) )
437
- == hir:: def:: DefKind :: Trait ;
438
-
427
+ // const_trait_impl: use a non-const param env when checking that a FnDef type is well formed.
428
+ // this is because the well-formedness of the function does not need to be proved to have `const`
429
+ // impls for trait bounds.
439
430
let instantiated_predicates = tcx. predicates_of ( def_id) . instantiate ( tcx, substs) ;
440
431
let prev = self . cx . param_env ;
441
- if const_norm {
442
- self . cx . param_env = prev. without_const ( ) ;
443
- }
432
+ self . cx . param_env = prev. without_const ( ) ;
444
433
self . cx . normalize_and_prove_instantiated_predicates (
445
434
def_id,
446
435
instantiated_predicates,
447
436
locations,
448
437
) ;
449
- if const_norm {
450
- self . cx . param_env = prev;
451
- }
438
+ self . cx . param_env = prev;
439
+
452
440
}
453
441
}
454
442
}
0 commit comments