-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parser: shrink the size of WithSpan
to one register
#257
Conversation
@@ -134,19 +134,70 @@ impl<'a> Ast<'a> { | |||
/// in the code generation. | |||
pub struct WithSpan<'a, T> { | |||
inner: T, | |||
span: &'a str, | |||
span: Span<'a>, | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure the size doesn't grow up, might be worth adding a compile-time size_of
check of WithSpan
and of Span
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it matters too much, as the PR fixes another problem, too:
If the input span is shrunk at the end of the input, e.g. let i = i.trim()
, then the error messages will be broken afterward, because only the lengths are compared. This PR fixes that, too. This was actually my original intention with, because I had to refactor some code a few times in order not to break the error messages. That the Span is smaller afterwards is just a happy co-incidence. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a check, anyway. :)
Oh, I did not expect a fuzzer error, but it makes me happy that it is actually working!
Oops, I should have read the documentation of the method more carefully. :) The failed scenario: Parser(
Scenario {
syntax: Syntax {
block_start: "{%",
block_end: "%}",
expr_start: "{{",
expr_end: "}}",
comment_start: "{#",
comment_end: "#}",
},
src: "FFFFF\u{1a}FFFFFFFD& {%\r\rset\rnnnnnnnnnnnyA%}\u{11}\rr\ti-0)mmm..%}68-iioirLLLLLLLLcLLLLLLLLLLLLLL1i2{%for\r\rr\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rFFforn\r\rmmm%}68-0)mmm%}68-iioirLLLLLLLLcLLLLLLLLLLLLLL1i2{%for\r\rr\tin\tif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rLLLLLL& {%\r\rset\rnnnnnnnnnnnyA%}\u{11}\rr\ti-0)mmm%}68-iioirLLLLLLLLcLLLLLLLLLLLLLL1i2{%for\r\rr\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rFFfom%}68-iioirLLLLLLLLcLLLLLLLLLLLLLL1i2{%for\r\rr\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rFFforn\r\rmmm%}68-0)mmm%}68-iioirLLLLLLLLcLLLLLLLLLLLLLL1i2{%for\r\rr\tin\tif*W%}\u{14} s\0\0\0{%-\r\relse+%}|\rLLLLLLLL1i2{%for\r\rr\tin\rif*W%}\u{14}LL1i2{%for\r\rr\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rFFforn\r\rmmm%F\rnnnnnnnnLLLLLL1i2{%for\r\rr\tin\tif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rLLLLLLLL1i2{%for\r\rrr\tin\rif*W%}\u{14}LL1i2{%for\r\rr\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rFFforn\r\rmmm%F\rnnnnnnnnLLLLLL1i2{%for\r\rr\tin\tif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rLLLLLLLL1i2{%for\r\rr\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\riioirLLLLLLLLcLLLLLLLLLLLLLL1i2{%for\r\rr\tin\tif*W%}\u{14} s\0\0\0{%-\r\relse+%}|\rLLLLLLLL1i2{%for\r\rr\tin\r\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\riioirLLLLLLLLcLLLLLLLLLLLLLL1i2{%for\r\rr\tin\tif*W%}\u{14} s\0\0\0{%-\r\relse+%}|\rLLLLLLLL1i2{%for\r\rr\tin\rif*W%}\u{14}LL1i2{%for\r\rr\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rFFforn\r\rmmm%F\rnnnnnnnnLLLLLL1i2{%for\r\rr\tin\tif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rLLLLLLLL1i2{%for\r\rr\tin\rif*W%}\u{14} !\u{19} {%-\r\relse+%}|\rFFforn\r\rmmm%F\rnnnnnnnnnnnyA%\r}yyyA%}",
},
) |
3fc679b
to
45c9b54
Compare
45c9b54
to
611647a
Compare
WithSpan
to one registerWithSpan
to one register
Well, the changes in the parser are not too big. No reason to wait. |
You even added the fuzzing error, nice!
As the reviewer, I disagree. :p |
Please merge once fuzzer passed. |
To be rebased after #214 is merged.