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

Conversation

nnethercote
Copy link
Contributor

Similar to recent work doing the same for ExprKind::Err (#120586) and TyKind::Err (#121109).

r? @oli-obk

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 15, 2024
@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2024

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

@nnethercote
Copy link
Contributor Author

cc @ShE3py @fmease @compiler-errors

@nnethercote
Copy link
Contributor Author

nnethercote commented Feb 15, 2024

Note: I didn't add Dummy variants to either of the LitKind enums, because they weren't necessary. Although there are changes to four "dummy" values in rust-analyzer, those dummies aren't true dummies. Rather, the code to produce the appropriate TyKind simply isn't implemented yet. So I just used Integer which works fine.

@@ -31,7 +31,6 @@ pub fn escape_byte_str_symbol(bytes: &[u8]) -> Symbol {

#[derive(Debug)]
pub enum LitError {
LexerError,
Copy link
Member

Choose a reason for hiding this comment

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

🎉

@nnethercote
Copy link
Contributor Author

Best reviewed one commit at a time.

@rust-log-analyzer

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.
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.
To avoid some unwrapping.
Copy link
Member

@fmease fmease left a 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

@fmease fmease assigned fmease and unassigned oli-obk Feb 15, 2024
@fmease
Copy link
Member

fmease commented Feb 15, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Feb 15, 2024

📌 Commit ac47f6c has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 15, 2024
…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
@bors bors merged commit 06f53dd into rust-lang:master Feb 15, 2024
11 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 15, 2024
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`
@rustbot rustbot added this to the 1.78.0 milestone Feb 15, 2024
@nnethercote nnethercote deleted the LitKind-Err-guar branch February 15, 2024 20:40
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 26, 2024
…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`
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 28, 2024
…, 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`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 28, 2024
…, 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``
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 29, 2024
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``
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 7, 2024
…, 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``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants