Skip to content

Commit 854b78f

Browse files
committed
Normalize wording of privacy access labels
1 parent 94bbd46 commit 854b78f

File tree

89 files changed

+370
-332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+370
-332
lines changed

src/librustc_privacy/lib.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> {
10381038
def.variant_descr(),
10391039
self.tcx.def_path_str(def.did)
10401040
)
1041-
.span_label(span, format!("field `{}` is private", field.ident))
1041+
.span_label(span, "private field")
10421042
.emit();
10431043
}
10441044
}
@@ -1180,7 +1180,11 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> {
11801180
fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool {
11811181
let is_error = !self.item_is_accessible(def_id);
11821182
if is_error {
1183-
self.tcx.sess.span_err(self.span, &format!("{} `{}` is private", kind, descr));
1183+
self.tcx
1184+
.sess
1185+
.struct_span_err(self.span, &format!("{} `{}` is private", kind, descr))
1186+
.span_label(self.span, &format!("private {}", kind))
1187+
.emit();
11841188
}
11851189
is_error
11861190
}
@@ -1313,8 +1317,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
13131317
hir::QPath::Resolved(_, ref path) => path.to_string(),
13141318
hir::QPath::TypeRelative(_, ref segment) => segment.ident.to_string(),
13151319
};
1316-
let msg = format!("{} `{}` is private", kind.descr(def_id), name);
1317-
self.tcx.sess.span_err(span, &msg);
1320+
let kind = kind.descr(def_id);
1321+
self.tcx
1322+
.sess
1323+
.struct_span_err(span, &format!("{} `{}` is private", kind, name))
1324+
.span_label(span, &format!("private {}", kind))
1325+
.emit();
13181326
return;
13191327
}
13201328
}

