Skip to content

Commit bf87f3e

Browse files
committed
test: is try_eval_bits fast enough actually?
1 parent 2471179 commit bf87f3e

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

+21-20
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,27 @@ fn fast_try_eval_bits<'tcx>(
9393
param_env: ty::ParamEnv<'tcx>,
9494
value: &mir::Const<'tcx>,
9595
) -> Option<u128> {
96-
let int = match value {
97-
// If the constant is already evaluated, we shortcut here.
98-
mir::Const::Ty(c) if let ty::ConstKind::Value(valtree) = c.kind() => {
99-
valtree.unwrap_leaf()
100-
},
101-
// This is a more general form of the previous case.
102-
_ => {
103-
value.try_eval_scalar_int(tcx, param_env)?
104-
},
105-
};
106-
let size = match value.ty().kind() {
107-
ty::Bool => Size::from_bytes(1),
108-
ty::Char => Size::from_bytes(4),
109-
ty::Int(ity) => Integer::from_int_ty(&tcx, *ity).size(),
110-
ty::Uint(uty) => Integer::from_uint_ty(&tcx, *uty).size(),
111-
ty::Float(ty::FloatTy::F32) => Primitive::F32.size(&tcx),
112-
ty::Float(ty::FloatTy::F64) => Primitive::F64.size(&tcx),
113-
_ => return None,
114-
};
115-
int.to_bits(size).ok()
96+
value.try_eval_bits(tcx, param_env)
97+
// let int = match value {
98+
// // If the constant is already evaluated, we shortcut here.
99+
// mir::Const::Ty(c) if let ty::ConstKind::Value(valtree) = c.kind() => {
100+
// valtree.unwrap_leaf()
101+
// },
102+
// // This is a more general form of the previous case.
103+
// _ => {
104+
// value.try_eval_scalar_int(tcx, param_env)?
105+
// },
106+
// };
107+
// let size = match value.ty().kind() {
108+
// ty::Bool => Size::from_bytes(1),
109+
// ty::Char => Size::from_bytes(4),
110+
// ty::Int(ity) => Integer::from_int_ty(&tcx, *ity).size(),
111+
// ty::Uint(uty) => Integer::from_uint_ty(&tcx, *uty).size(),
112+
// ty::Float(ty::FloatTy::F32) => Primitive::F32.size(&tcx),
113+
// ty::Float(ty::FloatTy::F64) => Primitive::F64.size(&tcx),
114+
// _ => return None,
115+
// };
116+
// int.to_bits(size).ok()
116117
}
117118

118119
/// An inclusive interval, used for precise integer exhaustiveness checking.

0 commit comments

Comments
 (0)