Skip to content

Make most lexer errors non-fatal #14388

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

Merged
merged 1 commit into from
May 24, 2014
Merged

Conversation

lilyball
Copy link
Contributor

Most errors that arise in the lexer can be recovered from. This allows
for more than one syntax error to be reported at a time.

c: char)
-> ! {
let mut m = m;
fn fatal_span_char<S: StrAllocating>(rdr: &mut StringReader,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StrAllocating trait is mostly just an implementation detail, and it's kinda sad to see it used here for this (maybe not a pattern we want to promote). Can this take &str for the same level of convenience?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could. I started with StrAllocating because I hadn't vetted every callsite to see if any allocated. It turns out none do. I'll go ahead and make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, my other thought was taking IntoMaybeOwned, but that would just end up being a proxy for StrAllocating because it would end up being let mut m = m.into_maybe_owned().into_strbuf().

Most errors that arise in the lexer can be recovered from. This allows
for more than one syntax error to be reported at a time.
@lilyball
Copy link
Contributor Author

Updated with @alexcrichton suggestion.

@alexcrichton
Copy link
Member

mmmm I love me some non-fatal errors

bors added a commit that referenced this pull request May 24, 2014
…chton

Most errors that arise in the lexer can be recovered from. This allows
for more than one syntax error to be reported at a time.
@bors bors closed this May 24, 2014
@bors bors merged commit 4c9dace into rust-lang:master May 24, 2014
@lilyball lilyball deleted the nonfatal_lexer_errors branch May 24, 2014 19:46
flip1995 added a commit to flip1995/rust that referenced this pull request Mar 20, 2025
Follow-up of rust-lang/rust-clippy#11421.

I can't yet make the annotations mandatory because there is an issue
with `tests/ui-internal/custom_ice_message.rs`: the error message is not
emitted as JSON, meaning that we can't match it with `ui_test`. I need
to check if it's a bug in rustc or if `ui_test` needs to handle this
case somehow.

changelog: Add missing tests annotations for `ui-internal`

r? @flip1995
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.

3 participants