Skip to content

Commit 7be8693

Browse files
committed
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: <#92805 (comment)> r? `@lcnr`
2 parents 42852d7 + 3f3a10f commit 7be8693

File tree

123 files changed

+405
-886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+405
-886
lines changed

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
171171
for (local, location) in drop_used {
172172
if !live_locals.contains(&local) {
173173
let local_ty = self.cx.body.local_decls[local].ty;
174-
if local_ty.has_free_regions(self.cx.typeck.tcx()) {
174+
if local_ty.has_free_regions() {
175175
self.cx.add_drop_live_facts_for(local, local_ty, &[location], &locations);
176176
}
177177
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
426426
self.cx.param_env.and(type_op::ascribe_user_type::AscribeUserType::new(
427427
constant.literal.ty(),
428428
uv.def.did,
429-
UserSubsts { substs: uv.substs(self.tcx()), user_self_ty: None },
429+
UserSubsts { substs: uv.substs, user_self_ty: None },
430430
)),
431431
) {
432432
span_mirbug!(
@@ -1970,7 +1970,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19701970
let predicates = self.prove_closure_bounds(
19711971
tcx,
19721972
def_id.expect_local(),
1973-
uv.substs(tcx),
1973+
uv.substs,
19741974
location,
19751975
);
19761976
self.normalize_and_prove_instantiated_predicates(

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ pub(crate) fn codegen_constant<'tcx>(
129129
};
130130
let const_val = match const_.val {
131131
ConstKind::Value(const_val) => const_val,
132-
ConstKind::Unevaluated(uv) if fx.tcx.is_static(uv.def.did) => {
133-
assert!(uv.substs(fx.tcx).is_empty());
134-
assert!(uv.promoted.is_none());
132+
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
133+
if fx.tcx.is_static(def.did) =>
134+
{
135+
assert!(substs.is_empty());
136+
assert!(promoted.is_none());
135137

136-
return codegen_static_ref(fx, uv.def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
138+
return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
137139
}
138140
ConstKind::Unevaluated(unevaluated) => {
139141
match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
507507
ty::Adt(def, ..) if !def.is_box() => {
508508
// Again, only create type information if full debuginfo is enabled
509509
if cx.sess().opts.debuginfo == DebugInfo::Full
510-
&& !impl_self_ty.definitely_needs_subst(cx.tcx)
510+
&& !impl_self_ty.needs_subst()
511511
{
512512
Some(type_metadata(cx, impl_self_ty, rustc_span::DUMMY_SP))
513513
} else {

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14771477
LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"),
14781478
LocalRef::Operand(None) => {
14791479
let dst_layout = bx.layout_of(self.monomorphized_place_ty(dst.as_ref()));
1480-
assert!(!dst_layout.ty.has_erasable_regions(self.cx.tcx()));
1480+
assert!(!dst_layout.ty.has_erasable_regions());
14811481
let place = PlaceRef::alloca(bx, dst_layout);
14821482
place.storage_live(bx);
14831483
self.codegen_transmute_into(bx, src, place);

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
209209
let mut allocate_local = |local| {
210210
let decl = &mir.local_decls[local];
211211
let layout = bx.layout_of(fx.monomorphize(decl.ty));
212-
assert!(!layout.ty.has_erasable_regions(cx.tcx()));
212+
assert!(!layout.ty.has_erasable_regions());
213213

214214
if local == mir::RETURN_PLACE && fx.fn_abi.ret.is_indirect() {
215215
debug!("alloc: {:?} (return place) -> place", local);

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
568568
ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) => throw_inval!(TooGeneric),
569569
ty::ConstKind::Error(_) => throw_inval!(AlreadyReported(ErrorReported)),
570570
ty::ConstKind::Unevaluated(uv) => {
571-
let instance = self.resolve(uv.def, uv.substs(*self.tcx))?;
571+
let instance = self.resolve(uv.def, uv.substs)?;
572572
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())
573573
}
574574
ty::ConstKind::Infer(..) | ty::ConstKind::Placeholder(..) => {

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ where
99
T: TypeFoldable<'tcx>,
1010
{
1111
debug!("ensure_monomorphic_enough: ty={:?}", ty);
12-
if !ty.potentially_needs_subst() {
12+
if !ty.needs_subst() {
1313
return Ok(());
1414
}
1515

@@ -21,12 +21,8 @@ where
2121
impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> {
2222
type BreakTy = FoundParam;
2323

24-
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
25-
Some(self.tcx)
26-
}
27-
2824
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
29-
if !ty.potentially_needs_subst() {
25+
if !ty.needs_subst() {
3026
return ControlFlow::CONTINUE;
3127
}
3228

@@ -44,7 +40,7 @@ where
4440
let is_used = unused_params.contains(index).map_or(true, |unused| !unused);
4541
// Only recurse when generic parameters in fns, closures and generators
4642
// are used and require substitution.
47-
match (is_used, subst.definitely_needs_subst(self.tcx)) {
43+
match (is_used, subst.needs_subst()) {
4844
// Just in case there are closures or generators within this subst,
4945
// recurse.
5046
(true, true) => return subst.super_visit_with(self),

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
347347
fn check_local_or_return_ty(&mut self, ty: Ty<'tcx>, local: Local) {
348348
let kind = self.body.local_kind(local);
349349

350-
for ty in ty.walk(self.tcx) {
350+
for ty in ty.walk() {
351351
let ty = match ty.unpack() {
352352
GenericArgKind::Type(ty) => ty,
353353

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ where
337337

338338
// Check the qualifs of the value of `const` items.
339339
if let Some(ct) = constant.literal.const_for_ty() {
340-
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs_: _, promoted }) = ct.val {
340+
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) = ct.val {
341341
// Use qualifs of the type for the promoted. Promoteds in MIR body should be possible
342342
// only for `NeedsNonConstDrop` with precise drop checking. This is the only const
343343
// check performed after the promotion. Verify that with an assertion.

0 commit comments

Comments
 (0)