1
Fork 0

Assign E0784 to union expression error

This commit is contained in:
Guillaume Gomez 2021-08-02 16:33:37 +02:00
parent 76d247c00a
commit c364a4e30f
3 changed files with 41 additions and 2 deletions

View file

@ -1304,7 +1304,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Make sure the programmer specified correct number of fields.
if kind_name == "union" {
if ast_fields.len() != 1 {
tcx.sess.span_err(span, "union expressions should have exactly one field");
struct_span_err!(
tcx.sess,
span,
E0784,
"union expressions should have exactly one field",
)
.emit();
}
} else if check_completeness && !error_happened && !remaining_fields.is_empty() {
let no_accessible_remaining_fields = remaining_fields