Replace span_look_ahead with span_followed_by#154745
Replace span_look_ahead with span_followed_by#154745chenyukang wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
Some changes occurred in match checking cc @Nadrieril |
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| // In case this could be a struct literal that needs to be surrounded | ||
| // by parentheses, find the appropriate span. | ||
| let close_brace_span = sm.span_look_ahead(followed_brace_span, "}", Some(50)); | ||
| let close_brace_span = |
There was a problem hiding this comment.
we can not use span_look_ahead here, because we only want to make sure there is a } in 50 range.
otherwise we can not handle the scenario like U { /* keep comment here */ }, since there are some non whitespace chars inside { }.
https://github.com/rust-lang/rust/pull/154745/changes#diff-68dd28577bfdbdba4a4c4ee9d20797f2f0e3939d926d4bdcbe13b1117a2dbe32R35-R38 is the test case for this.
| let close_brace_span = | ||
| sm.span_to_next_source(open_brace_span).ok().and_then(|next_source| { | ||
| let offset = next_source.find('}')?; | ||
| if next_source[..offset].chars().count() >= 50 { |
There was a problem hiding this comment.
Please add a comment explaining what this >= 50 check is doing, and why 50 was chosen.
While reviewing that PR #154703 (comment), I found that magic number 100, let's remove it, and seems
span_followed_byis a better name.