@@ -167,12 +167,12 @@ fn validate_and_turn_into_const<'tcx>(
167
167
constant : RawConst < ' tcx > ,
168
168
key : ConstEvalInput < ' tcx > ,
169
169
) -> :: 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) ;
171
172
tcx. infer_ctxt ( ) . enter_with_canonical (
172
173
span,
173
174
& key,
174
175
|ref infcx, ty:: ParamEnvAnd { param_env, value : cid } , _| {
175
- let def_id = cid. instance . def . def_id ( ) ;
176
176
let is_static = tcx. is_static ( def_id) ;
177
177
let ecx = InterpCx :: new (
178
178
tcx. at ( span) ,
@@ -227,9 +227,7 @@ pub fn const_eval_validated_provider<'tcx>(
227
227
228
228
// see comment in const_eval_raw_provider for what we're doing here
229
229
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 ( ) ) {
233
231
// try again with reveal all as requested
234
232
Err ( ErrorHandled :: TooGeneric ) => { }
235
233
// dedupliate calls
@@ -270,9 +268,7 @@ pub fn const_eval_raw_provider<'tcx>(
270
268
271
269
// In case we fail in the `UserFacing` variant, we just do the real computation.
272
270
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 ( ) ) {
276
272
// try again with reveal all as requested
277
273
Err ( ErrorHandled :: TooGeneric ) => { }
278
274
// dedupliate calls
@@ -289,15 +285,15 @@ pub fn const_eval_raw_provider<'tcx>(
289
285
trace ! ( "const eval: {:?} ({})" , key, instance) ;
290
286
}
291
287
292
- let def_id = cid . instance . def . def_id ( ) ;
288
+ let def_id = key . def_id ( ) ;
293
289
294
290
if def_id. is_local ( ) && tcx. typeck_tables_of ( def_id) . tainted_by_errors {
295
291
return Err ( ErrorHandled :: Reported ) ;
296
292
}
297
293
298
294
let is_static = tcx. is_static ( def_id) ;
299
295
300
- let span = tcx. def_span ( cid . instance . def_id ( ) ) ;
296
+ let span = tcx. def_span ( def_id) ;
301
297
tcx. infer_ctxt ( ) . enter_with_canonical (
302
298
span,
303
299
& key,
0 commit comments