From 80176a120e90bb9f8e7b9e8fedda9ac857f434f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= Date: Thu, 8 Jun 2023 15:03:21 +0800 Subject: [PATCH] Adjust span labels for `HIDDEN_GLOB_REEXPORTS` --- compiler/rustc_lint/src/context.rs | 4 +- tests/ui/resolve/hidden_glob_reexports.rs | 4 +- tests/ui/resolve/hidden_glob_reexports.stderr | 45 ++++++++++++++----- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 947530a1b65a9..13164b0b339a3 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -953,8 +953,8 @@ pub trait LintContext: Sized { db.span_label(duplicate_reexport_span, format!("but the name `{}` in the {} namespace is also re-exported here", name, namespace)); } BuiltinLintDiagnostics::HiddenGlobReexports { name, namespace, glob_reexport_span, private_item_span } => { - db.span_label(glob_reexport_span, format!("the name `{}` in the {} namespace is supposed to be publicly re-exported here", name, namespace)); - db.span_label(private_item_span, "but the private item here shadows it"); + db.span_note(glob_reexport_span, format!("the name `{}` in the {} namespace is supposed to be publicly re-exported here", name, namespace)); + db.span_note(private_item_span, "but the private item here shadows it".to_owned()); } } // Rewrap `db`, and pass control to the user. diff --git a/tests/ui/resolve/hidden_glob_reexports.rs b/tests/ui/resolve/hidden_glob_reexports.rs index 361243fcd7bdf..102b565624526 100644 --- a/tests/ui/resolve/hidden_glob_reexports.rs +++ b/tests/ui/resolve/hidden_glob_reexports.rs @@ -6,10 +6,10 @@ pub mod upstream_a { pub struct Bar {} } - pub use self::inner::*; - struct Foo; //~^ WARN private item shadows public glob re-export + + pub use self::inner::*; } pub mod upstream_b { diff --git a/tests/ui/resolve/hidden_glob_reexports.stderr b/tests/ui/resolve/hidden_glob_reexports.stderr index ddf7bcda827a8..11fa94d6fee98 100644 --- a/tests/ui/resolve/hidden_glob_reexports.stderr +++ b/tests/ui/resolve/hidden_glob_reexports.stderr @@ -1,31 +1,54 @@ warning: private item shadows public glob re-export - --> $DIR/hidden_glob_reexports.rs:11:5 + --> $DIR/hidden_glob_reexports.rs:9:5 | -LL | pub use self::inner::*; - | -------------- the name `Foo` in the type namespace is supposed to be publicly re-exported here -LL | LL | struct Foo; - | ^^^^^^^^^^^ but the private item here shadows it + | ^^^^^^^^^^^ + | +note: the name `Foo` in the type namespace is supposed to be publicly re-exported here + --> $DIR/hidden_glob_reexports.rs:12:13 + | +LL | pub use self::inner::*; + | ^^^^^^^^^^^^^^ +note: but the private item here shadows it + --> $DIR/hidden_glob_reexports.rs:9:5 | +LL | struct Foo; + | ^^^^^^^^^^^ = note: `#[warn(hidden_glob_reexports)]` on by default warning: private item shadows public glob re-export --> $DIR/hidden_glob_reexports.rs:27:9 | +LL | use self::other::Foo; + | ^^^^^^^^^^^^^^^^ + | +note: the name `Foo` in the type namespace is supposed to be publicly re-exported here + --> $DIR/hidden_glob_reexports.rs:25:13 + | LL | pub use self::inner::*; - | -------------- the name `Foo` in the type namespace is supposed to be publicly re-exported here -LL | + | ^^^^^^^^^^^^^^ +note: but the private item here shadows it + --> $DIR/hidden_glob_reexports.rs:27:9 + | LL | use self::other::Foo; - | ^^^^^^^^^^^^^^^^ but the private item here shadows it + | ^^^^^^^^^^^^^^^^ warning: private item shadows public glob re-export --> $DIR/hidden_glob_reexports.rs:40:9 | +LL | use std::primitive::u8; + | ^^^^^^^^^^^^^^^^^^ + | +note: the name `u8` in the type namespace is supposed to be publicly re-exported here + --> $DIR/hidden_glob_reexports.rs:38:13 + | LL | pub use self::no_def_id::*; - | ------------------ the name `u8` in the type namespace is supposed to be publicly re-exported here -LL | + | ^^^^^^^^^^^^^^^^^^ +note: but the private item here shadows it + --> $DIR/hidden_glob_reexports.rs:40:9 + | LL | use std::primitive::u8; - | ^^^^^^^^^^^^^^^^^^ but the private item here shadows it + | ^^^^^^^^^^^^^^^^^^ warning: 3 warnings emitted