Skip to content

Commit 208c316

Browse files
Address nits
1 parent f14b965 commit 208c316

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

compiler/rustc_infer/src/infer/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1269,16 +1269,16 @@ impl<'tcx> InferCtxt<'tcx> {
12691269

12701270
ty::IntVar(v) => {
12711271
match self.inner.borrow_mut().int_unification_table().probe_value(v) {
1272-
ty::IntVarValue::Unknown => ty,
12731272
ty::IntVarValue::IntType(ty) => Ty::new_int(self.tcx, ty),
12741273
ty::IntVarValue::UintType(ty) => Ty::new_uint(self.tcx, ty),
1274+
ty::IntVarValue::Unknown => ty,
12751275
}
12761276
}
12771277

12781278
ty::FloatVar(v) => {
12791279
match self.inner.borrow_mut().float_unification_table().probe_value(v) {
1280-
ty::FloatVarValue::Unknown => ty,
12811280
ty::FloatVarValue::Known(ty) => Ty::new_float(self.tcx, ty),
1281+
ty::FloatVarValue::Unknown => ty,
12821282
}
12831283
}
12841284

@@ -1644,15 +1644,15 @@ impl<'tcx> InferCtxt<'tcx> {
16441644
// If `inlined_probe_value` returns a value it's always a
16451645
// `ty::Int(_)` or `ty::UInt(_)`, which never matches a
16461646
// `ty::Infer(_)`.
1647-
!self.inner.borrow_mut().int_unification_table().inlined_probe_value(v).is_unknown()
1647+
self.inner.borrow_mut().int_unification_table().inlined_probe_value(v).is_known()
16481648
}
16491649

16501650
TyOrConstInferVar::TyFloat(v) => {
16511651
// If `probe_value` returns a value it's always a
16521652
// `ty::Float(_)`, which never matches a `ty::Infer(_)`.
16531653
//
16541654
// Not `inlined_probe_value(v)` because this call site is colder.
1655-
!self.inner.borrow_mut().float_unification_table().probe_value(v).is_unknown()
1655+
self.inner.borrow_mut().float_unification_table().probe_value(v).is_known()
16561656
}
16571657

16581658
TyOrConstInferVar::Const(v) => {

compiler/rustc_type_ir/src/ty_kind.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,15 @@ pub enum IntVarValue {
723723
}
724724

725725
impl IntVarValue {
726-
pub fn is_unknown(&self) -> bool {
727-
matches!(self, IntVarValue::Unknown)
726+
pub fn is_known(self) -> bool {
727+
match self {
728+
IntVarValue::IntType(_) | IntVarValue::UintType(_) => true,
729+
IntVarValue::Unknown => false,
730+
}
731+
}
732+
733+
pub fn is_unknown(self) -> bool {
734+
!self.is_known()
728735
}
729736
}
730737

@@ -735,8 +742,15 @@ pub enum FloatVarValue {
735742
}
736743

737744
impl FloatVarValue {
738-
pub fn is_unknown(&self) -> bool {
739-
matches!(self, FloatVarValue::Unknown)
745+
pub fn is_known(self) -> bool {
746+
match self {
747+
FloatVarValue::Known(_) => true,
748+
FloatVarValue::Unknown => false,
749+
}
750+
}
751+
752+
pub fn is_unknown(self) -> bool {
753+
!self.is_known()
740754
}
741755
}
742756

0 commit comments

Comments
 (0)