-
Notifications
You must be signed in to change notification settings - Fork 13.4k
source_span_for_markdown_range: fix utf8 violation #141666
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
base: master
Are you sure you want to change the base?
source_span_for_markdown_range: fix utf8 violation #141666
Conversation
We need a regression test. |
yes, I was under the impression you were working on that (well, a MCVE for the issue). if you want me to do it, i can. |
I triggered the issue with |
Alright, I think I should be able to throw something together. |
This comment has been minimized.
This comment has been minimized.
my initial ideas for how to trigger this crash were unsuccessful, might be easier to just throw treereduce-rustc at it or something. also not sure if you had the bug happen on unmodified sysinfo or if there was some change you made. |
See #141665 (comment) for a minimal repro involving |
3194bc1
to
74b1eb3
Compare
@fmease do you think we could just add a regression test to the clippy test suite? either as a followup PR or via submodules. |
Isn't it possible to create a span in a unit test and then run our function on it? |
A unit test would almost certainly work, but I'm not sure the proper way to get a |
@@ -570,7 +570,12 @@ pub fn source_span_for_markdown_range( | |||
{ | |||
// If there is either a match in a previous fragment, or | |||
// multiple matches in this fragment, there is ambiguity. | |||
if match_data.is_none() && !snippet[match_start + 1..].contains(pat) { | |||
// the snippet cannot be zero-sized, |
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.
Also please don't split your comments so much. It makes much harder to read. You have up to 100 columns, make use of it.
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 was trying to use semantic line breaks, but maybe i went a bit overboard. I also am using a laptop with a fairly small screen.
That's a good point. I suppose there are such unit tests in the compiler making use of |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The job Click to see the possible cause of the failure (guessed by this bot)
|
The new code should have exactly identical behavior to the old code, but without the crash. I thought I fixed the inconsistentcy, but the tests are still failing, which means something changed which shouldn't have. |
fixes #141665
r? @GuillaumeGomez