Skip to content

Commit e3c7798

Browse files
committed
fix up quotes, improve short messages, add notes
1 parent 173e2be commit e3c7798

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/librustc_resolve/diagnostics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ http://doc.rust-lang.org/reference.html#types
201201

202202
E0364: r##"
203203
Private items cannot be publicly re-exported. This error indicates
204-
that you attempted to write a 'pub use' against a type or value that was
204+
that you attempted to write a `pub use` against a type or value that was
205205
not itself public.
206206
207207
Here is an example that demonstrates the error:
@@ -214,7 +214,7 @@ pub use foo::X;
214214
```
215215
216216
The solution to this problem is to ensure that the items that you are
217-
re-exporting are themselves marked with 'pub':
217+
re-exporting are themselves marked with `pub`:
218218
219219
```
220220
mod foo {
@@ -223,15 +223,15 @@ mod foo {
223223
pub use foo::X;
224224
```
225225
226-
See the Use Declarations section of the reference for more information
226+
See the 'Use Declarations' section of the reference for more information
227227
on this topic:
228228
229229
http://doc.rust-lang.org/reference.html#use-declarations
230230
"##,
231231

232232
E0365: r##"
233233
Private modules cannot be publicly re-exported. This error indicates
234-
that you attempted to write a 'pub use' against a module that was
234+
that you attempted to write a `pub use` against a module that was
235235
not itself public.
236236
237237
Here is an example that demonstrates the error:
@@ -244,7 +244,7 @@ pub use foo as foo2;
244244
245245
```
246246
The solution to this problem is to ensure that the module that you are
247-
re-exporting is itself marked with 'pub':
247+
re-exporting is itself marked with `pub`:
248248
249249
```
250250
pub mod foo {
@@ -253,7 +253,7 @@ pub mod foo {
253253
pub use foo as foo2;
254254
```
255255
256-
See the Use Declarations section of the reference for more information
256+
See the 'Use Declarations' section of the reference for more information
257257
on this topic:
258258
259259
http://doc.rust-lang.org/reference.html#use-declarations

src/librustc_resolve/resolve_imports.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,11 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
431431
value_result = BoundResult(target_module.clone(),
432432
(*child_name_bindings).clone());
433433
if directive.is_public && !child_name_bindings.is_public(ValueNS) {
434-
let msg = format!("`{}` is private", token::get_name(source));
434+
let msg = format!("`{}` is private, and cannot be reexported", token::get_name(source));
435+
let note_msg = format!("Consider marking `{}` as pub in the imported module",
436+
token::get_name(source));
435437
span_err!(self.resolver.session, directive.span, E0364, "{}", &msg);
438+
self.resolver.session.span_note(directive.span, &note_msg);
436439
pub_err = true;
437440
}
438441
}
@@ -441,8 +444,11 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
441444
type_result = BoundResult(target_module.clone(),
442445
(*child_name_bindings).clone());
443446
if !pub_err && directive.is_public && !child_name_bindings.is_public(TypeNS) {
444-
let msg = format!("`{}` is private", token::get_name(source));
447+
let msg = format!("`{}` is private, and cannot be reexported", token::get_name(source));
448+
let note_msg = format!("Consider changing module {} so that it is declared as `pub mod`",
449+
token::get_name(source));
445450
span_err!(self.resolver.session, directive.span, E0365, "{}", &msg);
451+
self.resolver.session.span_note(directive.span, &note_msg);
446452
}
447453
}
448454
}

0 commit comments

Comments
 (0)