-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Fix relative paths in private import suggestions #157524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //@ run-rustfix | ||
|
|
||
| #![allow(unused)] | ||
|
|
||
| // Regression test for https://github.com/rust-lang/rust/issues/157455. | ||
| mod public { | ||
| pub struct Hi; | ||
| } | ||
|
|
||
| mod testing { | ||
| use super::public::Hi; | ||
| } | ||
|
|
||
| use public::Hi; | ||
| //~^ ERROR struct import `Hi` is private [E0603] | ||
|
|
||
| fn main() {} |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have lots of tests that runs rustfix but don't name them with the postfix
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense 🙂 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //@ run-rustfix | ||
|
|
||
| #![allow(unused)] | ||
|
|
||
| // Regression test for https://github.com/rust-lang/rust/issues/157455. | ||
| mod public { | ||
| pub struct Hi; | ||
| } | ||
|
|
||
| mod testing { | ||
| use super::public::Hi; | ||
| } | ||
|
|
||
| use testing::Hi; | ||
| //~^ ERROR struct import `Hi` is private [E0603] | ||
|
|
||
| fn main() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| error[E0603]: struct import `Hi` is private | ||
| --> $DIR/private-import-suggestion-relative.rs:14:14 | ||
| | | ||
| LL | use testing::Hi; | ||
| | ^^ private struct import | ||
| | | ||
| note: the struct import `Hi` is defined here... | ||
| --> $DIR/private-import-suggestion-relative.rs:11:9 | ||
| | | ||
| LL | use super::public::Hi; | ||
| | ^^^^^^^^^^^^^^^^^ | ||
| note: ...and refers to the struct `Hi` which is defined here | ||
| --> $DIR/private-import-suggestion-relative.rs:7:5 | ||
| | | ||
| LL | pub struct Hi; | ||
| | ^^^^^^^^^^^^^^ you could import this directly | ||
| help: import `Hi` directly | ||
| | | ||
| LL - use testing::Hi; | ||
| LL + use public::Hi; | ||
| | | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0603`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this into a new test file with
//@ run-rustfix? I think that would make the purpose of this test clearer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Moved the root super case to
tests/ui/imports/private-import-suggestion-relative-rustfix.rsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I think leaving this test as-is before this PR and moving the added lines into a new one would be nice