review, small cleanup
This commit is contained in:
parent
1b275d08ad
commit
09e6254496
@ -30,7 +30,8 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
||||
span: Span,
|
||||
) -> Result<(), ErrorHandled> {
|
||||
debug!("is_const_evaluatable({:?}, {:?})", def, substs);
|
||||
if infcx.tcx.features().const_evaluatable_checked {
|
||||
// `AbstractConst::new` already returns `None` if `const_evaluatable_checked`
|
||||
// is not active, so we don't have to explicitly check for this here.
|
||||
if let Some(ct) = AbstractConst::new(infcx.tcx, def, substs) {
|
||||
for pred in param_env.caller_bounds() {
|
||||
match pred.skip_binders() {
|
||||
@ -50,7 +51,6 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let future_compat_lint = || {
|
||||
if let Some(local_def_id) = def.did.as_local() {
|
||||
@ -394,14 +394,17 @@ pub(super) fn try_unify<'tcx>(
|
||||
let a_ct = a_ct.subst(tcx, a.substs);
|
||||
let b_ct = b_ct.subst(tcx, b.substs);
|
||||
match (a_ct.val, b_ct.val) {
|
||||
// We can just unify errors with everything to reduce the amount of
|
||||
// emitted errors here.
|
||||
(ty::ConstKind::Error(_), _) | (_, ty::ConstKind::Error(_)) => true,
|
||||
(ty::ConstKind::Param(a_param), ty::ConstKind::Param(b_param)) => {
|
||||
a_param == b_param
|
||||
}
|
||||
(ty::ConstKind::Value(a_val), ty::ConstKind::Value(b_val)) => a_val == b_val,
|
||||
// If we have `fn a<const N: usize>() -> [u8; N + 1]` and `fn b<const M: usize>() -> [u8; 1 + M]`
|
||||
// we do not want to use `assert_eq!(a(), b())` to infer that `N` and `M` have to be `1`. This
|
||||
// means that we can't do anything with inference variables here.
|
||||
(ty::ConstKind::Infer(_), _) | (_, ty::ConstKind::Infer(_)) => false,
|
||||
// means that we only allow inference variables if they are equal.
|
||||
(ty::ConstKind::Infer(a_val), ty::ConstKind::Infer(b_val)) => a_val == b_val,
|
||||
// FIXME(const_evaluatable_checked): We may want to either actually try
|
||||
// to evaluate `a_ct` and `b_ct` if they are are fully concrete or something like
|
||||
// this, for now we just return false here.
|
||||
|
Loading…
Reference in New Issue
Block a user