Skip to content

Commit 206e86b

Browse files
committed
Rollup merge of #31721 - rphmeier:err_tuplestruct_count, r=Manishearth
Fixes #31706 Also fixes a phrasing error in the diagnostic.
2 parents 28a3e8b + 94499e3 commit 206e86b

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/librustc_privacy/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ let f = Bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `Bar::Foo`
205205
// is private
206206
```
207207
208-
To fix this error, please ensure that all the fields of the struct, or
209-
implement a function for easy instantiation. Examples:
208+
To fix this error, please ensure that all the fields of the struct are public,
209+
or implement a function for easy instantiation. Examples:
210210
211211
```
212212
mod Bar {

src/librustc_privacy/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
833833
NamedField(name) => format!("field `{}` of {} is private",
834834
name, struct_desc),
835835
UnnamedField(idx) => format!("field #{} of {} is private",
836-
idx + 1, struct_desc),
836+
idx, struct_desc),
837837
};
838838
span_err!(self.tcx.sess, span, E0451,
839839
"{}", &msg[..]);

src/test/compile-fail/privacy5.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,25 @@ fn this_crate() {
6363
let c = a::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
6464
let d = a::D(4);
6565

66-
let a::A(()) = a; //~ ERROR: field #1 of struct `a::A` is private
66+
let a::A(()) = a; //~ ERROR: field #0 of struct `a::A` is private
6767
let a::A(_) = a;
68-
match a { a::A(()) => {} } //~ ERROR: field #1 of struct `a::A` is private
68+
match a { a::A(()) => {} } //~ ERROR: field #0 of struct `a::A` is private
6969
match a { a::A(_) => {} }
7070

7171
let a::B(_) = b;
72-
let a::B(_b) = b; //~ ERROR: field #1 of struct `a::B` is private
72+
let a::B(_b) = b; //~ ERROR: field #0 of struct `a::B` is private
7373
match b { a::B(_) => {} }
74-
match b { a::B(_b) => {} } //~ ERROR: field #1 of struct `a::B` is private
75-
match b { a::B(1) => {} a::B(_) => {} } //~ ERROR: field #1 of struct `a::B` is private
74+
match b { a::B(_b) => {} } //~ ERROR: field #0 of struct `a::B` is private
75+
match b { a::B(1) => {} a::B(_) => {} } //~ ERROR: field #0 of struct `a::B` is private
7676

7777
let a::C(_, _) = c;
7878
let a::C(_a, _) = c;
79-
let a::C(_, _b) = c; //~ ERROR: field #2 of struct `a::C` is private
80-
let a::C(_a, _b) = c; //~ ERROR: field #2 of struct `a::C` is private
79+
let a::C(_, _b) = c; //~ ERROR: field #1 of struct `a::C` is private
80+
let a::C(_a, _b) = c; //~ ERROR: field #1 of struct `a::C` is private
8181
match c { a::C(_, _) => {} }
8282
match c { a::C(_a, _) => {} }
83-
match c { a::C(_, _b) => {} } //~ ERROR: field #2 of struct `a::C` is private
84-
match c { a::C(_a, _b) => {} } //~ ERROR: field #2 of struct `a::C` is private
83+
match c { a::C(_, _b) => {} } //~ ERROR: field #1 of struct `a::C` is private
84+
match c { a::C(_a, _b) => {} } //~ ERROR: field #1 of struct `a::C` is private
8585

8686
let a::D(_) = d;
8787
let a::D(_d) = d;
@@ -101,30 +101,30 @@ fn xcrate() {
101101
let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
102102
let d = other::D(4);
103103

104-
let other::A(()) = a; //~ ERROR: field #1 of struct `other::A` is private
104+
let other::A(()) = a; //~ ERROR: field #0 of struct `other::A` is private
105105
let other::A(_) = a;
106106
match a { other::A(()) => {} }
107-
//~^ ERROR: field #1 of struct `other::A` is private
107+
//~^ ERROR: field #0 of struct `other::A` is private
108108
match a { other::A(_) => {} }
109109

110110
let other::B(_) = b;
111-
let other::B(_b) = b; //~ ERROR: field #1 of struct `other::B` is private
111+
let other::B(_b) = b; //~ ERROR: field #0 of struct `other::B` is private
112112
match b { other::B(_) => {} }
113113
match b { other::B(_b) => {} }
114-
//~^ ERROR: field #1 of struct `other::B` is private
114+
//~^ ERROR: field #0 of struct `other::B` is private
115115
match b { other::B(1) => {} other::B(_) => {} }
116-
//~^ ERROR: field #1 of struct `other::B` is private
116+
//~^ ERROR: field #0 of struct `other::B` is private
117117

118118
let other::C(_, _) = c;
119119
let other::C(_a, _) = c;
120-
let other::C(_, _b) = c; //~ ERROR: field #2 of struct `other::C` is private
121-
let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `other::C` is private
120+
let other::C(_, _b) = c; //~ ERROR: field #1 of struct `other::C` is private
121+
let other::C(_a, _b) = c; //~ ERROR: field #1 of struct `other::C` is private
122122
match c { other::C(_, _) => {} }
123123
match c { other::C(_a, _) => {} }
124124
match c { other::C(_, _b) => {} }
125-
//~^ ERROR: field #2 of struct `other::C` is private
125+
//~^ ERROR: field #1 of struct `other::C` is private
126126
match c { other::C(_a, _b) => {} }
127-
//~^ ERROR: field #2 of struct `other::C` is private
127+
//~^ ERROR: field #1 of struct `other::C` is private
128128

129129
let other::D(_) = d;
130130
let other::D(_d) = d;

0 commit comments

Comments
 (0)