-
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
Better error messages for unresolved imports due to privateness when using use foo::*
#6477
Comments
This is going to need some deeper changes, I think. Might be a while, I'm not familiar with this part of rustc. |
No worries. |
I think the way to implement this is to add, at https://github.com/mozilla/rust/blob/incoming/src/librustc/middle/resolve.rs#L4035, iteration over all external types and checking if they exist or are private. Not really sure how to do this or if it's possible, but I think going through a similar process as (or maybe even just calling) resolve_definition_of_name_in_module with xray could do the trick. |
(that is, check if they have the same name) |
A quick study of the code, suggests to me that doing this: (roughly) let orig_xray = self.xray_context;
self.xray_context = Xray;
match self.resolve_path(path, TypeNS, true, visitor) {
Some(def) => {
// Found it, but it's private
}
None => {
// Straight-up doesn't exist
}
}
let self.xray_context = orig_xray; Which is similar to your idea. I'm not too familiar with the resolver though, so there may be a better way. |
This doesn't work, unfortunately. Not familiar enough with the resolver to figure out why. The log shows:
though. |
Triage bump. I've made no progress with this. |
I tend to close this, because of the glob feature gate and the chance of glob imports going away. |
I opened #11825 to cover glob imports going away, so this is contingent on that issue. |
They're leftovers from the enum namespacing transition Other than removing public reexports, I also had to publicize a type (compile::InstIdx). It should have always been public but was no error was never given because of this bug: rust-lang/rust#6477 I also had to enable documentation for compile::Ist because it was complaining that there wasn't any.
They're leftovers from the enum namespacing transition Other than removing public reexports, I also had to publicize a type (compile::InstIdx). It should have always been public but no error was ever given because of this bug: rust-lang/rust#6477 I also had to enable documentation for compile::Ist because it was complaining that there wasn't any.
This is still an issue as of:
The error with glob imports is:
Without is:
|
I seems to be fixed:
|
This is still not fixed, and indeed we now suggest to import |
E-needstest.
|
gar, no, that was the wrong code sample.. |
Today:
Closing! |
…s, r=ebroto Adapted the website search for better matching * This adds the ability to search for ids with dashes and spaces in the name. * Example: `missing-errors-doc` and `missing errors doc` are now valid aliases for lint names * It also improves the fuzzy search in the description. This search will now match any lint that where all searched words are inside the description. * Example: `doc section` finds two lints in our selection This was suggested/discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Enable.20lint.20search.20with.20dashes/near/220469464) ### Testing These changes can be tested locally by: 1. Clone this branch 2. Download the current lint index from the [gh-pages branch](https://github.com/rust-lang/rust-clippy/blob/gh-pages/master/lints.json) 3. Put it next to the `util/gh-pages/index.html` and open the html file. Make sure that it can load the lint data. (Browsers can be a bit iffy when opening a loacl html page and loading data) ### Note I found that searching only a few characters (< 3) seams slow and deleting one even more as almost every lint description contains them. This also happens in our current [lint list](https://rust-lang.github.io/rust-clippy/master/index.html). We could change the search to only be triggered if the search field contains more than 3 letters to slightly improve performance. --- changelog: Adapted the website search for better matching
…killercup Website issue tracker link and better search performance This PR implements some improvements to the website: 1. Added a "Search on Github" link to the "Known problems" section (Closes rust-lang#5386)  <details> <summary>Another mock up I created with the GitHub logo</summary>  </details> 2. Only starting the search after three letters and improving the search performance in general. (Followup rust-lang#6477) ### Testing These changes can be tested locally by: 1. Clone this branch 2. Download the current lint index from the [gh-pages branch](https://github.com/rust-lang/rust-clippy/blob/gh-pages/master/lints.json) 3. Put it next to the `util/gh-pages/index.html` and open the html file. Make sure that it can load the lint data. (Browsers can be a bit iffy when opening a local html page and loading data) ### Sources for search performance: 1. [A stackoverflow about angular filter performance](https://stackoverflow.com/questions/26876514/optimize-angular-filter-performance) * I selected a search debounce of 50ms that's fast enough to catch fast deletion and typing but responsive enough to not bother the user 2. [A stackoverflow about string comparison speeds](https://stackoverflow.com/questions/5296268/fastest-way-to-check-a-string-contain-another-substring-in-javascript) 3. [JS benchmarks for string search performance (`indexOf` seams to be the best)](https://jsben.ch/9cwLJ) Note: The performance is still a bit poor when going from a specific lint to no search filter. I suspect that angular is recreating all lint items when the filter is cleared causing a major lag spike. The filter functions is at least optimized for little to no search. --- changelog: Added a "Search on GitHub" link to the website
In #6443 @cmr made rustc for the following code
explain
error: unresolved import: found "Foo" in "foo" but it is private
.When the module members however are imported using
*
this way:rustc only says
error: use of undeclared type name "Foo"
.I think the most prominent use case could be
use super::*
in unit-test modules.The text was updated successfully, but these errors were encountered: