mirror of
https://github.com/openharmony/third_party_rust_rust.git
synced 2026-07-19 19:53:38 -04:00
nits
This commit is contained in:
@@ -38,6 +38,11 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
// FIXME(valtrees): This function is necessary because `fold_regions`
|
||||
// panics for mir constants in the visitor.
|
||||
//
|
||||
// Once `visit_mir_constant` is removed we can also remove this function
|
||||
// and just use `renumber_regions`.
|
||||
fn renumber_regions_in_mir_constant<'tcx>(
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
value: ConstantKind<'tcx>,
|
||||
|
||||
@@ -1816,12 +1816,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
fn check_operand(&mut self, op: &Operand<'tcx>, location: Location) {
|
||||
if let Operand::Constant(constant) = op {
|
||||
let maybe_uneval = match constant.literal {
|
||||
ConstantKind::Ty(ct) => match ct.kind() {
|
||||
ty::ConstKind::Unevaluated(uv) => Some(uv.expand()),
|
||||
_ => None,
|
||||
},
|
||||
ConstantKind::Val(..) | ConstantKind::Ty(_) => None,
|
||||
ConstantKind::Unevaluated(uv, _) => Some(uv),
|
||||
ConstantKind::Val(..) => None,
|
||||
};
|
||||
|
||||
if let Some(uv) = maybe_uneval {
|
||||
|
||||
@@ -117,17 +117,7 @@ pub(crate) fn codegen_constant<'tcx>(
|
||||
constant: &Constant<'tcx>,
|
||||
) -> CValue<'tcx> {
|
||||
let (const_val, ty) = match fx.monomorphize(constant.literal) {
|
||||
ConstantKind::Ty(const_) => match const_.kind() {
|
||||
ConstKind::Value(valtree) => {
|
||||
(fx.tcx.valtree_to_const_val((const_.ty(), valtree)), const_.ty())
|
||||
}
|
||||
ConstKind::Unevaluated(_) => bug!("expected constant to be evaluated at this stage"),
|
||||
ConstKind::Param(_)
|
||||
| ConstKind::Infer(_)
|
||||
| ConstKind::Bound(_, _)
|
||||
| ConstKind::Placeholder(_)
|
||||
| ConstKind::Error(_) => unreachable!("{:?}", const_),
|
||||
},
|
||||
ConstantKind::Ty(const_) => unreachable!("{:?}", const_),
|
||||
ConstantKind::Unevaluated(ty::Unevaluated { def, substs, promoted }, ty)
|
||||
if fx.tcx.is_static(def.did) =>
|
||||
{
|
||||
|
||||
@@ -2643,6 +2643,7 @@ impl<'tcx> Display for ConstantKind<'tcx> {
|
||||
match *self {
|
||||
ConstantKind::Ty(c) => pretty_print_const(c, fmt, true),
|
||||
ConstantKind::Val(val, ty) => pretty_print_const_value(val, ty, fmt, true),
|
||||
// FIXME(valtrees): Correctly print mir constants.
|
||||
ConstantKind::Unevaluated(..) => {
|
||||
fmt.write_str("_")?;
|
||||
Ok(())
|
||||
|
||||
@@ -307,9 +307,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
// Promoteds must lint and not error as the user didn't ask for them
|
||||
true
|
||||
}
|
||||
ConstantKind::Unevaluated(_, ty) | ConstantKind::Val(_, ty) => {
|
||||
ty.needs_subst()
|
||||
}
|
||||
ConstantKind::Unevaluated(..) | ConstantKind::Val(..) => c.needs_subst(),
|
||||
};
|
||||
if lint_only {
|
||||
// Out of backwards compatibility we cannot report hard errors in unused
|
||||
|
||||
Reference in New Issue
Block a user