src/librustc_resolve/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ impl<'a> Resolver<'a> {
952952
let descr = get_descr(binding);
953953
let mut err =
954954
struct_span_err!(self.session, ident.span, E0603, "{} `{}` is private", descr, ident);
955-
err.span_label(ident.span, &format!("this {} is private", descr));
955+
err.span_label(ident.span, &format!("private {}", descr));
956956
if let Some(span) = ctor_fields_span {
957957
err.span_label(span, "a constructor is private if any of the fields is private");
958958
}

src/librustc_resolve/late/diagnostics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,10 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
506506

507507
match (res, source) {
508508
(Res::Def(DefKind::Macro(MacroKind::Bang), _), _) => {
509-
err.span_suggestion(
510-
span,
509+
err.span_suggestion_verbose(
510+
span.shrink_to_hi(),
511511
"use `!` to invoke the macro",
512-
format!("{}!", path_str),
512+
"!".to_string(),
513513
Applicability::MaybeIncorrect,
514514
);
515515
if path_str == "try" && span.rust_2015() {

src/librustc_typeck/astconv.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,8 +1452,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
14521452
.expect("missing associated type");
14531453

14541454
if !assoc_ty.vis.is_accessible_from(def_scope, tcx) {
1455-
let msg = format!("associated type `{}` is private", binding.item_name);
1456-
tcx.sess.span_err(binding.span, &msg);
1455+
tcx.sess
1456+
.struct_span_err(
1457+
binding.span,
1458+
&format!("associated type `{}` is private", binding.item_name),
1459+
)
1460+
.span_label(binding.span, "private associated type")
1461+
.emit();
14571462
}
14581463
tcx.check_stability(assoc_ty.def_id, Some(hir_ref_id), binding.span);
14591464

@@ -2316,8 +2321,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
23162321

23172322
let kind = DefKind::AssocTy;
23182323
if !item.vis.is_accessible_from(def_scope, tcx) {
2319-
let msg = format!("{} `{}` is private", kind.descr(item.def_id), assoc_ident);
2320-
tcx.sess.span_err(span, &msg);
2324+
let kind = kind.descr(item.def_id);
2325+
let msg = format!("{} `{}` is private", kind, assoc_ident);
2326+
tcx.sess
2327+
.struct_span_err(span, &msg)
2328+
.span_label(span, &format!("private {}", kind))
2329+
.emit();
23212330
}
23222331
tcx.check_stability(item.def_id, Some(hir_ref_id), span);
23232332

src/librustc_typeck/check/method/suggest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,14 +769,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
769769
}
770770

771771
MethodError::PrivateMatch(kind, def_id, out_of_scope_traits) => {
772+
let kind = kind.descr(def_id);
772773
let mut err = struct_span_err!(
773774
self.tcx.sess,
774775
span,
775776
E0624,
776777
"{} `{}` is private",
777-
kind.descr(def_id),
778+
kind,
778779
item_name
779780
);
781+
err.span_label(span, &format!("private {}", kind));
780782
self.suggest_valid_traits(&mut err, out_of_scope_traits);
781783
err.emit();
782784
}

src/test/ui/associated-const/associated-const-private-impl.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0624]: associated constant `ID` is private
22
--> $DIR/associated-const-private-impl.rs:13:19
33
|
44
LL | assert_eq!(1, bar1::Foo::ID);
5-
| ^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^ private associated constant
66

77
error: aborting due to previous error
88

src/test/ui/error-codes/E0451.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0451]: field `b` of struct `bar::Foo` is private
22
--> $DIR/E0451.rs:14:21
33
|
44
LL | let bar::Foo{a, b} = foo;
5-
| ^ field `b` is private
5+
| ^ private field
66

77
error[E0451]: field `b` of struct `bar::Foo` is private
88
--> $DIR/E0451.rs:18:29
99
|
1010
LL | let f = bar::Foo{ a: 0, b: 0 };
11-
| ^^^^ field `b` is private
11+
| ^^^^ private field
1212

1313
error: aborting due to 2 previous errors
1414

src/test/ui/error-codes/E0603.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0603]: constant `PRIVATE` is private
22
--> $DIR/E0603.rs:6:17
33
|
44
LL | SomeModule::PRIVATE;
5-
| ^^^^^^^ this constant is private
5+
| ^^^^^^^ private constant
66
|
77
note: the constant `PRIVATE` is defined here
88
--> $DIR/E0603.rs:2:5

src/test/ui/error-codes/E0624.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0624]: associated function `method` is private
22
--> $DIR/E0624.rs:11:9
33
|
44
LL | foo.method();
5-
| ^^^^^^
5+
| ^^^^^^ private associated function
66

77
error: aborting due to previous error
88

src/test/ui/error-festival.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0603]: constant `FOO` is private
88
--> $DIR/error-festival.rs:22:10
99
|
1010
LL | foo::FOO;
11-
| ^^^ this constant is private
11+
| ^^^ private constant
1212
|
1313
note: the constant `FOO` is defined here
1414
--> $DIR/error-festival.rs:7:5

src/test/ui/explore-issue-38412.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,19 @@ error[E0624]: associated function `pub_crate` is private
8383
--> $DIR/explore-issue-38412.rs:50:7
8484
|
8585
LL | r.pub_crate();
86-
| ^^^^^^^^^
86+
| ^^^^^^^^^ private associated function
8787

8888
error[E0624]: associated function `pub_mod` is private
8989
--> $DIR/explore-issue-38412.rs:51:7
9090
|
9191
LL | r.pub_mod();
92-
| ^^^^^^^
92+
| ^^^^^^^ private associated function
9393

9494
error[E0624]: associated function `private` is private
9595
--> $DIR/explore-issue-38412.rs:52:7
9696
|
9797
LL | r.private();
98-
| ^^^^^^^
98+
| ^^^^^^^ private associated function
9999

100100
error[E0658]: use of unstable library feature 'unstable_undeclared'
101101
--> $DIR/explore-issue-38412.rs:57:7
@@ -119,19 +119,19 @@ error[E0624]: associated function `pub_crate` is private
119119
--> $DIR/explore-issue-38412.rs:63:7
120120
|
121121
LL | t.pub_crate();
122-
| ^^^^^^^^^
122+
| ^^^^^^^^^ private associated function
123123

