From fdd8b967c180192fb74bf17f07e2fda040bb9865 Mon Sep 17 00:00:00 2001 From: Sam Radhakrishan Date: Thu, 29 Aug 2019 02:43:09 +0530 Subject: [PATCH] Fixes #63976. Incorrect error message. Fix incorrect error message when accessing private field of union --- src/librustc_typeck/check/expr.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index d139cd4264c8..4943270e193e 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -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.