fix span calculation for non-ascii in needless_return
This commit is contained in:
parent
660b058ba2
commit
d3f8f3e9d7
4 changed files with 36 additions and 2 deletions
|
|
@ -465,8 +465,8 @@ fn last_statement_borrows<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>)
|
|||
// Go backwards while encountering whitespace and extend the given Span to that point.
|
||||
fn extend_span_to_previous_non_ws(cx: &LateContext<'_>, sp: Span) -> Span {
|
||||
if let Ok(prev_source) = cx.sess().source_map().span_to_prev_source(sp) {
|
||||
let ws = [' ', '\t', '\n'];
|
||||
if let Some(non_ws_pos) = prev_source.rfind(|c| !ws.contains(&c)) {
|
||||
let ws = [b' ', b'\t', b'\n'];
|
||||
if let Some(non_ws_pos) = prev_source.bytes().rposition(|c| !ws.contains(&c)) {
|
||||
let len = prev_source.len() - non_ws_pos - 1;
|
||||
return sp.with_lo(sp.lo() - BytePos::from_usize(len));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue