about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-06-10 15:24:44 +0200
committerGitHub <noreply@github.com>2023-06-10 15:24:44 +0200
commit312e67633313836ef89bc1f6b299f43e2fa7c155 (patch)
treea351bfef54051cd508970ec410bd7ab542f8d80a /compiler
parent8744b1a5752ce0277ff1484e8e64b3810a0cdad6 (diff)
parent80176a120e90bb9f8e7b9e8fedda9ac857f434f3 (diff)
downloadrust-312e67633313836ef89bc1f6b299f43e2fa7c155.tar.gz
rust-312e67633313836ef89bc1f6b299f43e2fa7c155.zip
Rollup merge of #112413 - jieyouxu:fix-hidden-glob-reexports-span-order, r=petrochenkov
Adjust span labels for `HIDDEN_GLOB_REEXPORTS`

Addresses https://github.com/rust-lang/rust/pull/111378#issuecomment-1581226063.

### Before This PR

The possibility that the private item comes before the glob re-export was not account for, causing the span label messages to say "but private item here shadows it" before "the name `Foo` in the type namespace is supposed to be publicly re-exported here".

### After This PR

```rust
warning: private item shadows public glob re-export
  --> $DIR/hidden_glob_reexports.rs:9:5
   |
LL |     struct Foo;
   |     ^^^^^^^^^^^ the private item here shadows the name `Foo` in the type namespace
...
LL |     pub use self::inner::*;
   |             -------------- but it is supposed to be publicly re-exported here
   |
   = note: `#[warn(hidden_glob_reexports)]` on by default

warning: private item shadows public glob re-export
  --> $DIR/hidden_glob_reexports.rs:27:9
   |
LL |     pub use self::inner::*;
   |             -------------- the name `Foo` in the type namespace is supposed to be publicly re-exported here
LL |
LL |     use self::other::Foo;
   |         ^^^^^^^^^^^^^^^^ but the private item here shadows it
```
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_lint/src/context.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs
index 947530a1b65..13164b0b339 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.