@@ -52,7 +52,7 @@ pub fn is_const_evaluatable<'tcx>(
5252 } ;
5353
5454 if !is_anon_ct {
55- if satisfied_from_param_env ( tcx, infcx, ct, param_env) ? {
55+ if satisfied_from_param_env ( tcx, infcx, ct, param_env) {
5656 return Ok ( ( ) ) ;
5757 }
5858 if ct. has_non_region_infer ( ) {
@@ -87,8 +87,14 @@ pub fn is_const_evaluatable<'tcx>(
8787 // If we're evaluating a generic foreign constant, under a nightly compiler while
8888 // the current crate does not enable `feature(generic_const_exprs)`, abort
8989 // compilation with a useful error.
90- Err ( _) if tcx. sess . is_nightly_build ( )
91- && let ty:: ConstKind :: Expr ( _) = tcx. expand_abstract_consts ( ct) . kind ( ) =>
90+ Err ( _)
91+ if tcx. sess . is_nightly_build ( )
92+ && satisfied_from_param_env (
93+ tcx,
94+ infcx,
95+ tcx. expand_abstract_consts ( ct) ,
96+ param_env,
97+ ) =>
9298 {
9399 tcx. sess
94100 . struct_span_fatal (
@@ -112,12 +118,15 @@ pub fn is_const_evaluatable<'tcx>(
112118 } else if uv. has_non_region_param ( ) {
113119 NotConstEvaluatable :: MentionsParam
114120 } else {
115- let guar = infcx. tcx . sess . delay_span_bug ( span, format ! ( "Missing value for constant, but no error reported?" ) ) ;
121+ let guar = infcx. tcx . sess . delay_span_bug (
122+ span,
123+ format ! ( "Missing value for constant, but no error reported?" ) ,
124+ ) ;
116125 NotConstEvaluatable :: Error ( guar)
117126 } ;
118127
119128 Err ( err)
120- } ,
129+ }
121130 Err ( ErrorHandled :: Reported ( e) ) => Err ( NotConstEvaluatable :: Error ( e) ) ,
122131 Ok ( _) => Ok ( ( ) ) ,
123132 }
@@ -130,7 +139,7 @@ fn satisfied_from_param_env<'tcx>(
130139 infcx : & InferCtxt < ' tcx > ,
131140 ct : ty:: Const < ' tcx > ,
132141 param_env : ty:: ParamEnv < ' tcx > ,
133- ) -> Result < bool , NotConstEvaluatable > {
142+ ) -> bool {
134143 // Try to unify with each subtree in the AbstractConst to allow for
135144 // `N + 1` being const evaluatable even if theres only a `ConstEvaluatable`
136145 // predicate for `(N + 1) * 2`
@@ -179,12 +188,12 @@ fn satisfied_from_param_env<'tcx>(
179188
180189 if let ControlFlow :: Break ( ( ) ) = result {
181190 debug ! ( "is_const_evaluatable: abstract_const ~~> ok" ) ;
182- return Ok ( true ) ;
191+ return true ;
183192 }
184193 }
185194 _ => { } // don't care
186195 }
187196 }
188197
189- Ok ( false )
198+ false
190199}
0 commit comments