Code
mod one {
pub struct One();
}
mod two {
use crate::one::One;
pub struct Two();
}
mod test {
use crate::two::{One, Two};
use std::{fs::Path};
}
Current output
error[E0603]: struct import `One` is private
--> src/lib.rs:11:22
|
11 | use crate::two::{One, Two};
| ^^^ private struct import
|
note: the struct import `One` is defined here...
--> src/lib.rs:6:9
|
6 | use crate::one::One;
| ^^^^^^^^^^^^^^^
note: ...and refers to the struct `One` which is defined here
--> src/lib.rs:2:5
|
2 | pub struct One();
| ^^^^^^^^^^^^^^^^^ you could import this directly
error[E0603]: struct `Path` is private
--> src/lib.rs:12:19
|
12 | use std::{fs::Path};
| ^^^^ private struct
|
note: the struct `Path` is defined here
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/fs.rs:46:19
|
46 | use crate::path::{Path, PathBuf};
| ^^^^
Desired output
error[E0603]: struct import `One` is private
--> src/lib.rs:11:22
|
11 | use crate::two::{One, Two};
| ^^^ private struct import
|
note: the struct import `One` is defined here...
--> src/lib.rs:6:9
|
6 | use crate::one::One;
| ^^^^^^^^^^^^^^^
note: ...and refers to the struct `One` which is defined here
--> src/lib.rs:2:5
|
2 | pub struct One();
| ^^^^^^^^^^^^^^^^^ you could import this directly
help: import `One` through the re-export
|
10 | +use crate::one::One;
11 | ~use crate::two::Two;
error[E0603]: struct `Path` is private
--> src/lib.rs:12:19
|
12 | use std::{fs::Path};
| ^^^^ private struct
|
note: the struct `Path` is defined here
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/fs.rs:46:19
|
46 | use crate::path::{Path, PathBuf};
| ^^^^
help: import `Path` directly
|
12 | ~use std::path::Path;
Rationale and extra context
#156244 fixed #156060 and #155348 by not emitting a suggestion at all, however I think we could still emit good suggestion, by: extracting an import out of a group and use the right path if the path is inside a group; or change the entire import if we're in a group of 1.
Other cases
Rust Version
latest playground nightly
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
#156244 fixed #156060 and #155348 by not emitting a suggestion at all, however I think we could still emit good suggestion, by: extracting an import out of a group and use the right path if the path is inside a group; or change the entire import if we're in a group of 1.
Other cases
Rust Version
Anything else?
No response