Rollup merge of #103984 - V0ldek:103974-refactor-mk_const, r=BoxyUwU

Refactor tcx mk_const parameters.

Unroll the `ty::ConstS` parameter to `TyCtxt::mk_const` into separate `ty::ConstKind` and `Ty` parameters.

Signature change is in:

c97fd8183a/compiler/rustc_middle/src/ty/context.rs (L2234)

and

c97fd8183a/compiler/rustc_middle/src/ty/context.rs (L2572-L2575)

the rest is callsites.

Closes #103974

r? `@oli-obk`
This commit is contained in:
Matthias Krüger 2022-11-05 00:02:06 +01:00 committed by GitHub
commit b101f3a865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 74 additions and 104 deletions

View file

@ -831,9 +831,7 @@ impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
let universe = self.universe_for(debruijn);
let p = ty::PlaceholderConst { universe, name: bound_const };
self.mapped_consts.insert(p, bound_const);
self.infcx
.tcx
.mk_const(ty::ConstS { kind: ty::ConstKind::Placeholder(p), ty: ct.ty() })
self.infcx.tcx.mk_const(ty::ConstKind::Placeholder(p), ct.ty())
}
_ => ct.super_fold_with(self),
}
@ -968,10 +966,7 @@ impl<'tcx> TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> {
let db = ty::DebruijnIndex::from_usize(
self.universe_indices.len() - index + self.current_index.as_usize() - 1,
);
self.tcx().mk_const(ty::ConstS {
kind: ty::ConstKind::Bound(db, *replace_var),
ty: ct.ty(),
})
self.tcx().mk_const(ty::ConstKind::Bound(db, *replace_var), ct.ty())
}
None => ct,
}
@ -2173,7 +2168,7 @@ fn confirm_impl_candidate<'cx, 'tcx>(
crate::traits::InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
let did = ty::WithOptConstParam::unknown(assoc_ty.item.def_id);
let kind = ty::ConstKind::Unevaluated(ty::UnevaluatedConst::new(did, identity_substs));
ty.map_bound(|ty| tcx.mk_const(ty::ConstS { ty, kind }).into())
ty.map_bound(|ty| tcx.mk_const(kind, ty).into())
} else {
ty.map_bound(|ty| ty.into())
};

View file

@ -555,13 +555,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
GenericParamDefKind::Const { .. } => {
let bound_var = ty::BoundVariableKind::Const;
bound_vars.push(bound_var);
tcx.mk_const(ty::ConstS {
ty: tcx.type_of(param.def_id),
kind: ty::ConstKind::Bound(
tcx.mk_const(
ty::ConstKind::Bound(
ty::INNERMOST,
ty::BoundVar::from_usize(bound_vars.len() - 1),
),
})
tcx.type_of(param.def_id),
)
.into()
}
});