diff options
| author | bors <bors@rust-lang.org> | 2018-05-03 20:45:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-05-03 20:45:54 +0000 |
| commit | e82261dfbb5feaa2d28d2b138f4aabb2aa52c94b (patch) | |
| tree | 3bade0f4dfbda64eac4eed19227ac3f46acdf373 /src/libsyntax_pos/lib.rs | |
| parent | d68b0eceaaf719a4702ab13a7ca62dea5d966082 (diff) | |
| parent | 03a0402dbf3143ab6a8b7166f4d1f74aa68f71df (diff) | |
| download | rust-e82261dfbb5feaa2d28d2b138f4aabb2aa52c94b.tar.gz rust-e82261dfbb5feaa2d28d2b138f4aabb2aa52c94b.zip | |
Auto merge of #50413 - kennytm:rollup, r=kennytm
Rollup of 12 pull requests Successful merges: - #50302 (Add query search order check) - #50320 (Fix invalid path generation in rustdoc search) - #50349 (Rename "show type declaration" to "show declaration") - #50360 (Clarify wordings of the `unstable_name_collision` lint.) - #50365 (Use two vectors in nearest_common_ancestor.) - #50393 (Allow unaligned reads in constants) - #50401 (Revert "Implement FromStr for PathBuf") - #50406 (Forbid constructing empty identifiers from concat_idents) - #50407 (Always inline simple BytePos and CharPos methods.) - #50416 (check if the token is a lifetime before parsing) - #50417 (Update Cargo) - #50421 (Fix ICE when using a..=b in a closure.) Failed merges:
Diffstat (limited to 'src/libsyntax_pos/lib.rs')
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 8d37b4aa396..8b4a3ea26a1 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -1150,13 +1150,17 @@ pub struct CharPos(pub usize); // have been unsuccessful impl Pos for BytePos { + #[inline(always)] fn from_usize(n: usize) -> BytePos { BytePos(n as u32) } + + #[inline(always)] fn to_usize(&self) -> usize { let BytePos(n) = *self; n as usize } } impl Add for BytePos { type Output = BytePos; + #[inline(always)] fn add(self, rhs: BytePos) -> BytePos { BytePos((self.to_usize() + rhs.to_usize()) as u32) } @@ -1165,6 +1169,7 @@ impl Add for BytePos { impl Sub for BytePos { type Output = BytePos; + #[inline(always)] fn sub(self, rhs: BytePos) -> BytePos { BytePos((self.to_usize() - rhs.to_usize()) as u32) } @@ -1183,13 +1188,17 @@ impl Decodable for BytePos { } impl Pos for CharPos { + #[inline(always)] fn from_usize(n: usize) -> CharPos { CharPos(n) } + + #[inline(always)] fn to_usize(&self) -> usize { let CharPos(n) = *self; n } } impl Add for CharPos { type Output = CharPos; + #[inline(always)] fn add(self, rhs: CharPos) -> CharPos { CharPos(self.to_usize() + rhs.to_usize()) } @@ -1198,6 +1207,7 @@ impl Add for CharPos { impl Sub for CharPos { type Output = CharPos; + #[inline(always)] fn sub(self, rhs: CharPos) -> CharPos { CharPos(self.to_usize() - rhs.to_usize()) } |
