diff --git a/crates/ra_tt/src/buffer.rs b/crates/ra_tt/src/buffer.rs index a149205fbd..56b844b8b7 100644 --- a/crates/ra_tt/src/buffer.rs +++ b/crates/ra_tt/src/buffer.rs @@ -29,21 +29,21 @@ impl TokenBuffer { pub fn new(tokens: &[TokenTree]) -> TokenBuffer { let mut buffers = vec![]; - let idx = TokenBuffer::new_inner(tokens.to_vec(), &mut buffers, None); + let idx = TokenBuffer::new_inner(tokens, &mut buffers, None); assert_eq!(idx, 0); TokenBuffer { buffers } } fn new_inner( - tokens: Vec, + tokens: &[TokenTree], buffers: &mut Vec>, next: Option, ) -> usize { let mut entries = vec![]; let mut children = vec![]; - for (idx, tt) in tokens.into_iter().enumerate() { + for (idx, tt) in tokens.iter().cloned().enumerate() { match tt { TokenTree::Leaf(leaf) => { entries.push(Entry::Leaf(leaf)); @@ -61,7 +61,7 @@ impl TokenBuffer { for (child_idx, subtree) in children { let idx = TokenBuffer::new_inner( - subtree.token_trees.clone(), + &subtree.token_trees, buffers, Some(EntryPtr(EntryId(res), child_idx + 1)), );