Fix FormatArgsExpn parsing of FormatSpec positions
This commit is contained in:
parent
1b245e7e0e
commit
bd9d375c6b
@ -7,7 +7,7 @@ use crate::visitors::expr_visitor_no_bodies;
|
||||
use arrayvec::ArrayVec;
|
||||
use itertools::{izip, Either, Itertools};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::intravisit::{walk_expr, Visitor};
|
||||
use rustc_hir::{self as hir, Expr, ExprField, ExprKind, HirId, Node, QPath};
|
||||
use rustc_lexer::unescape::unescape_literal;
|
||||
use rustc_lexer::{tokenize, unescape, LiteralKind, TokenKind};
|
||||
@ -515,7 +515,7 @@ impl<'tcx> Visitor<'tcx> for ParamPosition {
|
||||
sym::width => {
|
||||
self.width = parse_count(field.expr);
|
||||
},
|
||||
_ => {},
|
||||
_ => walk_expr(self, field.expr),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ fn main() {
|
||||
eprintln!("with {} {}", 2, value);
|
||||
eprintln!("with {value}");
|
||||
eprintln!("macro arg {}", one!());
|
||||
let width = 2;
|
||||
eprintln!("{:w$}", value, w = width);
|
||||
}
|
||||
// these should not warn, different destination
|
||||
{
|
||||
|
@ -36,6 +36,8 @@ fn main() {
|
||||
writeln!(std::io::stderr(), "with {} {}", 2, value).unwrap();
|
||||
writeln!(std::io::stderr(), "with {value}").unwrap();
|
||||
writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
|
||||
let width = 2;
|
||||
writeln!(std::io::stderr(), "{:w$}", value, w = width).unwrap();
|
||||
}
|
||||
// these should not warn, different destination
|
||||
{
|
||||
|
@ -72,5 +72,11 @@ error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
LL | writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("macro arg {}", one!())`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
error: use of `writeln!(stderr(), ...).unwrap()`
|
||||
--> $DIR/explicit_write.rs:40:9
|
||||
|
|
||||
LL | writeln!(std::io::stderr(), "{:w$}", value, w = width).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{:w$}", value, w = width)`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user