Skip to content

Commit 47fe531

Browse files
committed
Add lifetime parameters to &ParserState return values.
1 parent ce31095 commit 47fe531

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/parser.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1264,11 +1264,11 @@ pub enum ParserInput {
12641264
}
12651265

12661266
pub trait WasmDecoder<'a> {
1267-
fn read(&mut self) -> &ParserState;
1267+
fn read(&mut self) -> &ParserState<'a>;
12681268
fn push_input(&mut self, input: ParserInput);
1269-
fn read_with_input(&mut self, input: ParserInput) -> &ParserState;
1269+
fn read_with_input(&mut self, input: ParserInput) -> &ParserState<'a>;
12701270
fn create_binary_reader<'b>(&mut self) -> BinaryReader<'b> where 'a: 'b;
1271-
fn last_state(&self) -> &ParserState;
1271+
fn last_state(&self) -> &ParserState<'a>;
12721272
}
12731273

12741274
/// The `Parser` type. A simple event-driven parser of WebAssembly binary
@@ -1961,7 +1961,7 @@ impl<'a> WasmDecoder<'a> for Parser<'a> {
19611961
/// println!("Second state {:?}", state);
19621962
/// }
19631963
/// ```
1964-
fn read(&mut self) -> &ParserState {
1964+
fn read(&mut self) -> &ParserState<'a> {
19651965
let result = self.read_wrapped();
19661966
if result.is_err() {
19671967
self.state = ParserState::Error(result.err().unwrap());
@@ -2059,12 +2059,12 @@ impl<'a> WasmDecoder<'a> for Parser<'a> {
20592059
/// }
20602060
/// }
20612061
/// ```
2062-
fn read_with_input(&mut self, input: ParserInput) -> &ParserState {
2062+
fn read_with_input(&mut self, input: ParserInput) -> &ParserState<'a> {
20632063
self.push_input(input);
20642064
self.read()
20652065
}
20662066

2067-
fn last_state(&self) -> &ParserState {
2067+
fn last_state(&self) -> &ParserState<'a> {
20682068
&self.state
20692069
}
20702070
}

src/validator.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ impl<'a> ValidatingParser<'a> {
15381538
}
15391539

15401540
impl<'a> WasmDecoder<'a> for ValidatingParser<'a> {
1541-
fn read(&mut self) -> &ParserState {
1541+
fn read(&mut self) -> &ParserState<'a> {
15421542
if self.validation_error.is_some() {
15431543
panic!("Parser in error state: validation");
15441544
}
@@ -1556,7 +1556,7 @@ impl<'a> WasmDecoder<'a> for ValidatingParser<'a> {
15561556
}
15571557
}
15581558

1559-
fn read_with_input(&mut self, input: ParserInput) -> &ParserState {
1559+
fn read_with_input(&mut self, input: ParserInput) -> &ParserState<'a> {
15601560
self.push_input(input);
15611561
self.read()
15621562
}
@@ -1570,7 +1570,7 @@ impl<'a> WasmDecoder<'a> for ValidatingParser<'a> {
15701570
self.parser.create_binary_reader()
15711571
}
15721572

1573-
fn last_state(&self) -> &ParserState {
1573+
fn last_state(&self) -> &ParserState<'a> {
15741574
if self.validation_error.is_some() {
15751575
self.validation_error.as_ref().unwrap()
15761576
} else {

0 commit comments

Comments
 (0)