Fixes #63976. Incorrect error message.

Fix incorrect error message when accessing
private field of union
This commit is contained in:
Sam Radhakrishan 2019-08-29 02:43:09 +05:30
parent c4223726c3
commit fdd8b967c1

View File

@ -1396,8 +1396,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx().sess,
expr.span,
E0616,
"field `{}` of struct `{}` is private",
"field `{}` of `{}` `{}` is private",
field,
if let Some(def_kind) = self.tcx().def_kind(base_did){ def_kind.descr(base_did) }
else { " " },
struct_path
);
// Also check if an accessible method exists, which is often what is meant.