Support $crate in item and expr place.

This commit is contained in:
uHOOCCOOHu 2019-09-27 01:59:38 +08:00
parent 8cd23a4fb8
commit 2ecb126f5c
No known key found for this signature in database
GPG key ID: CED392DE0C483D00
14 changed files with 268 additions and 37 deletions

View file

@ -86,7 +86,7 @@ fn expand_subtree(ctx: &mut ExpandCtx, template: &tt::Subtree) -> Result<tt::Sub
fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr) -> Result<Fragment, ExpandError> {
let res = if v == "crate" {
// FIXME: Properly handle $crate token
// We simply produce identifier `$crate` here. And it will be resolved when lowering ast to Path.
let tt =
tt::Leaf::from(tt::Ident { text: "$crate".into(), id: tt::TokenId::unspecified() })
.into();