]> git.lizzy.rs Git - rust.git/commitdiff
Remove cast to usize for BytePos and CharPos
authorJames Whaley <juicy66173@gmail.com>
Mon, 21 Sep 2020 18:42:43 +0000 (19:42 +0100)
committerJames Whaley <juicy66173@gmail.com>
Mon, 21 Sep 2020 18:42:43 +0000 (19:42 +0100)
The case shouldn't be necessary and implicitly truncating BytePos is not
desirable.

compiler/rustc_span/src/lib.rs

index ad3a866463d45ba03ef0982ffb6ea29e10e2bc42..4b02a2d4076d7749c0cb28a078bd0c129fb6ff71 100644 (file)
@@ -1596,7 +1596,7 @@ impl Add for $ident {
 
                 #[inline(always)]
                 fn add(self, rhs: $ident) -> $ident {
-                    $ident((self.to_usize() + rhs.to_usize()) as $inner_ty)
+                    $ident(self.0 + rhs.0)
                 }
             }
 
@@ -1605,7 +1605,7 @@ impl Sub for $ident {
 
                 #[inline(always)]
                 fn sub(self, rhs: $ident) -> $ident {
-                    $ident((self.to_usize() - rhs.to_usize()) as $inner_ty)
+                    $ident(self.0 - rhs.0)
                 }
             }
         )*