902: Fix a typo r=matklad a=dwijnand



Co-authored-by: Dale Wijnand <dale.wijnand@gmail.com>
This commit is contained in:
bors[bot] 2019-02-26 18:04:24 +00:00
commit 4248b39993

View File

@ -8,7 +8,7 @@
#[derive(Default)]
pub struct TokenMap {
/// Maps `tt::TokenId` to the *relative* source range.
toknes: Vec<TextRange>,
tokens: Vec<TextRange>,
}
/// Convert the syntax tree (what user has written) to a `TokenTree` (what macro
@ -32,12 +32,12 @@ pub fn token_tree_to_ast_item_list(tt: &tt::Subtree) -> TreeArc<ast::SourceFile>
impl TokenMap {
pub fn relative_range_of(&self, tt: tt::TokenId) -> Option<TextRange> {
let idx = tt.0 as usize;
self.toknes.get(idx).map(|&it| it)
self.tokens.get(idx).map(|&it| it)
}
fn alloc(&mut self, relative_range: TextRange) -> tt::TokenId {
let id = self.toknes.len();
self.toknes.push(relative_range);
let id = self.tokens.len();
self.tokens.push(relative_range);
tt::TokenId(id as u32)
}
}