Skip to content

Commit d1b32e8

Browse files
committed
Tweaks for similarity with #59693
1 parent 96d700f commit d1b32e8

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

src/libsyntax_pos/hygiene.rs

+3
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,17 @@ pub fn clear_markings() {
218218
}
219219

220220
impl SyntaxContext {
221+
#[inline]
221222
pub const fn empty() -> Self {
222223
SyntaxContext(0)
223224
}
224225

226+
#[inline]
225227
crate fn as_u32(self) -> u32 {
226228
self.0
227229
}
228230

231+
#[inline]
229232
crate fn from_u32(raw: u32) -> SyntaxContext {
230233
SyntaxContext(raw)
231234
}

src/libsyntax_pos/span_encoding.rs

+2-26
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,9 @@ use std::hash::{Hash, Hasher};
1616
/// The primary goal of `Span` is to be as small as possible and fit into other structures
1717
/// (that's why it uses `packed` as well). Decoding speed is the second priority.
1818
/// See `SpanData` for the info on span fields in decoded representation.
19-
#[repr(packed)]
19+
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
2020
pub struct Span(u32);
2121

22-
impl Copy for Span {}
23-
impl Clone for Span {
24-
#[inline]
25-
fn clone(&self) -> Span {
26-
*self
27-
}
28-
}
29-
impl PartialEq for Span {
30-
#[inline]
31-
fn eq(&self, other: &Span) -> bool {
32-
let a = self.0;
33-
let b = other.0;
34-
a == b
35-
}
36-
}
37-
impl Eq for Span {}
38-
impl Hash for Span {
39-
#[inline]
40-
fn hash<H: Hasher>(&self, state: &mut H) {
41-
let a = self.0;
42-
a.hash(state)
43-
}
44-
}
45-
4622
/// Dummy span, both position and length are zero, syntax context is zero as well.
4723
/// This span is kept inline and encoded with format 0.
4824
pub const DUMMY_SP: Span = Span(0);
@@ -109,7 +85,7 @@ fn decode(span: Span) -> SpanData {
10985
let val = span.0;
11086

11187
// Extract a field at position `pos` having size `size`.
112-
let extract = |pos: u32, size: u32| {
88+
let extract = #[inline] |pos: u32, size: u32| {
11389
let mask = ((!0u32) as u64 >> (32 - size)) as u32; // Can't shift u32 by 32
11490
(val >> pos) & mask
11591
};

0 commit comments

Comments
 (0)