Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnr
partially revertish `lazily "compute" anon const default substs` reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049> r? `@lcnr`
This commit is contained in:
@@ -347,7 +347,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
||||
fn check_local_or_return_ty(&mut self, ty: Ty<'tcx>, local: Local) {
|
||||
let kind = self.body.local_kind(local);
|
||||
|
||||
for ty in ty.walk(self.tcx) {
|
||||
for ty in ty.walk() {
|
||||
let ty = match ty.unpack() {
|
||||
GenericArgKind::Type(ty) => ty,
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ where
|
||||
|
||||
// Check the qualifs of the value of `const` items.
|
||||
if let Some(ct) = constant.literal.const_for_ty() {
|
||||
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs_: _, promoted }) = ct.val {
|
||||
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) = ct.val {
|
||||
// Use qualifs of the type for the promoted. Promoteds in MIR body should be possible
|
||||
// only for `NeedsNonConstDrop` with precise drop checking. This is the only const
|
||||
// check performed after the promotion. Verify that with an assertion.
|
||||
|
||||
@@ -843,17 +843,13 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||
ty,
|
||||
val: ty::ConstKind::Unevaluated(ty::Unevaluated {
|
||||
def,
|
||||
substs_: Some(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: 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)
|
||||
}
|
||||
}),
|
||||
promoted: Some(promoted_id),
|
||||
}),
|
||||
})
|
||||
@@ -969,7 +965,6 @@ pub fn promote_candidates<'tcx>(
|
||||
scope.parent_scope = None;
|
||||
|
||||
let promoted = Body::new(
|
||||
tcx,
|
||||
body.source, // `promoted` gets filled in below
|
||||
IndexVec::new(),
|
||||
IndexVec::from_elem_n(scope, 1),
|
||||
|
||||
Reference in New Issue
Block a user