@@ -167,12 +167,12 @@ fn validate_and_turn_into_const<'tcx>(
167167 constant : RawConst < ' tcx > ,
168168 key : ConstEvalInput < ' tcx > ,
169169) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
170- let span = tcx. def_span ( key. value . value . instance . def_id ( ) ) ;
170+ let def_id = key. def_id ( ) ;
171+ let span = tcx. def_span ( def_id) ;
171172 tcx. infer_ctxt ( ) . enter_with_canonical (
172173 span,
173174 & key,
174175 |ref infcx, ty:: ParamEnvAnd { param_env, value : cid } , _| {
175- let def_id = cid. instance . def . def_id ( ) ;
176176 let is_static = tcx. is_static ( def_id) ;
177177 let ecx = InterpCx :: new (
178178 tcx. at ( span) ,
@@ -227,9 +227,7 @@ pub fn const_eval_validated_provider<'tcx>(
227227
228228 // see comment in const_eval_raw_provider for what we're doing here
229229 if param_env. reveal == Reveal :: All {
230- let mut key = key. clone ( ) ;
231- key. value . param_env . reveal = Reveal :: UserFacing ;
232- match tcx. const_eval_validated ( key) {
230+ match tcx. const_eval_validated ( key. with_reveal_user_facing ( ) ) {
233231 // try again with reveal all as requested
234232 Err ( ErrorHandled :: TooGeneric ) => { }
235233 // dedupliate calls
@@ -270,9 +268,7 @@ pub fn const_eval_raw_provider<'tcx>(
270268
271269 // In case we fail in the `UserFacing` variant, we just do the real computation.
272270 if param_env. reveal == Reveal :: All {
273- let mut key = key. clone ( ) ;
274- key. value . param_env . reveal = Reveal :: UserFacing ;
275- match tcx. const_eval_raw ( key) {
271+ match tcx. const_eval_raw ( key. with_reveal_user_facing ( ) ) {
276272 // try again with reveal all as requested
277273 Err ( ErrorHandled :: TooGeneric ) => { }
278274 // dedupliate calls
@@ -289,15 +285,15 @@ pub fn const_eval_raw_provider<'tcx>(
289285 trace ! ( "const eval: {:?} ({})" , key, instance) ;
290286 }
291287
292- let def_id = cid . instance . def . def_id ( ) ;
288+ let def_id = key . def_id ( ) ;
293289
294290 if def_id. is_local ( ) && tcx. typeck_tables_of ( def_id) . tainted_by_errors {
295291 return Err ( ErrorHandled :: Reported ) ;
296292 }
297293
298294 let is_static = tcx. is_static ( def_id) ;
299295
300- let span = tcx. def_span ( cid . instance . def_id ( ) ) ;
296+ let span = tcx. def_span ( def_id) ;
301297 tcx. infer_ctxt ( ) . enter_with_canonical (
302298 span,
303299 & key,
0 commit comments