mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
Rename TtSeq
as TtSlice
.
It's a better name because (a) it holds a slice, and (b) "sequence" has other meanings in this file.
This commit is contained in:
parent
f43028d06f
commit
440a685575
@ -93,12 +93,12 @@ use std::ops::{Deref, DerefMut};
|
|||||||
|
|
||||||
// To avoid costly uniqueness checks, we require that `MatchSeq` always has a nonempty body.
|
// To avoid costly uniqueness checks, we require that `MatchSeq` always has a nonempty body.
|
||||||
|
|
||||||
/// Either a sequence of token trees or a single one. This is used as the representation of the
|
/// Either a slice of token trees or a single one. This is used as the representation of the
|
||||||
/// sequence of tokens that make up a matcher.
|
/// token trees that make up a matcher.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
enum TokenTreeOrTokenTreeSlice<'tt> {
|
enum TokenTreeOrTokenTreeSlice<'tt> {
|
||||||
Tt(TokenTree),
|
Tt(TokenTree),
|
||||||
TtSeq(&'tt [TokenTree]),
|
TtSlice(&'tt [TokenTree]),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tt> TokenTreeOrTokenTreeSlice<'tt> {
|
impl<'tt> TokenTreeOrTokenTreeSlice<'tt> {
|
||||||
@ -106,7 +106,7 @@ impl<'tt> TokenTreeOrTokenTreeSlice<'tt> {
|
|||||||
/// will not recursively descend into subtrees).
|
/// will not recursively descend into subtrees).
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
TtSeq(ref v) => v.len(),
|
TtSlice(ref v) => v.len(),
|
||||||
Tt(ref tt) => tt.len(),
|
Tt(ref tt) => tt.len(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ impl<'tt> TokenTreeOrTokenTreeSlice<'tt> {
|
|||||||
/// The `index`-th token tree of `self`.
|
/// The `index`-th token tree of `self`.
|
||||||
fn get_tt(&self, index: usize) -> TokenTree {
|
fn get_tt(&self, index: usize) -> TokenTree {
|
||||||
match *self {
|
match *self {
|
||||||
TtSeq(ref v) => v[index].clone(),
|
TtSlice(ref v) => v[index].clone(),
|
||||||
Tt(ref tt) => tt.get_tt(index),
|
Tt(ref tt) => tt.get_tt(index),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ type NamedMatchVec = SmallVec<[NamedMatch; 4]>;
|
|||||||
/// lifetime. By separating `'tt` from `'root`, we can show that.
|
/// lifetime. By separating `'tt` from `'root`, we can show that.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct MatcherPos<'root, 'tt> {
|
struct MatcherPos<'root, 'tt> {
|
||||||
/// The token or sequence of tokens that make up the matcher. `elts` is short for "elements".
|
/// The token or slice of tokens that make up the matcher. `elts` is short for "elements".
|
||||||
top_elts: TokenTreeOrTokenTreeSlice<'tt>,
|
top_elts: TokenTreeOrTokenTreeSlice<'tt>,
|
||||||
|
|
||||||
/// The position of the "dot" in this matcher
|
/// The position of the "dot" in this matcher
|
||||||
@ -220,7 +220,7 @@ impl<'root, 'tt> MatcherPos<'root, 'tt> {
|
|||||||
let match_idx_hi = count_names(ms);
|
let match_idx_hi = count_names(ms);
|
||||||
MatcherPos {
|
MatcherPos {
|
||||||
// Start with the top level matcher given to us.
|
// Start with the top level matcher given to us.
|
||||||
top_elts: TtSeq(ms),
|
top_elts: TtSlice(ms),
|
||||||
|
|
||||||
// The "dot" is before the first token of the matcher.
|
// The "dot" is before the first token of the matcher.
|
||||||
idx: 0,
|
idx: 0,
|
||||||
@ -419,7 +419,7 @@ crate enum NamedMatch {
|
|||||||
MatchedNonterminal(Lrc<Nonterminal>),
|
MatchedNonterminal(Lrc<Nonterminal>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes a sequence of token trees `ms` representing a matcher which successfully matched input
|
/// Takes a slice of token trees `ms` representing a matcher which successfully matched input
|
||||||
/// and an iterator of items that matched input and produces a `NamedParseResult`.
|
/// and an iterator of items that matched input and produces a `NamedParseResult`.
|
||||||
fn nameize<I: Iterator<Item = NamedMatch>>(
|
fn nameize<I: Iterator<Item = NamedMatch>>(
|
||||||
sess: &ParseSess,
|
sess: &ParseSess,
|
||||||
@ -678,8 +678,8 @@ fn parse_tt_inner<'root, 'tt>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use the given sequence of token trees (`ms`) as a matcher. Match the token
|
/// Use the given slice of token trees (`ms`) as a matcher. Match the token stream from the given
|
||||||
/// stream from the given `parser` against it and return the match.
|
/// `parser` against it and return the match.
|
||||||
pub(super) fn parse_tt(
|
pub(super) fn parse_tt(
|
||||||
parser: &mut Cow<'_, Parser<'_>>,
|
parser: &mut Cow<'_, Parser<'_>>,
|
||||||
ms: &[TokenTree],
|
ms: &[TokenTree],
|
||||||
|
Loading…
Reference in New Issue
Block a user