@@ -339,27 +339,30 @@ impl<'tcx> Instance<'tcx> {
339
339
def_id : DefId ,
340
340
substs : SubstsRef < ' tcx > ,
341
341
) -> Result < Option < Instance < ' tcx > > , ErrorReported > {
342
- // All regions in the result of this query are erased, so it's
343
- // fine to erase all of the input regions.
344
-
345
- // HACK(eddyb) erase regions in `substs` first, so that `param_env.and(...)`
346
- // below is more likely to ignore the bounds in scope (e.g. if the only
347
- // generic parameters mentioned by `substs` were lifetime ones).
348
- let substs = tcx. erase_regions ( & substs) ;
349
-
350
- // FIXME(eddyb) should this always use `param_env.with_reveal_all()`?
351
- tcx. resolve_instance ( tcx. erase_regions ( & param_env. and ( ( def_id, substs) ) ) )
342
+ Instance :: resolve_opt_const_arg (
343
+ tcx,
344
+ param_env,
345
+ ty:: WithOptConstParam :: unknown ( def_id) ,
346
+ substs,
347
+ )
352
348
}
353
349
354
350
// This should be kept up to date with `resolve`.
355
- pub fn resolve_const_arg (
351
+ pub fn resolve_opt_const_arg (
356
352
tcx : TyCtxt < ' tcx > ,
357
353
param_env : ty:: ParamEnv < ' tcx > ,
358
354
def : ty:: WithOptConstParam < DefId > ,
359
355
substs : SubstsRef < ' tcx > ,
360
356
) -> Result < Option < Instance < ' tcx > > , ErrorReported > {
357
+ // All regions in the result of this query are erased, so it's
358
+ // fine to erase all of the input regions.
359
+
360
+ // HACK(eddyb) erase regions in `substs` first, so that `param_env.and(...)`
361
+ // below is more likely to ignore the bounds in scope (e.g. if the only
362
+ // generic parameters mentioned by `substs` were lifetime ones).
361
363
let substs = tcx. erase_regions ( & substs) ;
362
364
365
+ // FIXME(eddyb) should this always use `param_env.with_reveal_all()`?
363
366
if let Some ( ( did, param_did) ) = def. as_const_arg ( ) {
364
367
tcx. resolve_instance_of_const_arg (
365
368
tcx. erase_regions ( & param_env. and ( ( did, param_did, substs) ) ) ,
0 commit comments