-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
7 changed files
with
140 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// run-rustfix | ||
#![allow(unused_imports)] | ||
fn main() { | ||
use std::mem; //~ ERROR module import `mem` is private | ||
} | ||
|
||
pub mod foo { | ||
use std::mem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// run-rustfix | ||
#![allow(unused_imports)] | ||
fn main() { | ||
use foo::mem; //~ ERROR module import `mem` is private | ||
} | ||
|
||
pub mod foo { | ||
use std::mem; | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/ui/imports/private-std-reexport-suggest-public.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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 directly | ||
help: import `mem` through the re-export | ||
| | ||
LL | use std::mem; | ||
| ~~~~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0603`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters