diff options
Diffstat (limited to 'third_party/rust/wast/src/parser.rs')
-rw-r--r-- | third_party/rust/wast/src/parser.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/third_party/rust/wast/src/parser.rs b/third_party/rust/wast/src/parser.rs index 0c85923f83..7a20ebe255 100644 --- a/third_party/rust/wast/src/parser.rs +++ b/third_party/rust/wast/src/parser.rs @@ -65,6 +65,7 @@ use crate::lexer::{Float, Integer, Lexer, Token, TokenKind}; use crate::token::Span; use crate::Error; +use bumpalo::Bump; use std::borrow::Cow; use std::cell::{Cell, RefCell}; use std::collections::HashMap; @@ -303,7 +304,7 @@ pub struct ParseBuffer<'a> { cur: Cell<Position>, known_annotations: RefCell<HashMap<String, usize>>, depth: Cell<usize>, - strings: RefCell<Vec<Box<[u8]>>>, + strings: Bump, } /// The current position within a `Lexer` that we're at. This simultaneously @@ -396,14 +397,7 @@ impl ParseBuffer<'_> { /// This will return a reference to `s`, but one that's safely rooted in the /// `Parser`. fn push_str(&self, s: Vec<u8>) -> &[u8] { - let s = Box::from(s); - let ret = &*s as *const [u8]; - self.strings.borrow_mut().push(s); - // This should be safe in that the address of `ret` isn't changing as - // it's on the heap itself. Additionally the lifetime of this return - // value is tied to the lifetime of `self` (nothing is deallocated - // early), so it should be safe to say the two have the same lifetime. - unsafe { &*ret } + self.strings.alloc_slice_copy(&s) } /// Lexes the next "significant" token from the `pos` specified. |