Skip to content

Commit

Permalink
Reexport -> re-export in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Jan 15, 2018
1 parent c698496 commit 90fcd44
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ declare_lint! {
declare_lint! {
pub PUB_USE_OF_PRIVATE_EXTERN_CRATE,
Deny,
"detect public reexports of private extern crates"
"detect public re-exports of private extern crates"
}

declare_lint! {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ impl<'a> Resolver<'a> {
let (def, vis) = (binding.def(), binding.vis);
self.macro_exports.push(Export { ident, def, vis, span, is_import: true });
} else {
span_err!(self.session, span, E0470, "reexported macro not found");
span_err!(self.session, span, E0470, "re-exported macro not found");
}
}
used
Expand Down Expand Up @@ -729,7 +729,7 @@ impl<'a> Resolver<'a> {
}
} else if attr.check_name("macro_reexport") {
let bad_macro_reexport = |this: &mut Self, span| {
span_err!(this.session, span, E0467, "bad macro reexport");
span_err!(this.session, span, E0467, "bad macro re-export");
};
if let Some(names) = attr.meta_item_list() {
for attr in names {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ arguments.
"##,

E0467: r##"
Macro reexport declarations were empty or malformed.
Macro re-export declarations were empty or malformed.
Erroneous code examples:
Expand All @@ -1389,12 +1389,12 @@ extern crate core as other_macros_for_good;
This is a syntax error at the level of attribute declarations.
Currently, `macro_reexport` requires at least one macro name to be listed.
Unlike `macro_use`, listing no names does not reexport all macros from the
Unlike `macro_use`, listing no names does not re-export all macros from the
given crate.
Decide which macros you would like to export and list them properly.
These are proper reexport declarations:
These are proper re-export declarations:
```ignore (cannot-doctest-multicrate-project)
#[macro_reexport(some_macro, another_macro)]
Expand Down Expand Up @@ -1475,7 +1475,7 @@ extern crate some_crate; //ok!
"##,

E0470: r##"
A macro listed for reexport was not found.
A macro listed for re-export was not found.
Erroneous code example:
Expand All @@ -1493,7 +1493,7 @@ exported from the given crate.
This could be caused by a typo. Did you misspell the macro's name?
Double-check the names of the macros listed for reexport, and that the crate
Double-check the names of the macros listed for re-export, and that the crate
in question exports them.
A working version:
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2751,7 +2751,7 @@ impl<'a> Resolver<'a> {
let lint = lint::builtin::LEGACY_CONSTRUCTOR_VISIBILITY;
self.session.buffer_lint(lint, id, span,
"private struct constructors are not usable through \
reexports in outer modules",
re-exports in outer modules",
);
res = Some(PathResolution::new(ctor_def));
}
Expand Down
15 changes: 8 additions & 7 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,21 +803,22 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
if !any_successful_reexport {
let (ns, binding) = reexport_error.unwrap();
if ns == TypeNS && binding.is_extern_crate() {
let msg = format!("extern crate `{}` is private, and cannot be reexported \
(error E0365), consider declaring with `pub`",
let msg = format!("extern crate `{}` is private, and cannot be \
re-exported (error E0365), consider declaring with \
`pub`",
ident);
self.session.buffer_lint(PUB_USE_OF_PRIVATE_EXTERN_CRATE,
directive.id,
directive.span,
&msg);
} else if ns == TypeNS {
struct_span_err!(self.session, directive.span, E0365,
"`{}` is private, and cannot be reexported", ident)
.span_label(directive.span, format!("reexport of private `{}`", ident))
"`{}` is private, and cannot be re-exported", ident)
.span_label(directive.span, format!("re-export of private `{}`", ident))
.note(&format!("consider declaring type or module `{}` with `pub`", ident))
.emit();
} else {
let msg = format!("`{}` is private, and cannot be reexported", ident);
let msg = format!("`{}` is private, and cannot be re-exported", ident);
let note_msg =
format!("consider marking `{}` as `pub` in the imported module", ident);
struct_span_err!(self.session, directive.span, E0364, "{}", &msg)
Expand Down Expand Up @@ -932,12 +933,12 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
!orig_binding.vis.is_at_least(binding.vis, &*self) {
let msg = match directive.subclass {
ImportDirectiveSubclass::SingleImport { .. } => {
format!("variant `{}` is private and cannot be reexported",
format!("variant `{}` is private and cannot be re-exported",
ident)
},
ImportDirectiveSubclass::GlobImport { .. } => {
let msg = "enum is private and its variants \
cannot be reexported".to_owned();
cannot be re-exported".to_owned();
let error_id = (DiagnosticMessageId::ErrorId(0), // no code?!
Some(binding.span),
msg.clone());
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::ItemKind::ExternCrate(_) => {
if let Some(attr) = attr::find_by_name(&i.attrs[..], "macro_reexport") {
gate_feature_post!(&self, macro_reexport, attr.span,
"macros reexports are experimental \
"macros re-exports are experimental \
and possibly buggy");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail-fulldeps/gated-macro-reexports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
#![crate_type = "dylib"]

#[macro_reexport(reexported)]
//~^ ERROR macros reexports are experimental and possibly buggy
//~^ ERROR macros re-exports are experimental and possibly buggy
#[macro_use] #[no_link]
extern crate macro_reexport_1;
2 changes: 1 addition & 1 deletion src/test/compile-fail/E0365.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ mod foo {
}

pub use foo as foo2;
//~^ ERROR `foo` is private, and cannot be reexported [E0365]
//~^ ERROR `foo` is private, and cannot be re-exported [E0365]

fn main() {}
8 changes: 4 additions & 4 deletions src/test/compile-fail/imports/reexports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod a {
mod foo {}

mod a {
pub use super::foo; //~ ERROR cannot be reexported
pub use super::foo; //~ ERROR cannot be re-exported
pub use super::*; //~ ERROR must import something with the glob's visibility
}
}
Expand All @@ -24,17 +24,17 @@ mod b {

pub mod a {
pub use super::foo; // This is OK since the value `foo` is visible enough.
fn f(_: foo::S) {} // `foo` is imported in the type namespace (but not `pub` reexported).
fn f(_: foo::S) {} // `foo` is imported in the type namespace (but not `pub` re-exported).
}

pub mod b {
pub use super::*; // This is also OK since the value `foo` is visible enough.
fn f(_: foo::S) {} // Again, the module `foo` is imported (but not `pub` reexported).
fn f(_: foo::S) {} // Again, the module `foo` is imported (but not `pub` re-exported).
}
}

mod c {
// Test that `foo` is not reexported.
// Test that `foo` is not re-exported.
use b::a::foo::S; //~ ERROR `foo`
use b::b::foo::S as T; //~ ERROR `foo`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

mod rank {
pub use self::Professor::*;
//~^ ERROR enum is private and its variants cannot be reexported
//~^ ERROR enum is private and its variants cannot be re-exported
pub use self::Lieutenant::{JuniorGrade, Full};
//~^ ERROR variant `JuniorGrade` is private and cannot be reexported
//~| ERROR variant `Full` is private and cannot be reexported
//~^ ERROR variant `JuniorGrade` is private and cannot be re-exported
//~| ERROR variant `Full` is private and cannot be re-exported
pub use self::PettyOfficer::*;
//~^ ERROR enum is private and its variants cannot be reexported
//~^ ERROR enum is private and its variants cannot be re-exported
pub use self::Crewman::*;
//~^ ERROR enum is private and its variants cannot be reexported
//~^ ERROR enum is private and its variants cannot be re-exported

enum Professor {
Adjunct,
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/macro-reexport-malformed-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
#![feature(macro_reexport)]

#[allow(unused_extern_crates)]
#[macro_reexport] //~ ERROR bad macro reexport
#[macro_reexport] //~ ERROR bad macro re-export
extern crate std;
2 changes: 1 addition & 1 deletion src/test/compile-fail/macro-reexport-malformed-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
#![feature(macro_reexport)]

#[allow(unused_extern_crates)]
#[macro_reexport="foo"] //~ ERROR bad macro reexport
#[macro_reexport="foo"] //~ ERROR bad macro re-export
extern crate std;
2 changes: 1 addition & 1 deletion src/test/compile-fail/macro-reexport-malformed-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
#![feature(macro_reexport)]

#[allow(unused_extern_crates)]
#[macro_reexport(foo="bar")] //~ ERROR bad macro reexport
#[macro_reexport(foo="bar")] //~ ERROR bad macro re-export
extern crate std;
2 changes: 1 addition & 1 deletion src/test/compile-fail/macro-reexport-undef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![feature(macro_reexport)]

#[macro_use(macro_two)]
#[macro_reexport(no_way)] //~ ERROR reexported macro not found
#[macro_reexport(no_way)] //~ ERROR re-exported macro not found
extern crate two_macros;

pub fn main() {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/privacy/legacy-ctor-visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-tidy-linelength

#![allow(unused)]

use m::S;
Expand All @@ -19,7 +21,7 @@ mod m {
use S;
fn f() {
S(10);
//~^ ERROR private struct constructors are not usable through reexports in outer modules
//~^ ERROR private struct constructors are not usable through re-exports in outer modules
//~| WARN this was previously accepted
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/privacy/restricted/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod foo {
fn f() {
use foo::bar::S;
pub(self) use foo::bar::f; // ok
pub(super) use foo::bar::f as g; //~ ERROR cannot be reexported
pub(super) use foo::bar::f as g; //~ ERROR cannot be re-exported
S::default().x; // ok
S::default().f(); // ok
S::g(); // ok
Expand Down
8 changes: 4 additions & 4 deletions src/test/compile-fail/private-variant-reexport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
// except according to those terms.

mod m1 {
pub use ::E::V; //~ ERROR variant `V` is private and cannot be reexported
pub use ::E::V; //~ ERROR variant `V` is private and cannot be re-exported
}

mod m2 {
pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be reexported
pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be re-exported
}

mod m3 {
pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be reexported
pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be re-exported
}

mod m4 {
pub use ::E::*; //~ ERROR enum is private and its variants cannot be reexported
pub use ::E::*; //~ ERROR enum is private and its variants cannot be re-exported
}

enum E { V }
Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/pub-reexport-priv-extern-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
#![allow(unused)]

extern crate core;
pub use core as reexported_core; //~ ERROR `core` is private, and cannot be reexported
pub use core as reexported_core; //~ ERROR `core` is private, and cannot be re-exported
//~^ WARN this was previously accepted

mod foo1 {
extern crate core;
}

mod foo2 {
use foo1::core; //~ ERROR `core` is private, and cannot be reexported
use foo1::core; //~ ERROR `core` is private, and cannot be re-exported
//~^ WARN this was previously accepted
pub mod bar {
extern crate core;
}
}

mod baz {
pub use foo2::bar::core; //~ ERROR `core` is private, and cannot be reexported
pub use foo2::bar::core; //~ ERROR `core` is private, and cannot be re-exported
//~^ WARN this was previously accepted
}

Expand Down

0 comments on commit 90fcd44

Please sign in to comment.