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:
parent
7087d9b2a0
commit
26b87bf8ff
10 changed files with 27 additions and 46 deletions
|
@ -147,7 +147,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }, ty) => {
|
||||
let universe_mapped = universe_map(universe);
|
||||
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, name };
|
||||
self.tcx.mk_const(ty::ConstKind::Placeholder(placeholder_mapped), ty).into()
|
||||
self.tcx.mk_const(placeholder_mapped, ty).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -765,10 +765,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
|||
substs,
|
||||
substs,
|
||||
)?;
|
||||
Ok(self.tcx().mk_const(
|
||||
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
|
||||
c.ty(),
|
||||
))
|
||||
Ok(self.tcx().mk_const(ty::UnevaluatedConst { def, substs }, c.ty()))
|
||||
}
|
||||
_ => relate::super_relate_consts(self, c, c),
|
||||
}
|
||||
|
@ -988,10 +985,7 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
|
|||
substs,
|
||||
)?;
|
||||
|
||||
Ok(self.tcx().mk_const(
|
||||
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
|
||||
c.ty(),
|
||||
))
|
||||
Ok(self.tcx().mk_const(ty::UnevaluatedConst { def, substs }, c.ty()))
|
||||
}
|
||||
_ => relate::super_relate_consts(self, c, c),
|
||||
}
|
||||
|
|
|
@ -94,13 +94,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}))
|
||||
},
|
||||
consts: &mut |bound_var: ty::BoundVar, ty| {
|
||||
self.tcx.mk_const(
|
||||
ty::ConstKind::Placeholder(ty::PlaceholderConst {
|
||||
universe: next_universe,
|
||||
name: bound_var,
|
||||
}),
|
||||
ty,
|
||||
)
|
||||
self.tcx
|
||||
.mk_const(ty::PlaceholderConst { universe: next_universe, name: bound_var }, ty)
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -2049,10 +2049,10 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
|
|||
bug!("const `{ct}`'s type should not reference params or types");
|
||||
}
|
||||
tcx.mk_const(
|
||||
ty::ConstKind::Placeholder(ty::PlaceholderConst {
|
||||
ty::PlaceholderConst {
|
||||
universe: ty::UniverseIndex::ROOT,
|
||||
name: ty::BoundVar::from_usize(idx),
|
||||
}),
|
||||
},
|
||||
ty,
|
||||
)
|
||||
.into()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue