about summary refs log tree commit diff
path: root/tests/ui/proc-macro
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-11-19 17:46:44 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-12-04 22:26:08 +0000
commitbeaf31581a1ade80bbd934e87ae3fa9b2b4c88a4 (patch)
tree873154c68fe4c833f5970bfdcb8a831f669c34d0 /tests/ui/proc-macro
parent0e2dac8375950a12812ec65868e42b43ed214ef9 (diff)
downloadrust-beaf31581a1ade80bbd934e87ae3fa9b2b4c88a4.tar.gz
rust-beaf31581a1ade80bbd934e87ae3fa9b2b4c88a4.zip
Structured `use` suggestion on privacy error
When encoutering a privacy error on an item through a re-export that is
accessible in an alternative path, provide a structured suggestion with
that path.

```
error[E0603]: module import `mem` is private
  --> $DIR/private-std-reexport-suggest-public.rs:4:14
   |
LL |     use foo::mem;
   |              ^^^ private module import
   |
note: the module import `mem` is defined here...
  --> $DIR/private-std-reexport-suggest-public.rs:8:9
   |
LL |     use std::mem;
   |         ^^^^^^^^
note: ...and refers to the module `mem` which is defined here
  --> $SRC_DIR/std/src/lib.rs:LL:COL
   |
   = note: you could import this
help: import `mem` through the re-export
   |
LL |     use std::mem;
   |         ~~~~~~~~
```

Fix #42909.
Diffstat (limited to 'tests/ui/proc-macro')
-rw-r--r--tests/ui/proc-macro/disappearing-resolution.stderr6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/ui/proc-macro/disappearing-resolution.stderr b/tests/ui/proc-macro/disappearing-resolution.stderr
index 5b969549a11..e6d0868687e 100644
--- a/tests/ui/proc-macro/disappearing-resolution.stderr
+++ b/tests/ui/proc-macro/disappearing-resolution.stderr
@@ -19,7 +19,11 @@ note: ...and refers to the derive macro `Empty` which is defined here
   --> $DIR/auxiliary/test-macros.rs:25:1
    |
 LL | pub fn empty_derive(_: TokenStream) -> TokenStream {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider importing it directly
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ you could import this directly
+help: import `Empty` directly
+   |
+LL | use test_macros::Empty;
+   |     ~~~~~~~~~~~~~~~~~~
 
 error: aborting due to 2 previous errors