mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
skip incorrect suggestion in nested imports
This commit is contained in:
@@ -2483,6 +2483,11 @@ fn report_privacy_error(&mut self, privacy_error: &PrivacyError<'ra>) {
|
||||
// `tests/ui/imports/issue-55884-2.rs`
|
||||
continue;
|
||||
}
|
||||
// In nested imports `dedup_span` is just the inner ident, so a full path
|
||||
// substitution would produce invalid code. See #156060.
|
||||
if single_nested {
|
||||
break;
|
||||
}
|
||||
let path = join_path_idents(sugg);
|
||||
let sugg = if reexport {
|
||||
errors::ImportIdent::ThroughReExport { span: dedup_span, ident, path }
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Regression test for #156060.
|
||||
|
||||
mod one {
|
||||
pub struct One();
|
||||
}
|
||||
|
||||
mod two {
|
||||
use crate::one::One;
|
||||
pub struct Two();
|
||||
}
|
||||
|
||||
mod test {
|
||||
use crate::two::{One, Two};
|
||||
//~^ ERROR struct import `One` is private [E0603]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,20 @@
|
||||
error[E0603]: struct import `One` is private
|
||||
--> $DIR/private-import-nested-suggestion-156060.rs:13:22
|
||||
|
|
||||
LL | use crate::two::{One, Two};
|
||||
| ^^^ private struct import
|
||||
|
|
||||
note: the struct import `One` is defined here...
|
||||
--> $DIR/private-import-nested-suggestion-156060.rs:8:9
|
||||
|
|
||||
LL | use crate::one::One;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
note: ...and refers to the struct `One` which is defined here
|
||||
--> $DIR/private-import-nested-suggestion-156060.rs:4:5
|
||||
|
|
||||
LL | pub struct One();
|
||||
| ^^^^^^^^^^^^^^^^^ you could import this directly
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0603`.
|
||||
Reference in New Issue
Block a user