124124
error[E0624]: associated function `pub_mod` is private
125125
--> $DIR/explore-issue-38412.rs:64:7
126126
|
127127
LL | t.pub_mod();
128-
| ^^^^^^^
128+
| ^^^^^^^ private associated function
129129

130130
error[E0624]: associated function `private` is private
131131
--> $DIR/explore-issue-38412.rs:65:7
132132
|
133133
LL | t.private();
134-
| ^^^^^^^
134+
| ^^^^^^^ private associated function
135135

136136
error: aborting due to 19 previous errors
137137

src/test/ui/export-import.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0603]: function `unexported` is private
22
--> $DIR/export-import.rs:1:8
33
|
44
LL | use m::unexported;
5-
| ^^^^^^^^^^ this function is private
5+
| ^^^^^^^^^^ private function
66
|
77
note: the function `unexported` is defined here
88
--> $DIR/export-import.rs:7:5

src/test/ui/export-tag-variant.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0603]: enum `Y` is private
22
--> $DIR/export-tag-variant.rs:7:26
33
|
44
LL | fn main() { let z = foo::Y::Y1; }
5-
| ^ this enum is private
5+
| ^ private enum
66
|
77
note: the enum `Y` is defined here
88
--> $DIR/export-tag-variant.rs:4:5

src/test/ui/export.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ error[E0603]: function `z` is private
2626
--> $DIR/export.rs:10:18
2727
|
2828
LL | fn main() { foo::z(10); }
29-
| ^ this function is private
29+
| ^ private function
3030
|
3131
note: the function `z` is defined here
3232
--> $DIR/export.rs:5:5

src/test/ui/extern/extern-crate-visibility.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0603]: crate import `core` is private
22
--> $DIR/extern-crate-visibility.rs:6:10
33
|
44
LL | use foo::core::cell;
5-
| ^^^^ this crate import is private
5+
| ^^^^ private crate import
66
|
77
note: the crate import `core` is defined here
88
--> $DIR/extern-crate-visibility.rs:2:5
@@ -14,7 +14,7 @@ error[E0603]: crate import `core` is private
1414
--> $DIR/extern-crate-visibility.rs:9:10
1515
|
1616
LL | foo::core::cell::Cell::new(0);
17-
| ^^^^ this crate import is private
17+
| ^^^^ private crate import
1818
|
1919
note: the crate import `core` is defined here
2020
--> $DIR/extern-crate-visibility.rs:2:5

src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0451]: field `secret_uid` of struct `foo::S` is private
22
--> $DIR/functional-struct-update-respects-privacy.rs:28:49
33
|
44
LL | let s_2 = foo::S { b: format!("ess two"), ..s_1 }; // FRU ...
5-
| ^^^ field `secret_uid` is private
5+
| ^^^ private field
66

77
error: aborting due to previous error
88

src/test/ui/hygiene/fields.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: type `foo::S` is private
22
--> $DIR/fields.rs:15:17
33
|
44
LL | let s = S { x: 0 };
5-
| ^^^^^^^^^^
5+
| ^^^^^^^^^^ private type
66
...
77
LL | let s = foo::m!(S, x);
88
| ------------- in this macro invocation
@@ -13,7 +13,7 @@ error: type `foo::S` is private
1313
--> $DIR/fields.rs:16:17
1414
|
1515
LL | let _ = s.x;
16-
| ^
16+
| ^ private type
1717
...
1818
LL | let s = foo::m!(S, x);
1919
| ------------- in this macro invocation
@@ -24,7 +24,7 @@ error: type `foo::T` is private
2424
--> $DIR/fields.rs:18:17
2525
|
2626
LL | let t = T(0);
27-
| ^^^^
27+
| ^^^^ private type
2828
...
2929
LL | let s = foo::m!(S, x);
3030
| ------------- in this macro invocation
@@ -35,7 +35,7 @@ error: type `foo::T` is private
3535
--> $DIR/fields.rs:19:17
3636
|
3737
LL | let _ = t.0;
38-
| ^
38+
| ^ private type
3939
...
4040
LL | let s = foo::m!(S, x);
4141
| ------------- in this macro invocation

