-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Incorrect hint to import private member #50923
Comments
This was actually intentional (see the PR introducing this diagnostic #31674). |
Ah, makes sense. |
I don't feel a second hint is necessary? Code bases of sufficient size may have many types with the same name, and sometimes it really is the case that you forgot to define it (or got the name wrong).
I think the current error says quite enough. |
If the concern is about wasting vertical terminal real estate, we can take that into account. (Only output n lines worth of suggestions, even if more than n lines worth of candidates are found, with already-public candidates prioritized before those with the additional "add (It's plausible that I'll find time to work on this this week.) |
Never mind; I'm not going to work on this. (I don't see any insurmountable difficulties, but my enthusiasm has waned remembering the time I introduced a similar suggestion in resolve and it ended up invoking some gross snippet-munging that depended on knowing the type of item.) |
Hi, |
I've run into this personally. I would be interested in modifying the error message so that when a possible type is suggested it will include information about whether the type is Example:
|
As example there is https://github.com/dtolnay/quote crate, by @dtolnay . |
I think what @Dushistov is getting at is that public re-exports aren't being suggested and private paths are; here's a minimal case (stable 1.31.0, edition 2018):
That is, the suggestion I get is:
But the suggestion I expect to get with the re-export is |
So if I'm understanding this correctly, there are a few factors that should be considered when deciding what help message to print:
It seems like the order of operations should look something like this:
I'd be willing to take a stab at this with a little guidance (if nobody's started it). I want to get some more opinions on the exact approach to take before I start, though. |
@nicholastmosher any progress?, this is really starting to become annoying :/ |
This appears to have been partially resolved. What remains now is that rustc recommends private members when it doesn't find any public alternatives, and it doesn't point out that they're private (the initial issue). My suggestion is that we just change the message in that particular case from I have no experience with the codebase but will set aside some time to study it for Hacktoberfest, and would be willing to give this a go. I'll just wait for some confirmation on how to tackle this. |
Hi @cauebs are you still working on this? If not I would like to fix this ;) |
@FlakM I'm not. You can go ahead. |
@FlakM, am I correct in guessing that you're not still working on this? If so, I'd like to have a go at it :) |
Sadly I didn't manage to get a crack at it... Good luck!
pt., 3 wrz 2021, 19:09 użytkownik Sebastian Paarmann <
***@***.***> napisał:
… @FlakM <https://github.com/FlakM>, am I correct in guessing that you're
not still working on this? If so, I'd like to have a go at it :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#50923 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA767CH5OYWH54TQTY375N3UAD6MDANCNFSM4FAYXYHA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Thanks! @rustbot claim |
After not finding nearly as much time to look at this as I'd hoped, I looked at it again, and it seems to have been fixed in the meantime 🎉 The test from the original comment now outputs: Playground link error[E0425]: cannot find value `PrivateMember` in this scope
--> src/main.rs:6:5
|
6 | PrivateMember;
| ^^^^^^^^^^^^^ not found in this scope
|
note: unit struct `crate::other_module::PrivateMember` exists but is inaccessible
--> src/main.rs:2:5
|
2 | struct PrivateMember;
| ^^^^^^^^^^^^^^^^^^^^^ not accessible I think this is from #88838. (cc @FabianWolff ). I think with that this issue can be closed now? |
@spaarmann the bug is that it suggest private members instead of the public ones, not that private access is incorrectly reported. |
@jannickj Can you provide an example? The original issue in the first comment is certainly not that.
|
ahh mb, I missed that it had been fixed 😅 |
One year later May I ask if this issue can be closed then or am missunderstanding something here? |
I believe all of the cases mentioned on this thread have been addressed. If there are more specific cases, feel free to create a new ticket (referencing this one, if needed). |
When a private member is accessed from another module an error is raised as expected, but it is wrongly hinted that you can import it into scope, as seen in this example:
Following the hint is clearly wrong:
Meta
The text was updated successfully, but these errors were encountered: