Description
The span of this error is useful:
error[E0282]: type annotations needed
|
# | println!("{:?}", []);
| ^^ cannot infer type
|
However, in a slightly more complicated println, the same error points at the entire macro invocation:
error[E0282]: type annotations needed
|
# | println!("{:?} {a} {a:?}", [], a = 1 + 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
It should have just pointed at []
(or perhaps {:?}
), rather than the entire macro call.
The simple println results in this case in format_args lowering:
rust/compiler/rustc_ast_lowering/src/format.rs
Lines 513 to 520 in cb0d6e7
The more complicated println results in this case in format_args lowering:
rust/compiler/rustc_ast_lowering/src/format.rs
Lines 538 to 547 in cb0d6e7
It'd be nice if both cases would cause any type/trait errors to be reported on the argument (or placeholders), instead of on the span of the entire macro invocation.
I'm not sure if this requires changes in rustc_ast_lowering, or in the code that reports the type errors.