src/test/ui/hygiene/impl_items.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
22
--> $DIR/impl_items.rs:12:23
33
|
44
LL | let _: () = S.f();
5-
| ^
5+
| ^ private type
66
...
77
LL | foo::m!();
88
| ---------- in this macro invocation

src/test/ui/hygiene/intercrate.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: type `fn() -> u32 {intercrate::foo::bar::f}` is private
22
--> $DIR/intercrate.rs:10:16
33
|
44
LL | assert_eq!(intercrate::foo::m!(), 1);
5-
| ^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^ private type
66
|
77
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
88

src/test/ui/hygiene/privacy.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0603]: function `f` is private
22
--> $DIR/privacy.rs:16:14
33
|
44
LL | foo::f()
5-
| ^ this function is private
5+
| ^ private function
66
|
77
note: the function `f` is defined here
88
--> $DIR/privacy.rs:4:5

src/test/ui/hygiene/rustc-macro-transparency.stderr

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ error[E0423]: expected value, found macro `semitransparent`
88
--> $DIR/rustc-macro-transparency.rs:29:5
99
|
1010
LL | semitransparent;
11-
| ^^^^^^^^^^^^^^^ help: use `!` to invoke the macro: `semitransparent!`
11+
| ^^^^^^^^^^^^^^^
12+
|
13+
help: use `!` to invoke the macro
14+
|
15+
LL | semitransparent!;
16+
| ^
1217

1318
error[E0423]: expected value, found macro `opaque`
1419
--> $DIR/rustc-macro-transparency.rs:30:5
1520
|
1621
LL | opaque;
17-
| ^^^^^^ help: use `!` to invoke the macro: `opaque!`
22+
| ^^^^^^
23+
|
24+
help: use `!` to invoke the macro
25+
|
26+
LL | opaque!;
27+
| ^
1828

1929
error: aborting due to 3 previous errors
2030

src/test/ui/import.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error[E0603]: unresolved item import `foo` is private
1717
--> $DIR/import.rs:15:10
1818
|
1919
LL | zed::foo();
20-
| ^^^ this unresolved item import is private
20+
| ^^^ private unresolved item import
2121
|
2222
note: the unresolved item import `foo` is defined here
2323
--> $DIR/import.rs:10:9

src/test/ui/imports/issue-55884-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0603]: struct import `ParseOptions` is private
22
--> $DIR/issue-55884-2.rs:12:17
33
|
44
LL | pub use parser::ParseOptions;
5-
| ^^^^^^^^^^^^ this struct import is private
5+
| ^^^^^^^^^^^^ private struct import
66
|
77
note: the struct import `ParseOptions` is defined here...
88
--> $DIR/issue-55884-2.rs:9:9

src/test/ui/imports/reexports.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error[E0603]: module import `foo` is private
1414
--> $DIR/reexports.rs:33:15
1515
|
1616
LL | use b::a::foo::S;
17-
| ^^^ this module import is private
17+
| ^^^ private module import
1818
|
1919
note: the module import `foo` is defined here...
2020
--> $DIR/reexports.rs:21:17
@@ -31,7 +31,7 @@ error[E0603]: module import `foo` is private
3131
--> $DIR/reexports.rs:34:15
3232
|
3333
LL | use b::b::foo::S as T;
34-
| ^^^ this module import is private
34+
| ^^^ private module import
3535
|
3636
note: the module import `foo` is defined here...
3737
--> $DIR/reexports.rs:26:17

src/test/ui/imports/unresolved-imports-used.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ error[E0603]: function `quz` is private
3838
--> $DIR/unresolved-imports-used.rs:9:10
3939
|
4040
LL | use qux::quz;
41-
| ^^^ this function is private
41+
| ^^^ private function
4242
|
4343
note: the function `quz` is defined here
4444
--> $DIR/unresolved-imports-used.rs:5:4

0 commit comments

Comments
 (0)