Trailing newlines affect spans #86076
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Trailing newlines affect the locations and spans of error messages. For instance:
produces (when compiling
test.rs
with rustc):Which is what I would expect. However, the same code with a trailing newline:
produces:
where the first error message points to nowhere (position
test.rs:1:10
does not exist), and the span of the second error message is too wide by one character. This initially confused me quite a bit, because it looks like an invisible character in the source file, or an issue with a multibyte character or something. I think that the trailing newline should either be ignored, or that the error should locate EOF in line 2 (and not 1, after the newline, which is attest.rs:1:9
).The text was updated successfully, but these errors were encountered: