-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
use statement fails silently if it would shadow an existing name #10884
Comments
This is currently all working as intended as you mentioned. This is why we require that That being said, the idea of having a warning about this is interesting. I personally would not want the lint to be warn-by-default, and allow-by-default lints have questionable usefulness when their purpose is to catch a possible bug like this, but the idea may be worth exploring. |
I think that it is worth warning-by-default if it was an explicit use (it's basically a no-op, and we just had a patch warning on unused code ^^) but not for a globbed use (that would be allow-by-default or not checked at all). Of course, globs aren't finished yet (and might not be sticking around at all), so that point could well moot. There is also the warn-by-default unused_import for use statements that could be but aren't used. But that's just my 2 pence. |
FWIW, any resolution errors caused by this will make the compiler quit before even hitting the lint pass; and in cases where it is shadowed without causing an error, wouldn't it be flagged by unused import errors? |
I'm going to close this as working as intended. @huonw has a good point that a lint wouldn't be too useful in terms of errors, and I think that any errors should be accompanied with extra machinery from resolve instead. Resolve could keep a history of shadowed items and attempt to resolve through all shadowed items, providing a suggestion that perhaps you didn't mean to shadow when an error occurs. For now though, everything is working as intended. I think that a different bug should be opened for improving error messages of resolve. |
…=dswij New lint [`needless_raw_string_hashes`] Emits a warning when there are an extraneous number of hashes(?) around a raw string literal, for example `r##"I'm a "raw string literal"!"##` or `cr#"crunb"#` Closes rust-lang#10882 I think this could also fit in `style` as well, rather than `complexity`. changelog: Add [`needless_raw_string_hashes`] and [`needless_raw_string`] lints
If a use statement would shadow an existing name, it does nothing, not even emit a warning. While the rule on not importing if it would shadow seems to be "working as intended", it might be helpful to issue a warning (or error).
The text was updated successfully, but these errors were encountered: