Skip to content

Commit

Permalink
libsyntax_pos: Tweak some visibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jul 8, 2018
1 parent 0c0315c commit 01b6d7c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
24 changes: 16 additions & 8 deletions src/libsyntax_pos/hygiene.rs
Expand Up @@ -27,16 +27,16 @@ use std::fmt;

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

#[derive(Copy, Clone, Debug)]
pub struct SyntaxContextData {
pub outer_mark: Mark,
pub prev_ctxt: SyntaxContext,
struct SyntaxContextData {
outer_mark: Mark,
prev_ctxt: SyntaxContext,
// This context, but with all transparent and semi-transparent marks filtered away.
pub opaque: SyntaxContext,
opaque: SyntaxContext,
// This context, but with all transparent marks filtered away.
pub opaque_and_semitransparent: SyntaxContext,
opaque_and_semitransparent: SyntaxContext,
}

/// A mark is a unique id associated with a macro expansion.
Expand Down Expand Up @@ -198,15 +198,15 @@ impl Mark {
}

#[derive(Debug)]
pub struct HygieneData {
crate struct HygieneData {
marks: Vec<MarkData>,
syntax_contexts: Vec<SyntaxContextData>,
markings: HashMap<(SyntaxContext, Mark), SyntaxContext>,
default_edition: Edition,
}

impl HygieneData {
pub fn new() -> Self {
crate fn new() -> Self {
HygieneData {
marks: vec![MarkData {
parent: Mark::root(),
Expand Down Expand Up @@ -249,6 +249,14 @@ impl SyntaxContext {
SyntaxContext(0)
}

crate fn as_u32(self) -> u32 {
self.0
}

crate fn from_u32(raw: u32) -> SyntaxContext {
SyntaxContext(raw)
}

// Allocate a new SyntaxContext with the given ExpnInfo. This is used when
// deserializing Spans from the incr. comp. cache.
// FIXME(mw): This method does not restore MarkData::parent or
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_pos/lib.rs
Expand Up @@ -19,10 +19,10 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]

#![feature(const_fn)]
#![feature(crate_visibility_modifier)]
#![feature(custom_attribute)]
#![feature(non_exhaustive)]
#![feature(optin_builtin_traits)]
#![allow(unused_attributes)]
#![feature(specialization)]
#![feature(stdsimd)]

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax_pos/span_encoding.rs
Expand Up @@ -100,7 +100,7 @@ const INTERNED_INDEX_OFFSET: u32 = 1;

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

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

#[derive(Default)]
Expand Down

0 comments on commit 01b6d7c

Please sign in to comment.