Skip to content

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed
 

‎src/libsyntax_pos/hygiene.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ use std::fmt;
2727

2828
/// A SyntaxContext represents a chain of macro expansions (represented by marks).
2929
#[derive(Clone, Copy, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
30-
pub struct SyntaxContext(pub(super) u32);
30+
pub struct SyntaxContext(u32);
3131

3232
#[derive(Copy, Clone, Debug)]
33-
pub struct SyntaxContextData {
34-
pub outer_mark: Mark,
35-
pub prev_ctxt: SyntaxContext,
33+
struct SyntaxContextData {
34+
outer_mark: Mark,
35+
prev_ctxt: SyntaxContext,
3636
// This context, but with all transparent and semi-transparent marks filtered away.
37-
pub opaque: SyntaxContext,
37+
opaque: SyntaxContext,
3838
// This context, but with all transparent marks filtered away.
39-
pub opaque_and_semitransparent: SyntaxContext,
39+
opaque_and_semitransparent: SyntaxContext,
4040
}
4141

4242
/// A mark is a unique id associated with a macro expansion.
@@ -198,15 +198,15 @@ impl Mark {
198198
}
199199

200200
#[derive(Debug)]
201-
pub struct HygieneData {
201+
crate struct HygieneData {
202202
marks: Vec<MarkData>,
203203
syntax_contexts: Vec<SyntaxContextData>,
204204
markings: HashMap<(SyntaxContext, Mark), SyntaxContext>,
205205
default_edition: Edition,
206206
}
207207

208208
impl HygieneData {
209-
pub fn new() -> Self {
209+
crate fn new() -> Self {
210210
HygieneData {
211211
marks: vec![MarkData {
212212
parent: Mark::root(),
@@ -249,6 +249,14 @@ impl SyntaxContext {
249249
SyntaxContext(0)
250250
}
251251

252+
crate fn as_u32(self) -> u32 {
253+
self.0
254+
}
255+
256+
crate fn from_u32(raw: u32) -> SyntaxContext {
257+
SyntaxContext(raw)
258+
}
259+
252260
// Allocate a new SyntaxContext with the given ExpnInfo. This is used when
253261
// deserializing Spans from the incr. comp. cache.
254262
// FIXME(mw): This method does not restore MarkData::parent or

‎src/libsyntax_pos/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
html_root_url = "https://doc.rust-lang.org/nightly/")]
2020

2121
#![feature(const_fn)]
22+
#![feature(crate_visibility_modifier)]
2223
#![feature(custom_attribute)]
2324
#![feature(non_exhaustive)]
2425
#![feature(optin_builtin_traits)]
25-
#![allow(unused_attributes)]
2626
#![feature(specialization)]
2727
#![feature(stdsimd)]
2828

‎src/libsyntax_pos/span_encoding.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const INTERNED_INDEX_OFFSET: u32 = 1;
100100

101101
#[inline]
102102
fn encode(sd: &SpanData) -> Span {
103-
let (base, len, ctxt) = (sd.lo.0, sd.hi.0 - sd.lo.0, sd.ctxt.0);
103+
let (base, len, ctxt) = (sd.lo.0, sd.hi.0 - sd.lo.0, sd.ctxt.as_u32());
104104

105105
let val = if (base >> INLINE_SIZES[BASE_INDEX]) == 0 &&
106106
(len >> INLINE_SIZES[LEN_INDEX]) == 0 &&
@@ -132,7 +132,7 @@ fn decode(span: Span) -> SpanData {
132132
let index = extract(INTERNED_INDEX_OFFSET, INTERNED_INDEX_SIZE);
133133
return with_span_interner(|interner| *interner.get(index));
134134
};
135-
SpanData { lo: BytePos(base), hi: BytePos(base + len), ctxt: SyntaxContext(ctxt) }
135+
SpanData { lo: BytePos(base), hi: BytePos(base + len), ctxt: SyntaxContext::from_u32(ctxt) }
136136
}
137137

138138
#[derive(Default)]

0 commit comments

Comments
 (0)
Please sign in to comment.