Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
sam09 committed Aug 29, 2019
1 parent fdd8b96 commit 378c32b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/librustc_typeck/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,14 +1392,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
base_did: DefId,
) {
let struct_path = self.tcx().def_path_str(base_did);
let kind_name = match self.tcx().def_kind(base_did) {
Some(def_kind) => def_kind.descr(base_did),
_ => " ",
};
let mut err = struct_span_err!(
self.tcx().sess,
expr.span,
E0616,
"field `{}` of `{}` `{}` is private",
"field `{}` of {} `{}` is private",
field,
if let Some(def_kind) = self.tcx().def_kind(base_did){ def_kind.descr(base_did) }
else { " " },
kind_name,
struct_path
);
// Also check if an accessible method exists, which is often what is meant.
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/privacy/union-field-privacy-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ fn main() {

let a = u.a; // OK
let b = u.b; // OK
let c = u.c; //~ ERROR field `c` of struct `m::U` is private
let c = u.c; //~ ERROR field `c` of union `m::U` is private
}
2 changes: 1 addition & 1 deletion src/test/ui/privacy/union-field-privacy-2.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0616]: field `c` of struct `m::U` is private
error[E0616]: field `c` of union `m::U` is private
--> $DIR/union-field-privacy-2.rs:14:13
|
LL | let c = u.c;
Expand Down

0 comments on commit 378c32b

Please sign in to comment.