Simplify calls to tcx.mk_const
`mk_const(ty::ConstKind::X(...), ty)` can now be simplified to
`mk_cosnt(..., ty)`.
I searched with the following regex: \mk_const\([\n\s]*(ty::)?ConstKind\
I've left `ty::ConstKind::{Bound, Error}` as-is, they seem clearer this
way.
This commit is contained in:
@@ -2527,8 +2527,7 @@ impl<'tcx> ConstantKind<'tcx> {
|
||||
let generics = tcx.generics_of(item_def_id);
|
||||
let index = generics.param_def_id_to_index[&def_id];
|
||||
let name = tcx.item_name(def_id);
|
||||
let ty_const =
|
||||
tcx.mk_const(ty::ConstKind::Param(ty::ParamConst::new(index, name)), ty);
|
||||
let ty_const = tcx.mk_const(ty::ParamConst::new(index, name), ty);
|
||||
debug!(?ty_const);
|
||||
|
||||
return Self::Ty(ty_const);
|
||||
|
||||
@@ -76,10 +76,10 @@ impl<'tcx> Const<'tcx> {
|
||||
match Self::try_eval_lit_or_param(tcx, ty, expr) {
|
||||
Some(v) => v,
|
||||
None => tcx.mk_const(
|
||||
ty::ConstKind::Unevaluated(ty::UnevaluatedConst {
|
||||
ty::UnevaluatedConst {
|
||||
def: def.to_global(),
|
||||
substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()),
|
||||
}),
|
||||
},
|
||||
ty,
|
||||
),
|
||||
}
|
||||
@@ -134,7 +134,7 @@ impl<'tcx> Const<'tcx> {
|
||||
let generics = tcx.generics_of(item_def_id);
|
||||
let index = generics.param_def_id_to_index[&def_id];
|
||||
let name = tcx.item_name(def_id);
|
||||
Some(tcx.mk_const(ty::ConstKind::Param(ty::ParamConst::new(index, name)), ty))
|
||||
Some(tcx.mk_const(ty::ParamConst::new(index, name), ty))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
@@ -143,7 +143,7 @@ impl<'tcx> Const<'tcx> {
|
||||
/// Interns the given value as a constant.
|
||||
#[inline]
|
||||
pub fn from_value(tcx: TyCtxt<'tcx>, val: ty::ValTree<'tcx>, ty: Ty<'tcx>) -> Self {
|
||||
tcx.mk_const(ConstKind::Value(val), ty)
|
||||
tcx.mk_const(val, ty)
|
||||
}
|
||||
|
||||
/// Panics if self.kind != ty::ConstKind::Value
|
||||
|
||||
@@ -663,10 +663,7 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
|
||||
au.substs,
|
||||
bu.substs,
|
||||
)?;
|
||||
return Ok(tcx.mk_const(
|
||||
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def: au.def, substs }),
|
||||
a.ty(),
|
||||
));
|
||||
return Ok(tcx.mk_const(ty::UnevaluatedConst { def: au.def, substs }, a.ty()));
|
||||
}
|
||||
// Before calling relate on exprs, it is necessary to ensure that the nested consts
|
||||
// have identical types.
|
||||
|
||||
Reference in New Issue
Block a user