internal: remove accidental code re-use

FragmentKind played two roles:

* entry point to the parser
* syntactic category of a macro call

These are different use-cases, and warrant different types. For example,
macro can't expand to visibility, but we have such fragment today.

This PR introduces `ExpandsTo` enum to separate this two use-cases.

I suspect we might further split `FragmentKind` into `$x:specifier` enum
specific to MBE, and a general parser entry point, but that's for
another PR!
This commit is contained in:
Aleksey Kladov 2021-09-05 22:30:06 +03:00
parent 847d0faf92
commit dbb702cfc1
18 changed files with 168 additions and 135 deletions

View file

@ -2,7 +2,7 @@
use std::iter;
use parser::{FragmentKind, ParseError, TreeSink};
use parser::{ParseError, TreeSink};
use rustc_hash::FxHashMap;
use syntax::{
ast::{self, make::tokens::doc_comment},
@ -12,8 +12,9 @@ use syntax::{
};
use tt::buffer::{Cursor, TokenBuffer};
use crate::{subtree_source::SubtreeTokenSource, tt_iter::TtIter};
use crate::{ExpandError, TokenMap};
use crate::{
subtree_source::SubtreeTokenSource, tt_iter::TtIter, ExpandError, FragmentKind, TokenMap,
};
/// Convert the syntax node to a `TokenTree` (what macro
/// will consume).