Skip to content

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

Merged
bors merged 5 commits into
rust-lang:masterfrom
nnethercote:LitKind-Err-guar
Feb 15, 2024
Merged

bors merged 5 commits into
rust-lang:masterfrom
nnethercote:LitKind-Err-guar

Conversation

@nnethercote

Copy link
Copy Markdown
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

ghost commented Feb 15, 2024

Copy link
Copy Markdown
Collaborator

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

ghost commented Feb 15, 2024

Copy link
Copy Markdown
Contributor Author

cc @ShE3py @fmease @compiler-errors

@nnethercote

ghost commented Feb 15, 2024 •

Copy link
Copy Markdown
Contributor Author

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.


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

ghost Feb 15, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🎉

@nnethercote

ghost commented Feb 15, 2024

Copy link
Copy Markdown
Contributor Author

Best reviewed one commit at a time.

@rust-log-analyzer

This comment has been minimized.

Nicholas Nethercote added 3 commits February 15, 2024 12:58
`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.
Comment thread compiler/rustc_session/src/errors.rs Resolved
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.

ghost left a comment •

Copy link
Copy Markdown
Member

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

ghost commented Feb 15, 2024

Copy link
Copy Markdown
Member

@bors r+

@bors

ghost commented Feb 15, 2024

Copy link
Copy Markdown
Collaborator

📌 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
bors merged commit 06f53dd into rust-lang:master Feb 15, 2024
@rustbot rustbot added this to the 1.78.0 milestone Feb 15, 2024
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