]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_const_eval/src/transform/promote_consts.rs
Erase regions better in promote_candidate
[rust.git] / compiler / rustc_const_eval / src / transform / promote_consts.rs
index ed4d8c95d1e6178d882bcaef5a3c9b5bad620a39..161c89e3242b9f660336c64da476154e48a9ca24 100644 (file)
@@ -839,17 +839,12 @@ fn promote_candidate(mut self, candidate: Candidate, next_promoted_id: usize) ->
             let mut promoted_operand = |ty, span| {
                 promoted.span = span;
                 promoted.local_decls[RETURN_PLACE] = LocalDecl::new(ty, span);
+                let substs = tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def.did));
                 let _const = tcx.mk_const(ty::ConstS {
                     ty,
                     kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
                         def,
-                        substs: InternalSubsts::for_item(tcx, def.did, |param, _| {
-                            if let ty::GenericParamDefKind::Lifetime = param.kind {
-                                tcx.lifetimes.re_erased.into()
-                            } else {
-                                tcx.mk_param_from_def(param)
-                            }
-                        }),
+                        substs,
                         promoted: Some(promoted_id),
                     }),
                 });