Skip to content

feat: add diagnostic for E0422#22393

Open
WeiTheShinobi wants to merge 1 commit into
rust-lang:masterfrom
WeiTheShinobi:e0422
Open

feat: add diagnostic for E0422#22393
WeiTheShinobi wants to merge 1 commit into
rust-lang:masterfrom
WeiTheShinobi:e0422

Conversation

@WeiTheShinobi
Copy link
Copy Markdown
Contributor

Related to #22140

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 17, 2026
// Find the relevant variant
let (adt_ty, Some(variant)) = self.resolve_variant(expr.into(), path, false) else {
// FIXME: Emit an error.
self.push_diagnostic(InferenceDiagnostic::UnresolvedRecordExpr { expr });
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 17, 2026

Choose a reason for hiding this comment

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

I know there was a FIXME, but I think the error should go inside resolve_variant(), which will also fix it for patterns.

View changes since the review

@@ -0,0 +1,45 @@
use either::Either;
use syntax::{AstNode, ast::Expr};
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 17, 2026

Choose a reason for hiding this comment

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

By convention we don't use specific ast nodes, instead we refer to them as ast::Node.

View changes since the review

"cannot find struct, variant or union type in this scope".to_owned(),
crate::adjusted_display_range(ctx, d.expr, &|expr| match expr {
Either::Left(Expr::RecordExpr(it)) => it.path().map(|p| p.syntax().text_range()),
_ => None,
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 17, 2026

Choose a reason for hiding this comment

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

If you emit the error in resolve_variant(), you also need to account for ast::Pat::{RecordPat,TupleStructPat}.

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants