@@ -3311,8 +3311,31 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33113311 }
33123312
33133313 pub fn to_const ( & self , ast_c : & hir:: AnonConst ) -> & ' tcx ty:: Const < ' tcx > {
3314- let c = self . tcx . hir ( ) . local_def_id ( ast_c. hir_id ) . expect_local ( ) ;
3315- ty:: Const :: from_anon_const ( self . tcx , c)
3314+ let const_def_id = self . tcx . hir ( ) . local_def_id ( ast_c. hir_id ) . expect_local ( ) ;
3315+ let c = ty:: Const :: from_anon_const ( self . tcx , const_def_id) ;
3316+
3317+ // HACK(eddyb) emulate what a `WellFormedConst` obligation would do.
3318+ // This code should be replaced with the proper WF handling ASAP.
3319+ if let ty:: ConstKind :: Unevaluated ( def_id, substs, promoted) = c. val {
3320+ assert ! ( promoted. is_none( ) ) ;
3321+
3322+ // HACK(eddyb) let's hope these are always empty.
3323+ // let obligations = self.nominal_obligations(def_id, substs);
3324+ // self.out.extend(obligations);
3325+
3326+ let cause = traits:: ObligationCause :: new (
3327+ self . tcx . def_span ( const_def_id. to_def_id ( ) ) ,
3328+ self . body_id ,
3329+ traits:: MiscObligation ,
3330+ ) ;
3331+ self . register_predicate ( traits:: Obligation :: new (
3332+ cause,
3333+ self . param_env ,
3334+ ty:: Predicate :: ConstEvaluatable ( def_id, substs) ,
3335+ ) ) ;
3336+ }
3337+
3338+ c
33163339 }
33173340
33183341 // If the type given by the user has free regions, save it for later, since
0 commit comments