Refactor TokenStream to hold Vec<TokenTree> instead of tt::Subtree

`TokenStream` assumes that its subtree's delimeter is `None`, and this
should be encoded in the type system instead of having a delimiter field
that is mostly ignored.

`tt::Subtree` is just `pub delimiter: Option<Delimiter>, pub
token_trees: Vec<TokenTree>`, so a Subtree that is statically guaranteed
not to have a delimiter is just Vec<TokenTree>.
This commit is contained in:
Kevin Mehall
2021-03-06 09:46:32 -07:00
parent 632fa8ef4a
commit 62f594b390
3 changed files with 56 additions and 65 deletions

View File

@@ -138,7 +138,7 @@ impl Expander {
parsed_body,
false,
);
return res.map(|it| it.subtree);
return res.map(|it| it.into_subtree());
}
bridge::client::ProcMacro::Bang { name, client } if *name == macro_name => {
let res = client.run(
@@ -147,7 +147,7 @@ impl Expander {
parsed_body,
false,
);
return res.map(|it| it.subtree);
return res.map(|it| it.into_subtree());
}
bridge::client::ProcMacro::Attr { name, client } if *name == macro_name => {
let res = client.run(
@@ -157,7 +157,7 @@ impl Expander {
parsed_body,
false,
);
return res.map(|it| it.subtree);
return res.map(|it| it.into_subtree());
}
_ => continue,
}