Skip to content
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

Add ErrorGuaranteed to ast::LitKind::Err, token::LitKind::Err. #121120

Merged
merged 5 commits into from
Feb 15, 2024

Commits on Feb 15, 2024

  1. Remove LitError::LexerError.

    `cook_lexer_literal` can emit an error about an invalid int literal but
    then return a non-`Err` token. And then `integer_lit` has to account for
    this to avoid printing a redundant error message.
    
    This commit changes `cook_lexer_literal` to return `Err` in that case.
    Then `integer_lit` doesn't need the special case, and
    `LitError::LexerError` can be removed.
    nnethercote committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    8b35f8e View commit details
    Browse the repository at this point in the history
  2. Make report_lit_error return ErrorGuaranteed.

    This will be helpful for subsequent commits.
    nnethercote committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    a513bb2 View commit details
    Browse the repository at this point in the history
  3. Make emit_unescape_error return Option<ErrorGuaranteed>.

    And use the result in `cook_common` to decide whether to return an error
    token.
    nnethercote committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    332c577 View commit details
    Browse the repository at this point in the history
  4. Add ErrorGuaranteed to ast::LitKind::Err, token::LitKind::Err.

    This mostly works well, and eliminates a couple of delayed bugs.
    
    One annoying thing is that we should really also add an
    `ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's
    difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`,
    so we have to fake it.
    nnethercote committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    25ed6e4 View commit details
    Browse the repository at this point in the history
  5. Add suffixes to LitError.

    To avoid some unwrapping.
    nnethercote committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    ac47f6c View commit details
    Browse the repository at this point in the history