{print,write}-with-newline: do not suggest empty format string
This commit is contained in:
parent
231444d989
commit
0261e341fd
5 changed files with 41 additions and 13 deletions
|
|
@ -322,11 +322,15 @@ impl EarlyLintPass for Write {
|
|||
}
|
||||
|
||||
/// Given a format string that ends in a newline and its span, calculates the span of the
|
||||
/// newline.
|
||||
/// newline, or the format string itself if the format string consists solely of a newline.
|
||||
fn newline_span(fmtstr: &StrLit) -> Span {
|
||||
let sp = fmtstr.span;
|
||||
let contents = &fmtstr.symbol.as_str();
|
||||
|
||||
if *contents == r"\n" {
|
||||
return sp;
|
||||
}
|
||||
|
||||
let newline_sp_hi = sp.hi()
|
||||
- match fmtstr.style {
|
||||
StrStyle::Cooked => BytePos(1),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue