Skip to content

lexer: show correct span on lexical errors #9298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

ben0x539
Copy link
Contributor

Previously, the lexer calling rdr.fatal(...) would report the span of
the last complete token, instead of a span within the erroneous token
(besides one span fixed in 1ac90bb).

This commit adds a few wrappers around rdr.fatal(...) that set the
span based on the StringReader's state, give or take, so that all
fatal errors in libsyntax/parse/lexer.rs can now report the offending
code more precisely. A number of tests try to verify that, though the
compile-fail testing setup can only check that the spans are on the
right lines, and the "unterminated string/block comment" errors can't
have the line marked at all, so that's incomplete.

Closes #9149.

Previously, the lexer calling `rdr.fatal(...)` would report the span of
the last complete token, instead of a span within the erroneous token
(besides one span fixed in 1ac90bb).

This commit adds a few wrappers around `rdr.fatal(...)` that set the
span based on the `StringReader`'s state, give or take, so that all
fatal errors in `libsyntax/parse/lexer.rs` can now report the offending
code more precisely. A number of tests try to verify that, though the
`compile-fail` testing setup can only check that the spans are on the
right lines, and the "unterminated string/block comment" errors can't
have the line marked at all, so that's incomplete.

Closes rust-lang#9149.
@ben0x539
Copy link
Contributor Author

After discussion in the IRC channel with Eridius, I see enough issues with my code to retract this PR for now.

@ben0x539 ben0x539 closed this Sep 18, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 30, 2023
Lint `mem_forget` if any fields are `Drop`

Closes rust-lang#9298
I think this way of doing it (`needs_drop`) should be fine.

---

changelog: Enhancement: [`mem_forget`]: Now lints on types with fields that implement `Drop`
[rust-lang#10996](rust-lang/rust-clippy#10996)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bad span on character literal errors
1 participant