1
Fork 0

rebase and use ty::Const in patterns again

This commit is contained in:
b-naber 2022-03-25 10:06:10 +01:00
parent ac60db231c
commit 0078e54185
13 changed files with 73 additions and 144 deletions

View file

@ -2711,7 +2711,7 @@ impl<'tcx> ConstantKind<'tcx> {
if let Some(val) = c.val().try_eval(tcx, param_env) {
match val {
Ok(val) => Self::Val(val, c.ty()),
Err(ErrorReported) => Self::Ty(tcx.const_error(self.ty())),
Err(_) => Self::Ty(tcx.const_error(self.ty())),
}
} else {
self

View file

@ -193,7 +193,7 @@ pub enum StmtKind<'tcx> {
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Expr<'_>, 144);
rustc_data_structures::static_assert_size!(Expr<'_>, 104);
/// A THIR expression.
#[derive(Debug, HashStable)]
@ -736,11 +736,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
Some(adt_def.variant(variant_index))
}
_ => self.ty.ty_adt_def().and_then(|adt| {
if !adt.is_enum() {
Some(adt.non_enum_variant())
} else {
None
}
if !adt.is_enum() { Some(adt.non_enum_variant()) } else { None }
}),
};

View file

@ -2,7 +2,6 @@ use super::{
Arm, Block, Expr, ExprKind, Guard, InlineAsmOperand, Pat, PatKind, Stmt, StmtKind, Thir,
};
use crate::mir::ConstantKind;
use crate::ty::Const;
pub trait Visitor<'a, 'tcx: 'a>: Sized {
fn thir(&self) -> &'a Thir<'tcx>;

View file

@ -76,11 +76,7 @@ static_assert_size!(ConstKind<'_>, 40);
impl<'tcx> ConstKind<'tcx> {
#[inline]
pub fn try_to_value(self) -> Option<ConstValue<'tcx>> {
if let ConstKind::Value(val) = self {
Some(val)
} else {
None
}
if let ConstKind::Value(val) = self { Some(val) } else { None }
}
#[inline]