Skip to content

Commit fdd8b96

Browse files
committed
Fixes #63976. Incorrect error message.
Fix incorrect error message when accessing private field of union
1 parent c422372 commit fdd8b96

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/librustc_typeck/check/expr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,8 +1396,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13961396
self.tcx().sess,
13971397
expr.span,
13981398
E0616,
1399-
"field `{}` of struct `{}` is private",
1399+
"field `{}` of `{}` `{}` is private",
14001400
field,
1401+
if let Some(def_kind) = self.tcx().def_kind(base_did){ def_kind.descr(base_did) }
1402+
else { " " },
14011403
struct_path
14021404
);
14031405
// Also check if an accessible method exists, which is often what is meant.

0 commit comments

Comments
 (0)