-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Unuseful span in type error in some format_args!() invocations #140578
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-fmtArea: `core::fmt`Area: `core::fmt`D-imprecise-spansDiagnostics: spans don't point to exactly the erroneous codeDiagnostics: spans don't point to exactly the erroneous codeE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-fmtArea: `core::fmt`Area: `core::fmt`D-imprecise-spansDiagnostics: spans don't point to exactly the erroneous codeDiagnostics: spans don't point to exactly the erroneous codeE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The span of this error is useful:
However, in a slightly more complicated println, the same error points at the entire macro invocation:
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.