Fix a typo

This commit is contained in:
Dale Wijnand 2019-02-26 17:59:32 +00:00
parent 5e00a398f7
commit ffca2c1fe4
No known key found for this signature in database
GPG key ID: 4F256E3D151DF5EF

View file

@ -8,7 +8,7 @@ use ra_syntax::{
#[derive(Default)] #[derive(Default)]
pub struct TokenMap { pub struct TokenMap {
/// Maps `tt::TokenId` to the *relative* source range. /// 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 /// 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 { impl TokenMap {
pub fn relative_range_of(&self, tt: tt::TokenId) -> Option<TextRange> { pub fn relative_range_of(&self, tt: tt::TokenId) -> Option<TextRange> {
let idx = tt.0 as usize; 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 { fn alloc(&mut self, relative_range: TextRange) -> tt::TokenId {
let id = self.toknes.len(); let id = self.tokens.len();
self.toknes.push(relative_range); self.tokens.push(relative_range);
tt::TokenId(id as u32) tt::TokenId(id as u32)
} }
} }