Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2483,6 +2483,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// `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 }
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/imports/private-import-nested-suggestion-156060.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Regression test for #156060.
Comment thread
el-ev marked this conversation as resolved.

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() {}
20 changes: 20 additions & 0 deletions tests/ui/imports/private-import-nested-suggestion-156060.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Loading