Skip to content

Commit

Permalink
Address nits
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jun 1, 2024
1 parent f14b965 commit 208c316
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,16 +1269,16 @@ impl<'tcx> InferCtxt<'tcx> {

ty::IntVar(v) => {
match self.inner.borrow_mut().int_unification_table().probe_value(v) {
ty::IntVarValue::Unknown => ty,
ty::IntVarValue::IntType(ty) => Ty::new_int(self.tcx, ty),
ty::IntVarValue::UintType(ty) => Ty::new_uint(self.tcx, ty),
ty::IntVarValue::Unknown => ty,
}
}

ty::FloatVar(v) => {
match self.inner.borrow_mut().float_unification_table().probe_value(v) {
ty::FloatVarValue::Unknown => ty,
ty::FloatVarValue::Known(ty) => Ty::new_float(self.tcx, ty),
ty::FloatVarValue::Unknown => ty,
}
}

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

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

TyOrConstInferVar::Const(v) => {
Expand Down
22 changes: 18 additions & 4 deletions compiler/rustc_type_ir/src/ty_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,15 @@ pub enum IntVarValue {
}

impl IntVarValue {
pub fn is_unknown(&self) -> bool {
matches!(self, IntVarValue::Unknown)
pub fn is_known(self) -> bool {
match self {
IntVarValue::IntType(_) | IntVarValue::UintType(_) => true,
IntVarValue::Unknown => false,
}
}

pub fn is_unknown(self) -> bool {
!self.is_known()
}
}

Expand All @@ -735,8 +742,15 @@ pub enum FloatVarValue {
}

impl FloatVarValue {
pub fn is_unknown(&self) -> bool {
matches!(self, FloatVarValue::Unknown)
pub fn is_known(self) -> bool {
match self {
FloatVarValue::Known(_) => true,
FloatVarValue::Unknown => false,
}
}

pub fn is_unknown(self) -> bool {
!self.is_known()
}
}

Expand Down

0 comments on commit 208c316

Please sign in to comment.