Will Schroeder
Will Schroeder
I just realised that this is not enough; peek_mut (and peek_nth_mut) are also required. I'll add them to the PR in the morning.
I've now added the two methods that were missing
I'm not sure `error_callback` is the right name for the attribute. Would `error_constructor` be more clear?
Just a heads-up that adding a defaulted method to a trait (which this PR does) is [listed as a 'possibly-breaking' change](https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-default-item) in the cargo book's SemVer section.
I ran the benchmarks on my machine and got this: ``` group default_before default_changes ----- -------------- --------------- count_ok/identifiers 1.19 618.1±2.13ns 1201.8 MB/sec 1.00 519.2±2.93ns 1431.0 MB/sec count_ok/keywords_operators_and_punctators 1.13 1711.9±11.62ns 1187.2...
The problem is on lines 381 and 385 of src/lexer.rs: ```rust #[cfg(not(feature = "forbid_unsafe"))] { self.token = core::mem::ManuallyDrop::new(Some(Err(Token::make_error(self)))); } #[cfg(feature = "forbid_unsafe")] { self.token = Some(Err(Token::make_error(self))); } ``` Previously, `Token::make_error(self)`...
Here are my benchmarks after reverting that specific line: ``` group default_before default_changes ----- -------------- --------------- count_ok/identifiers 1.00 619.9±5.36ns 1198.5 MB/sec 1.00 618.1±1.59ns 1201.8 MB/sec count_ok/keywords_operators_and_punctators 1.00 1709.8±10.51ns 1188.6 MB/sec...
To get it to work, I changed the signature and default implementation of `make_error`: ```rust #[inline(always)] #[doc(hidden)] fn make_error(lexer: &mut Lexer
> Thanks for your efforts @mysteriouslyseeing! I am not sure to understand your two benchmark results: the first is this PR's changes, and the second is the change between last...
Hmmm, that is strange. Looks like it's mostly increases? Identifiers are worse, but only without `forbid_unsafe`? Unfortunately I probably can't investigate because my local benchmarks are showing little to no...