Skip to content

Commit f1c797f

Browse files
compiler-errorslcnr
authored andcommitted
Address nits
1 parent 6515202 commit f1c797f

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,16 +1271,16 @@ impl<'tcx> InferCtxt<'tcx> {
12711271

12721272
ty::IntVar(v) => {
12731273
match self.inner.borrow_mut().int_unification_table().probe_value(v) {
1274-
ty::IntVarValue::Unknown => ty,
12751274
ty::IntVarValue::IntType(ty) => Ty::new_int(self.tcx, ty),
12761275
ty::IntVarValue::UintType(ty) => Ty::new_uint(self.tcx, ty),
1276+
ty::IntVarValue::Unknown => ty,
12771277
}
12781278
}
12791279

12801280
ty::FloatVar(v) => {
12811281
match self.inner.borrow_mut().float_unification_table().probe_value(v) {
1282-
ty::FloatVarValue::Unknown => ty,
12831282
ty::FloatVarValue::Known(ty) => Ty::new_float(self.tcx, ty),
1283+
ty::FloatVarValue::Unknown => ty,
12841284
}
12851285
}
12861286

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

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

16601660
TyOrConstInferVar::Const(v) => {

compiler/rustc_type_ir/src/ty_kind.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,15 @@ pub enum IntVarValue {
725725
}
726726

727727
impl IntVarValue {
728-
pub fn is_unknown(&self) -> bool {
729-
matches!(self, IntVarValue::Unknown)
728+
pub fn is_known(self) -> bool {
729+
match self {
730+
IntVarValue::IntType(_) | IntVarValue::UintType(_) => true,
731+
IntVarValue::Unknown => false,
732+
}
733+
}
734+
735+
pub fn is_unknown(self) -> bool {
736+
!self.is_known()
730737
}
731738
}
732739

@@ -737,8 +744,15 @@ pub enum FloatVarValue {
737744
}
738745

739746
impl FloatVarValue {
740-
pub fn is_unknown(&self) -> bool {
741-
matches!(self, FloatVarValue::Unknown)
747+
pub fn is_known(self) -> bool {
748+
match self {
749+
FloatVarValue::Known(_) => true,
750+
FloatVarValue::Unknown => false,
751+
}
752+
}
753+
754+
pub fn is_unknown(self) -> bool {
755+
!self.is_known()
742756
}
743757
}
744758

0 commit comments

Comments
 (0)