Skip to content

Commit 81fe857

Browse files
committed
make mbe::TokenTree private to module
1 parent 9835697 commit 81fe857

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

src/libsyntax/ext/mbe.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ use rustc_data_structures::sync::Lrc;
2020
/// Contains the sub-token-trees of a "delimited" token tree, such as the contents of `(`. Note
2121
/// that the delimiter itself might be `NoDelim`.
2222
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
23-
crate struct Delimited {
24-
crate delim: token::DelimToken,
25-
crate tts: Vec<TokenTree>,
23+
struct Delimited {
24+
delim: token::DelimToken,
25+
tts: Vec<TokenTree>,
2626
}
2727

2828
impl Delimited {
2929
/// Returns a `self::TokenTree` with a `Span` corresponding to the opening delimiter.
30-
crate fn open_tt(&self, span: Span) -> TokenTree {
30+
fn open_tt(&self, span: Span) -> TokenTree {
3131
let open_span = if span.is_dummy() {
3232
span
3333
} else {
@@ -37,7 +37,7 @@ impl Delimited {
3737
}
3838

3939
/// Returns a `self::TokenTree` with a `Span` corresponding to the closing delimiter.
40-
crate fn close_tt(&self, span: Span) -> TokenTree {
40+
fn close_tt(&self, span: Span) -> TokenTree {
4141
let close_span = if span.is_dummy() {
4242
span
4343
} else {
@@ -48,33 +48,33 @@ impl Delimited {
4848
}
4949

5050
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
51-
crate struct SequenceRepetition {
51+
struct SequenceRepetition {
5252
/// The sequence of token trees
53-
crate tts: Vec<TokenTree>,
53+
tts: Vec<TokenTree>,
5454
/// The optional separator
55-
crate separator: Option<Token>,
55+
separator: Option<Token>,
5656
/// Whether the sequence can be repeated zero (*), or one or more times (+)
57-
crate kleene: KleeneToken,
57+
kleene: KleeneToken,
5858
/// The number of `Match`s that appear in the sequence (and subsequences)
59-
crate num_captures: usize,
59+
num_captures: usize,
6060
}
6161

6262
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
63-
crate struct KleeneToken {
64-
crate span: Span,
65-
crate op: KleeneOp,
63+
struct KleeneToken {
64+
span: Span,
65+
op: KleeneOp,
6666
}
6767

6868
impl KleeneToken {
69-
crate fn new(op: KleeneOp, span: Span) -> KleeneToken {
69+
fn new(op: KleeneOp, span: Span) -> KleeneToken {
7070
KleeneToken { span, op }
7171
}
7272
}
7373

7474
/// A Kleene-style [repetition operator](http://en.wikipedia.org/wiki/Kleene_star)
7575
/// for token sequences.
7676
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
77-
crate enum KleeneOp {
77+
enum KleeneOp {
7878
/// Kleene star (`*`) for zero or more repetitions
7979
ZeroOrMore,
8080
/// Kleene plus (`+`) for one or more repetitions
@@ -86,7 +86,7 @@ crate enum KleeneOp {
8686
/// Similar to `tokenstream::TokenTree`, except that `$i`, `$i:ident`, and `$(...)`
8787
/// are "first-class" token trees. Useful for parsing macros.
8888
#[derive(Debug, Clone, PartialEq, RustcEncodable, RustcDecodable)]
89-
crate enum TokenTree {
89+
enum TokenTree {
9090
Token(Token),
9191
Delimited(DelimSpan, Lrc<Delimited>),
9292
/// A kleene-style repetition sequence
@@ -103,7 +103,7 @@ crate enum TokenTree {
103103

104104
impl TokenTree {
105105
/// Return the number of tokens in the tree.
106-
crate fn len(&self) -> usize {
106+
fn len(&self) -> usize {
107107
match *self {
108108
TokenTree::Delimited(_, ref delimed) => match delimed.delim {
109109
token::NoDelim => delimed.tts.len(),
@@ -115,23 +115,23 @@ impl TokenTree {
115115
}
116116

117117
/// Returns `true` if the given token tree is delimited.
118-
crate fn is_delimited(&self) -> bool {
118+
fn is_delimited(&self) -> bool {
119119
match *self {
120120
TokenTree::Delimited(..) => true,
121121
_ => false,
122122
}
123123
}
124124

125125
/// Returns `true` if the given token tree is a token of the given kind.
126-
crate fn is_token(&self, expected_kind: &TokenKind) -> bool {
126+
fn is_token(&self, expected_kind: &TokenKind) -> bool {
127127
match self {
128128
TokenTree::Token(Token { kind: actual_kind, .. }) => actual_kind == expected_kind,
129129
_ => false,
130130
}
131131
}
132132

133133
/// Gets the `index`-th sub-token-tree. This only makes sense for delimited trees and sequences.
134-
crate fn get_tt(&self, index: usize) -> TokenTree {
134+
fn get_tt(&self, index: usize) -> TokenTree {
135135
match (self, index) {
136136
(&TokenTree::Delimited(_, ref delimed), _) if delimed.delim == token::NoDelim => {
137137
delimed.tts[index].clone()
@@ -151,7 +151,7 @@ impl TokenTree {
151151
}
152152

153153
/// Retrieves the `TokenTree`'s span.
154-
crate fn span(&self) -> Span {
154+
fn span(&self) -> Span {
155155
match *self {
156156
TokenTree::Token(Token { span, .. })
157157
| TokenTree::MetaVar(span, _)
@@ -160,7 +160,7 @@ impl TokenTree {
160160
}
161161
}
162162

163-
crate fn token(kind: TokenKind, span: Span) -> TokenTree {
163+
fn token(kind: TokenKind, span: Span) -> TokenTree {
164164
TokenTree::Token(Token::new(kind, span))
165165
}
166166
}

src/libsyntax/ext/mbe/macro_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ struct MacroState<'a> {
196196
/// - `node_id` is used to emit lints
197197
/// - `span` is used when no spans are available
198198
/// - `lhses` and `rhses` should have the same length and represent the macro definition
199-
crate fn check_meta_variables(
199+
pub(super) fn check_meta_variables(
200200
sess: &ParseSess,
201201
node_id: NodeId,
202202
span: Span,

src/libsyntax/ext/mbe/macro_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ crate enum ParseResult<T> {
282282
crate type NamedParseResult = ParseResult<FxHashMap<Ident, NamedMatch>>;
283283

284284
/// Count how many metavars are named in the given matcher `ms`.
285-
crate fn count_names(ms: &[TokenTree]) -> usize {
285+
pub(super) fn count_names(ms: &[TokenTree]) -> usize {
286286
ms.iter().fold(0, |count, elt| {
287287
count + match *elt {
288288
TokenTree::Sequence(_, ref seq) => seq.num_captures,
@@ -648,7 +648,7 @@ fn inner_parse_loop<'root, 'tt>(
648648
/// - `directory`: Information about the file locations (needed for the black-box parser)
649649
/// - `recurse_into_modules`: Whether or not to recurse into modules (needed for the black-box
650650
/// parser)
651-
crate fn parse(
651+
pub(super) fn parse(
652652
sess: &ParseSess,
653653
tts: TokenStream,
654654
ms: &[TokenTree],

src/libsyntax/ext/mbe/quoted.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use std::iter::Peekable;
3535
/// # Returns
3636
///
3737
/// A collection of `self::TokenTree`. There may also be some errors emitted to `sess`.
38-
crate fn parse(
38+
pub(super) fn parse(
3939
input: tokenstream::TokenStream,
4040
expect_matchers: bool,
4141
sess: &ParseSess,

0 commit comments

Comments
 (0)