about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-08-14 09:36:42 +0200
committerRalf Jung <post@ralfj.de>2025-08-14 09:44:22 +0200
commit2330afab6388de5cd4f27233334b614b07d819d6 (patch)
tree1a3255b1770da1415b85a8a81ddc620b4d344216
parente2cc7757e1bdbe8c9dc0dcffc1017ceff4799899 (diff)
downloadrust-2330afab6388de5cd4f27233334b614b07d819d6.tar.gz
rust-2330afab6388de5cd4f27233334b614b07d819d6.zip
Apply suggestions from code review
Co-authored-by: Boxy <rust@boxyuwu.dev>
-rw-r--r--compiler/rustc_middle/src/thir.rs6
-rw-r--r--compiler/rustc_middle/src/ty/consts/valtree.rs2
-rw-r--r--compiler/rustc_mir_build/src/builder/matches/mod.rs4
-rw-r--r--compiler/rustc_mir_build/src/builder/matches/test.rs2
4 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs
index 2c7b41193eb..f1d19800a78 100644
--- a/compiler/rustc_middle/src/thir.rs
+++ b/compiler/rustc_middle/src/thir.rs
@@ -1034,7 +1034,7 @@ impl<'tcx> PatRangeBoundary<'tcx> {
             Self::NegInfinity | Self::PosInfinity => None,
         }
     }
-    pub fn eval_bits(self, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> u128 {
+    pub fn to_bits(self, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> u128 {
         match self {
             Self::Finite(value) => value.try_to_scalar_int().unwrap().to_bits_unchecked(),
             Self::NegInfinity => {
@@ -1077,8 +1077,8 @@ impl<'tcx> PatRangeBoundary<'tcx> {
             _ => {}
         }
 
-        let a = self.eval_bits(ty, tcx);
-        let b = other.eval_bits(ty, tcx);
+        let a = self.to_bits(ty, tcx);
+        let b = other.to_bits(ty, tcx);
 
         match ty.kind() {
             ty::Float(ty::FloatTy::F16) => {
diff --git a/compiler/rustc_middle/src/ty/consts/valtree.rs b/compiler/rustc_middle/src/ty/consts/valtree.rs
index bf20520f4cd..a14e47d7082 100644
--- a/compiler/rustc_middle/src/ty/consts/valtree.rs
+++ b/compiler/rustc_middle/src/ty/consts/valtree.rs
@@ -135,7 +135,7 @@ pub type ConstToValTreeResult<'tcx> = Result<Result<ValTree<'tcx>, Ty<'tcx>>, Er
 /// A type-level constant value.
 ///
 /// Represents a typed, fully evaluated constant.
-/// Note that this is used by pattern elaboration to represent values which cannot occur in types,
+/// Note that this is also used by pattern elaboration to represent values which cannot occur in types,
 /// such as raw pointers and floats.
 #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
 #[derive(HashStable, TyEncodable, TyDecodable, TypeFoldable, TypeVisitable, Lift)]
diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs
index 2833b649ed7..6ee9674bb08 100644
--- a/compiler/rustc_mir_build/src/builder/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs
@@ -1316,12 +1316,12 @@ enum TestKind<'tcx> {
     If,
 
     /// Test for equality with value, possibly after an unsizing coercion to
-    /// `ty`,
+    /// `cast_ty`,
     Eq {
         value: ty::Value<'tcx>,
         // Integer types are handled by `SwitchInt`, and constants with ADT
         // types and `&[T]` types are converted back into patterns, so this can
-        // only be `&str` or `f*`.
+        // only be `&str` or floats.
         cast_ty: Ty<'tcx>,
     },
 
diff --git a/compiler/rustc_mir_build/src/builder/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs
index cefc3d0bf14..d03794fe2d5 100644
--- a/compiler/rustc_mir_build/src/builder/matches/test.rs
+++ b/compiler/rustc_mir_build/src/builder/matches/test.rs
@@ -695,7 +695,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 }
             }
 
-            (TestKind::Eq { value: test_val, .. }, TestCase::Constant { value: case_val, .. }) => {
+            (TestKind::Eq { value: test_val, .. }, TestCase::Constant { value: case_val }) => {
                 if test_val == case_val {
                     fully_matched = true;
                     Some(TestBranch::Success)