Skip to content

Commit

Permalink
Improve error for missing expression in struct update syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed May 26, 2023
1 parent 1221e43 commit 71cde38
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ast_lowering_bad_return_type_notation_output =
ast_lowering_base_expression_double_dot =
base expression required after `..`
.label = add a base expression here
.suggestion = using struct update syntax requires a base expression of the same type
ast_lowering_clobber_abi_not_supported =
`clobber_abi` is not supported on this target
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub struct UnderscoreExprLhsAssign {
pub struct BaseExpressionDoubleDot {
#[primary_span]
#[label]
#[suggestion(code = "/* expr */", applicability = "has-placeholders", style = "verbose")]
pub span: Span,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ error: base expression required after `..`
|
LL | Struct { a, .. };
| ^ add a base expression here
|
help: using struct update syntax requires a base expression of the same type
|
LL | Struct { a, ../* expr */ };
| ++++++++++

error[E0026]: struct `Struct` does not have a field named `c`
--> $DIR/struct_destructure_fail.rs:10:20
Expand Down

0 comments on commit 71cde38

Please sign in to comment.