diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index ea0e657f7edef..b63de78d1cc85 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -644,6 +644,16 @@ fn register_builtins(store: &mut LintStore) { ); store.register_removed("wasm_c_abi", "the wasm C ABI has been fixed"); store.register_removed("soft_unstable", "the general soft-unstable mechanism has been removed"); + store.register_removed( + "private_macro_use", + "converted into hard error, \ + see for more information", + ); + store.register_removed( + "pub_use_of_private_extern_crate", + "converted into hard error, \ + see for more information", + ); } fn register_internals(store: &mut LintStore) { diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 68a220a7224d4..94f69c840cf13 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -87,7 +87,6 @@ declare_lint_pass! { PRIVATE_BOUNDS, PRIVATE_INTERFACES, PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, - PUB_USE_OF_PRIVATE_EXTERN_CRATE, REDUNDANT_IMPORTS, REDUNDANT_LIFETIMES, REFINING_IMPL_TRAIT_INTERNAL, @@ -1291,40 +1290,6 @@ declare_lint! { "public interface leaks type from a private dependency" } -declare_lint! { - /// The `pub_use_of_private_extern_crate` lint detects a specific - /// situation of re-exporting a private `extern crate`. - /// - /// ### Example - /// - /// ```rust,compile_fail - /// extern crate core; - /// pub use core as reexported_core; - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// A public `use` declaration should not be used to publically re-export a - /// private `extern crate`. `pub extern crate` should be used instead. - /// - /// This was historically allowed, but is not the intended behavior - /// according to the visibility rules. This is a [future-incompatible] - /// lint to transition this to a hard error in the future. See [issue - /// #127909] for more details. - /// - /// [issue #127909]: https://github.com/rust-lang/rust/issues/127909 - /// [future-incompatible]: ../index.md#future-incompatible-lints - pub PUB_USE_OF_PRIVATE_EXTERN_CRATE, - Deny, - "detect public re-exports of private extern crates", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #127909), - report_in_deps: true, - }; -} - declare_lint! { /// The `invalid_type_param_default` lint detects type parameter defaults /// erroneously allowed in an invalid location. @@ -4910,53 +4875,6 @@ declare_lint! { }; } -declare_lint! { - /// The `private_macro_use` lint detects private macros that are imported - /// with `#[macro_use]`. - /// - /// ### Example - /// - /// ```rust,ignore (needs extern crate) - /// // extern_macro.rs - /// macro_rules! foo_ { () => {}; } - /// use foo_ as foo; - /// - /// // code.rs - /// - /// #![deny(private_macro_use)] - /// - /// #[macro_use] - /// extern crate extern_macro; - /// - /// fn main() { - /// foo!(); - /// } - /// ``` - /// - /// This will produce: - /// - /// ```text - /// error: cannot find macro `foo` in this scope - /// ``` - /// - /// ### Explanation - /// - /// This lint arises from overlooking visibility checks for macros - /// in an external crate. - /// - /// This is a [future-incompatible] lint to transition this to a - /// hard error in the future. - /// - /// [future-incompatible]: ../index.md#future-incompatible-lints - pub PRIVATE_MACRO_USE, - Deny, - "detects certain macro bindings that should not be re-exported", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #120192), - report_in_deps: true, - }; -} - declare_lint! { /// The `uncovered_param_in_projection` lint detects a violation of one of Rust's orphan rules for /// foreign trait implementations that concerns the use of type parameters inside trait associated diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 6310155154b95..ad346f8002cd2 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -1122,9 +1122,9 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { } } - let macro_use_import = |this: &Self, span, warn_private| { + let macro_use_import = |this: &Self, span| { this.r.arenas.alloc_import(ImportData { - kind: ImportKind::MacroUse { warn_private }, + kind: ImportKind::MacroUse, root_id: item.id, parent_scope: this.parent_scope, imported_module: CmCell::new(Some(ModuleOrUniformRoot::Module(module))), @@ -1142,22 +1142,12 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { let allow_shadowing = self.parent_scope.expansion == LocalExpnId::ROOT; if let Some(span) = import_all { - let import = macro_use_import(self, span, false); + let import = macro_use_import(self, span); self.r.potentially_unused_imports.push(import); module.for_each_child_mut(self, |this, ident, _, ns, binding| { - if ns == MacroNS { - let import = - if this.r.is_accessible_from(binding.vis(), this.parent_scope.module) { - import - } else { - // FIXME: This branch is used for reporting the `private_macro_use` lint - // and should eventually be removed. - if this.r.macro_use_prelude.contains_key(&ident.name) { - // Do not override already existing entries with compatibility entries. - return; - } - macro_use_import(this, span, true) - }; + if ns == MacroNS + && this.r.is_accessible_from(binding.vis(), this.parent_scope.module) + { let import_decl = this.r.new_import_decl(binding, import); this.add_macro_use_decl(ident.name, import_decl, span, allow_shadowing); } @@ -1172,7 +1162,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { None, ); if let Ok(binding) = result { - let import = macro_use_import(self, ident.span, false); + let import = macro_use_import(self, ident.span); self.r.potentially_unused_imports.push(import); let import_decl = self.r.new_import_decl(binding, import); self.add_macro_use_decl(ident.name, import_decl, ident.span, allow_shadowing); diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 7e1b1bce3ff74..d67941a4ea229 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -420,15 +420,15 @@ impl Resolver<'_, '_> { || import.span.is_dummy() || self.import_use_map.contains_key(import) => { - if let ImportKind::MacroUse { .. } = import.kind { - if !import.span.is_dummy() { - self.lint_buffer.buffer_lint( - MACRO_USE_EXTERN_CRATE, - import.root_id, - import.span, - crate::errors::MacroUseDeprecated, - ); - } + if let ImportKind::MacroUse = import.kind + && !import.span.is_dummy() + { + self.lint_buffer.buffer_lint( + MACRO_USE_EXTERN_CRATE, + import.root_id, + import.span, + crate::errors::MacroUseDeprecated, + ); } } ImportKind::ExternCrate { id, .. } => { @@ -443,7 +443,7 @@ impl Resolver<'_, '_> { maybe_unused_extern_crates.insert(id, import.span); } } - ImportKind::MacroUse { .. } => { + ImportKind::MacroUse => { self.lint_buffer.buffer_lint( UNUSED_IMPORTS, import.root_id, diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 723890a2f1ca2..a0dc1c909b0ae 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -300,7 +300,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { use DeclKind::Import; let can_suggest = |binding: Decl<'_>, import: self::Import<'_>| { !binding.span.is_dummy() - && !matches!(import.kind, ImportKind::MacroUse { .. } | ImportKind::MacroExport) + && !matches!(import.kind, ImportKind::MacroUse | ImportKind::MacroExport) }; let import = match (&new_binding.kind, &old_binding.kind) { // If there are two imports where one or both have attributes then prefer removing the @@ -2286,9 +2286,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { next_ident = source; Some(source_decl) } - ImportKind::Glob { .. } - | ImportKind::MacroUse { .. } - | ImportKind::MacroExport => Some(source_decl), + ImportKind::Glob { .. } | ImportKind::MacroUse | ImportKind::MacroExport => { + Some(source_decl) + } ImportKind::ExternCrate { .. } => None, }, _ => None, diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index 9f26fc076e57f..1fc2c201f8dac 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -794,19 +794,6 @@ pub(crate) struct CannotBeReexportedCratePublicNS { pub(crate) ident: Ident, } -#[derive(Diagnostic)] -#[diag("extern crate `{$ident}` is private and cannot be re-exported", code = E0365)] -pub(crate) struct PrivateExternCrateReexport { - pub ident: Ident, - #[suggestion( - "consider making the `extern crate` item publicly accessible", - code = "pub ", - style = "verbose", - applicability = "maybe-incorrect" - )] - pub sugg: Span, -} - #[derive(Subdiagnostic)] #[help("consider adding a `#[macro_export]` to the macro in the imported module")] pub(crate) struct ConsiderAddingMacroExport { @@ -1428,12 +1415,6 @@ pub(crate) struct UnusedMacroUse; #[help("remove it and import macros at use sites with a `use` item instead")] pub(crate) struct MacroUseDeprecated; -#[derive(Diagnostic)] -#[diag("macro `{$ident}` is private")] -pub(crate) struct MacroIsPrivate { - pub ident: Ident, -} - #[derive(Diagnostic)] #[diag("unused macro definition: `{$name}`")] pub(crate) struct UnusedMacroDefinition { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index a3b80ae264da6..1d4eead517935 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -20,7 +20,7 @@ use rustc_middle::span_bug; use rustc_middle::ty::{TyCtxt, Visibility}; use rustc_session::lint::builtin::{ AMBIGUOUS_GLOB_REEXPORTS, EXPORTED_PRIVATE_DEPENDENCIES, HIDDEN_GLOB_REEXPORTS, - PUB_USE_OF_PRIVATE_EXTERN_CRATE, REDUNDANT_IMPORTS, UNUSED_IMPORTS, + REDUNDANT_IMPORTS, UNUSED_IMPORTS, }; use rustc_session::parse::feature_err; use rustc_span::edit_distance::find_best_match_for_name; @@ -99,11 +99,7 @@ pub(crate) enum ImportKind<'ra> { target: Ident, id: NodeId, }, - MacroUse { - /// A field has been added indicating whether it should be reported as a lint, - /// addressing issue#119301. - warn_private: bool, - }, + MacroUse, MacroExport, } @@ -134,9 +130,7 @@ impl<'ra> std::fmt::Debug for ImportKind<'ra> { .field("target", target) .field("id", id) .finish(), - MacroUse { warn_private } => { - f.debug_struct("MacroUse").field("warn_private", warn_private).finish() - } + MacroUse => f.debug_struct("MacroUse").finish(), MacroExport => f.debug_struct("MacroExport").finish(), } } @@ -253,7 +247,7 @@ impl<'ra> ImportData<'ra> { ImportKind::Single { id, .. } | ImportKind::Glob { id, .. } | ImportKind::ExternCrate { id, .. } => Some(id), - ImportKind::MacroUse { .. } | ImportKind::MacroExport => None, + ImportKind::MacroUse | ImportKind::MacroExport => None, } } @@ -263,7 +257,7 @@ impl<'ra> ImportData<'ra> { ImportKind::Single { id, .. } => Reexport::Single(to_def_id(id)), ImportKind::Glob { id, .. } => Reexport::Glob(to_def_id(id)), ImportKind::ExternCrate { id, .. } => Reexport::ExternCrate(to_def_id(id)), - ImportKind::MacroUse { .. } => Reexport::MacroUse, + ImportKind::MacroUse => Reexport::MacroUse, ImportKind::MacroExport => Reexport::MacroExport, } } @@ -272,7 +266,6 @@ impl<'ra> ImportData<'ra> { ImportSummary { vis: self.vis, nearest_parent_mod: self.parent_scope.module.nearest_parent_mod().expect_local(), - is_single: matches!(self.kind, ImportKind::Single { .. }), } } } @@ -333,20 +326,6 @@ struct UnresolvedImportError { on_unknown_attr: Option, } -// Reexports of the form `pub use foo as bar;` where `foo` is `extern crate foo;` -// are permitted for backward-compatibility under a deprecation lint. -fn pub_use_of_private_extern_crate_hack(import: ImportSummary, decl: Decl<'_>) -> Option { - match (import.is_single, decl.kind) { - (true, DeclKind::Import { import: decl_import, .. }) - if let ImportKind::ExternCrate { id, .. } = decl_import.kind - && import.vis.is_public() => - { - Some(id) - } - _ => None, - } -} - /// Removes identical import layers from two declarations. fn remove_same_import<'ra>(d1: Decl<'ra>, d2: Decl<'ra>) -> (Decl<'ra>, Decl<'ra>) { if let DeclKind::Import { import: import1, source_decl: d1_next } = d1.kind @@ -374,7 +353,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let decl_vis = decl.vis(); if decl_vis.partial_cmp(import.vis, self.tcx) == Some(Ordering::Less) && decl_vis.is_accessible_from(import.nearest_parent_mod, self.tcx) - && pub_use_of_private_extern_crate_hack(import, decl).is_none() { // Imported declaration is less visible than the import, but is still visible // from the current module, use the declaration's visibility. @@ -383,8 +361,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Good case - imported declaration is more visible than the import, or the same, // use the import's visibility. // Bad case - imported declaration is too private for the current module. - // It doesn't matter what visibility we choose here (except in the `PRIVATE_MACRO_USE` - // and `PUB_USE_OF_PRIVATE_EXTERN_CRATE` cases), because either some error will be + // It doesn't matter what visibility we choose here, because either some error will be // reported, or the import declaration will be thrown away (unfortunately cannot use // delayed bug here for this reason). // Use import visibility to keep the all declaration visibilities in a module ordered. @@ -1495,20 +1472,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // All namespaces must be re-exported with extra visibility for an error to occur. if !any_successful_reexport { let (ns, binding) = reexport_error.unwrap(); - if let Some(extern_crate_id) = - pub_use_of_private_extern_crate_hack(import.summary(), binding) - { - let extern_crate_sp = self.tcx.source_span(self.local_def_id(extern_crate_id)); - self.lint_buffer.buffer_lint( - PUB_USE_OF_PRIVATE_EXTERN_CRATE, - import_id, - import.span, - crate::errors::PrivateExternCrateReexport { - ident, - sugg: extern_crate_sp.shrink_to_lo(), - }, - ); - } else if ns == TypeNS { + if ns == TypeNS { let err = if crate_private_reexport { self.dcx() .create_err(CannotBeReexportedCratePublicNS { span: import.span, ident }) @@ -1802,7 +1766,7 @@ fn import_kind_to_string(import_kind: &ImportKind<'_>) -> String { ImportKind::Single { source, .. } => source.to_string(), ImportKind::Glob { .. } => "*".to_string(), ImportKind::ExternCrate { .. } => "".to_string(), - ImportKind::MacroUse { .. } => "#[macro_use]".to_string(), + ImportKind::MacroUse => "#[macro_use]".to_string(), ImportKind::MacroExport => "#[macro_export]".to_string(), } } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 3b8f3c4a24c90..17900fd99d58a 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -70,7 +70,6 @@ use rustc_middle::ty::{ TyCtxt, TyCtxtFeed, Visibility, }; use rustc_session::config::CrateType; -use rustc_session::lint::builtin::PRIVATE_MACRO_USE; use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transparency}; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym}; use smallvec::{SmallVec, smallvec}; @@ -2205,31 +2204,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } } if let DeclKind::Import { import, source_decl } = used_decl.kind { - if let ImportKind::MacroUse { warn_private: true } = import.kind { - // Do not report the lint if the macro name resolves in stdlib prelude - // even without the problematic `macro_use` import. - let found_in_stdlib_prelude = self.prelude.is_some_and(|prelude| { - let empty_module = self.empty_module.to_module(); - let arenas = self.arenas; - self.cm() - .maybe_resolve_ident_in_module( - ModuleOrUniformRoot::Module(prelude), - ident, - MacroNS, - &ParentScope::module(empty_module, arenas), - None, - ) - .is_ok() - }); - if !found_in_stdlib_prelude { - self.lint_buffer().buffer_lint( - PRIVATE_MACRO_USE, - import.root_id, - ident.span, - errors::MacroIsPrivate { ident }, - ); - } - } // Avoid marking `extern crate` items that refer to a name from extern prelude, // but not introduce it, as used if they are accessed from lexical scope. if used == Used::Scope @@ -2715,7 +2689,6 @@ enum Stage { struct ImportSummary { vis: Visibility, nearest_parent_mod: LocalDefId, - is_single: bool, } /// Invariant: if `Finalize` is used, expansion and import resolution must be complete. diff --git a/tests/ui/extern/issue-80074.rs b/tests/ui/extern/issue-80074.rs index 942b78916d6a0..81030ab152250 100644 --- a/tests/ui/extern/issue-80074.rs +++ b/tests/ui/extern/issue-80074.rs @@ -11,8 +11,7 @@ extern crate issue_80074_2; fn main() { foo!(); - //~^ ERROR: macro `foo` is private - //~| WARN: it will become a hard error in a future release! + //~^ ERROR: cannot find macro `foo` in this scope bar!(); //~^ ERROR: cannot find macro `bar` in this scope m!(); diff --git a/tests/ui/extern/issue-80074.stderr b/tests/ui/extern/issue-80074.stderr index 510ca1be0a199..ed78263a6bc77 100644 --- a/tests/ui/extern/issue-80074.stderr +++ b/tests/ui/extern/issue-80074.stderr @@ -4,39 +4,24 @@ error[E0469]: imported macro not found LL | #[macro_use(m)] | ^ -error: cannot find macro `bar` in this scope - --> $DIR/issue-80074.rs:16:5 - | -LL | bar!(); - | ^^^ - error: cannot find macro `m` in this scope - --> $DIR/issue-80074.rs:18:5 + --> $DIR/issue-80074.rs:17:5 | LL | m!(); | ^ -error: macro `foo` is private - --> $DIR/issue-80074.rs:13:5 +error: cannot find macro `bar` in this scope + --> $DIR/issue-80074.rs:15:5 | -LL | foo!(); +LL | bar!(); | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #120192 - = note: `#[deny(private_macro_use)]` on by default - -error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0469`. -Future incompatibility report: Future breakage diagnostic: -error: macro `foo` is private +error: cannot find macro `foo` in this scope --> $DIR/issue-80074.rs:13:5 | LL | foo!(); | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #120192 - = note: `#[deny(private_macro_use)]` on by default +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0469`. diff --git a/tests/ui/lint/force-warn/ice-free.rs b/tests/ui/lint/force-warn/ice-free.rs index 99b79f44648b2..29e7efdf927af 100644 --- a/tests/ui/lint/force-warn/ice-free.rs +++ b/tests/ui/lint/force-warn/ice-free.rs @@ -1,9 +1,6 @@ -//@ compile-flags: --force-warn pub_use_of_private_extern_crate +//@ compile-flags: --force-warn unused_variables //@ check-pass -extern crate core; -pub use core as reexported_core; -//~^ warning: extern crate `core` is private -//~| warning: this was previously accepted by the compiler - -fn main() {} +fn main() { + let x = 10; //~ WARN unused variable: `x` +} diff --git a/tests/ui/lint/force-warn/ice-free.stderr b/tests/ui/lint/force-warn/ice-free.stderr index b64e3b138a265..7a4b9b0789335 100644 --- a/tests/ui/lint/force-warn/ice-free.stderr +++ b/tests/ui/lint/force-warn/ice-free.stderr @@ -1,32 +1,10 @@ -warning[E0365]: extern crate `core` is private and cannot be re-exported +warning: unused variable: `x` --> $DIR/ice-free.rs:5:9 | -LL | pub use core as reexported_core; - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | let x = 10; + | ^ help: if this is intentional, prefix it with an underscore: `_x` | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #127909 - = note: requested on the command line with `--force-warn pub-use-of-private-extern-crate` -help: consider making the `extern crate` item publicly accessible - | -LL | pub extern crate core; - | +++ + = note: requested on the command line with `--force-warn unused-variables` warning: 1 warning emitted -For more information about this error, try `rustc --explain E0365`. -Future incompatibility report: Future breakage diagnostic: -warning[E0365]: extern crate `core` is private and cannot be re-exported - --> $DIR/ice-free.rs:5:9 - | -LL | pub use core as reexported_core; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #127909 - = note: requested on the command line with `--force-warn pub-use-of-private-extern-crate` -help: consider making the `extern crate` item publicly accessible - | -LL | pub extern crate core; - | +++ - diff --git a/tests/ui/pub/pub-reexport-priv-extern-crate.rs b/tests/ui/pub/pub-reexport-priv-extern-crate.rs index bc91cf4bc7551..d0e62bf2c40ab 100644 --- a/tests/ui/pub/pub-reexport-priv-extern-crate.rs +++ b/tests/ui/pub/pub-reexport-priv-extern-crate.rs @@ -1,11 +1,10 @@ extern crate core; -pub use core as reexported_core; //~ ERROR `core` is private and cannot be re-exported - //~^ WARN this was previously accepted +pub use core as reexported_core; +//~^ ERROR `core` is only public within the crate, and cannot be re-exported outside mod foo1 { extern crate core; - pub use self::core as core2; //~ ERROR extern crate `core` is private and cannot be re-exported - //~^ WARN this was previously accepted + pub use self::core as core2; //~ ERROR `core` is private, and cannot be re-exported } mod foo2 { @@ -20,6 +19,5 @@ mod baz { } fn main() { - // Check that `foo1::core2` has the reexport's visibility and is accessible. - foo1::core2::mem::drop(()); + foo1::core2::mem::drop(()); //~ ERROR crate import `core2` is private } diff --git a/tests/ui/pub/pub-reexport-priv-extern-crate.stderr b/tests/ui/pub/pub-reexport-priv-extern-crate.stderr index 1b8279c643318..73f38580a4a0f 100644 --- a/tests/ui/pub/pub-reexport-priv-extern-crate.stderr +++ b/tests/ui/pub/pub-reexport-priv-extern-crate.stderr @@ -1,5 +1,21 @@ +error[E0365]: `core` is only public within the crate, and cannot be re-exported outside + --> $DIR/pub-reexport-priv-extern-crate.rs:2:9 + | +LL | pub use core as reexported_core; + | ^^^^^^^^^^^^^^^^^^^^^^^ re-export of crate public `core` + | + = note: consider declaring type or module `core` with `pub` + +error[E0365]: `core` is private, and cannot be re-exported + --> $DIR/pub-reexport-priv-extern-crate.rs:7:13 + | +LL | pub use self::core as core2; + | ^^^^^^^^^^^^^^^^^^^ re-export of private `core` + | + = note: consider declaring type or module `core` with `pub` + error[E0603]: crate import `core` is private - --> $DIR/pub-reexport-priv-extern-crate.rs:12:22 + --> $DIR/pub-reexport-priv-extern-crate.rs:11:22 | LL | use crate::foo1::core; | ^^^^ private crate import @@ -11,75 +27,40 @@ LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ error[E0603]: crate import `core` is private - --> $DIR/pub-reexport-priv-extern-crate.rs:19:31 + --> $DIR/pub-reexport-priv-extern-crate.rs:18:31 | LL | pub use crate::foo2::bar::core; | ^^^^ private crate import | note: the crate import `core` is defined here - --> $DIR/pub-reexport-priv-extern-crate.rs:14:9 + --> $DIR/pub-reexport-priv-extern-crate.rs:13:9 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ -error[E0365]: extern crate `core` is private and cannot be re-exported - --> $DIR/pub-reexport-priv-extern-crate.rs:2:9 - | -LL | pub use core as reexported_core; - | ^^^^^^^^^^^^^^^^^^^^^^^ +error[E0603]: crate import `core2` is private + --> $DIR/pub-reexport-priv-extern-crate.rs:22:11 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #127909 - = note: `#[deny(pub_use_of_private_extern_crate)]` (part of `#[deny(future_incompatible)]`) on by default -help: consider making the `extern crate` item publicly accessible +LL | foo1::core2::mem::drop(()); + | ^^^^^ private crate import | -LL | pub extern crate core; - | +++ - -error[E0365]: extern crate `core` is private and cannot be re-exported +note: the crate import `core2` is defined here... --> $DIR/pub-reexport-priv-extern-crate.rs:7:13 | LL | pub use self::core as core2; | ^^^^^^^^^^^^^^^^^^^ +note: ...and refers to the crate import `core` which is defined here + --> $DIR/pub-reexport-priv-extern-crate.rs:6:5 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #127909 -help: consider making the `extern crate` item publicly accessible +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ +help: consider importing this function instead + | +LL - foo1::core2::mem::drop(()); +LL + core::mem::drop(()); | -LL | pub extern crate core; - | +++ -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0365, E0603. For more information about an error, try `rustc --explain E0365`. -Future incompatibility report: Future breakage diagnostic: -error[E0365]: extern crate `core` is private and cannot be re-exported - --> $DIR/pub-reexport-priv-extern-crate.rs:2:9 - | -LL | pub use core as reexported_core; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #127909 - = note: `#[deny(pub_use_of_private_extern_crate)]` (part of `#[deny(future_incompatible)]`) on by default -help: consider making the `extern crate` item publicly accessible - | -LL | pub extern crate core; - | +++ - -Future breakage diagnostic: -error[E0365]: extern crate `core` is private and cannot be re-exported - --> $DIR/pub-reexport-priv-extern-crate.rs:7:13 - | -LL | pub use self::core as core2; - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #127909 - = note: `#[deny(pub_use_of_private_extern_crate)]` (part of `#[deny(future_incompatible)]`) on by default -help: consider making the `extern crate` item publicly accessible - | -LL | pub extern crate core; - | +++ -