1
Fork 0

reword the message to suggest surrounding with parentheses

This commit is contained in:
yukang 2023-06-06 23:56:46 +08:00
parent 3983881d4e
commit e3071eaa60
4 changed files with 10 additions and 7 deletions

View file

@ -751,7 +751,10 @@ impl SourceMap {
f: impl Fn(char) -> bool,
) -> Result<Span, SpanSnippetError> {
self.span_to_source(span, |s, start, _end| {
let n = s[..start].char_indices().rfind(|&(_, c)| !f(c)).map_or(start, |(i, _)| start - i - 1);
let n = s[..start]
.char_indices()
.rfind(|&(_, c)| !f(c))
.map_or(start, |(i, _)| start - i - 1);
Ok(span.with_lo(span.lo() - BytePos(n as u32)))
})
}