-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
Note: I didn't add |
@@ -31,7 +31,6 @@ pub fn escape_byte_str_symbol(bytes: &[u8]) -> Symbol { | |||
|
|||
#[derive(Debug)] | |||
pub enum LitError { | |||
LexerError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Best reviewed one commit at a time. |
This comment has been minimized.
This comment has been minimized.
`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.
This will be helpful for subsequent commits.
And use the result in `cook_common` to decide whether to return an error token.
6caf605
to
57c7326
Compare
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.
57c7326
to
25ed6e4
Compare
To avoid some unwrapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating those variants, now I can sleep soundly :D
r=me when green
@bors r+ |
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#120449 (Document requirements for unsized {Rc,Arc}::from_raw) - rust-lang#120505 (Fix BTreeMap's Cursor::remove_{next,prev}) - rust-lang#120672 (std::thread update freebsd stack guard handling.) - rust-lang#121088 (Implicitly enable evex512 if avx512 is enabled) - rust-lang#121104 (Ignore unsized types when trying to determine the size of the original type) - rust-lang#121107 (Fix msg for verbose suggestions with confusable capitalization) - rust-lang#121113 (Continue compilation even if inherent impl checks fail) - rust-lang#121120 (Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#121120 - nnethercote:LitKind-Err-guar, r=fmease Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`. Similar to recent work doing the same for `ExprKind::Err` (rust-lang#120586) and `TyKind::Err` (rust-lang#121109). r? `@oli-obk`
…ease Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`. Similar to recent work doing the same for `ExprKind::Err` (rust-lang#120586) and `TyKind::Err` (rust-lang#121109). r? `@oli-obk`
…, r=fmease Use `LitKind::Err` for malformed floats rust-lang#121120 changed `StringReader::cook_lexer_literal` to return `LitKind::Err` for malformed integer literals. This commit does the same for float literals, for consistency. r? `@fmease`
…, r=fmease Use `LitKind::Err` for malformed floats rust-lang#121120 changed `StringReader::cook_lexer_literal` to return `LitKind::Err` for malformed integer literals. This commit does the same for float literals, for consistency. r? ``@fmease``
Rollup merge of rust-lang#121724 - nnethercote:LitKind-Err-for-floats, r=fmease Use `LitKind::Err` for malformed floats rust-lang#121120 changed `StringReader::cook_lexer_literal` to return `LitKind::Err` for malformed integer literals. This commit does the same for float literals, for consistency. r? ``@fmease``
…, r=fmease Use `LitKind::Err` for malformed floats rust-lang#121120 changed `StringReader::cook_lexer_literal` to return `LitKind::Err` for malformed integer literals. This commit does the same for float literals, for consistency. r? ``@fmease``
Similar to recent work doing the same for
ExprKind::Err
(#120586) andTyKind::Err
(#121109).r? @oli-obk