about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSam Radhakrishan <sk09idm@gmail.com>2019-08-29 02:43:09 +0530
committerSam Radhakrishan <sk09idm@gmail.com>2019-08-29 02:48:36 +0530
commitfdd8b967c180192fb74bf17f07e2fda040bb9865 (patch)
treec4cee5cbdf7c74b396bc1f3142c8513b206733ec
parentc4223726c354642705d87b9837933e3c3f38a2d8 (diff)
downloadrust-fdd8b967c180192fb74bf17f07e2fda040bb9865.tar.gz
rust-fdd8b967c180192fb74bf17f07e2fda040bb9865.zip
Fixes #63976. Incorrect error message.
Fix incorrect error message when accessing
private field of union
-rw-r--r--src/librustc_typeck/check/expr.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs
index d139cd4264c..4943270e193 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.