-
Notifications
You must be signed in to change notification settings - Fork 13k
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
RFC: requiring leading :: on use declarations #10910
Comments
It would be nice to clear this up, but leading |
I was confused by this as well. |
Just out of curiosity: could someone elaborate about the particular technical problems that would be posed by allowing To lead off with a question: I assume one issue is that if there's also a top-level |
@glaebhoerl I suspect @pcwalton knows better here, but I am not sure there are many technical problems, assuming e.g. that each The bigger issue is whether we would want to go down the road of relative lookup in |
@pnkfelix Thanks. To be clear, I'm not necessarily proposing that we allow it, I'm just interested in the background w.r.t. why things are the way they are. You might be correct that even from an ergonomic perspective it wouldn't be desirable. The only difference it would make compared to what we have now is whether relative paths need to be prefixed with |
@glaebhoerl Oh, you are correct. I had incorrectly thought that |
@pnkfelix Funny, I only realized the same thing halfway through my last comment, based on your comment in the OP. I thought I was the one behind the curve. :) |
One reason -- which is not technical -- is that it was really hard That said, I don't have a clear understanding of what the limits |
After discussion at meeting, decided that none of the alternatives here are all that attractive. (Though I was intrigued by @nikomatsakis 's proposal of "try relative, then fall back on absolute" for resolution in non- Anyway, closing; we should instead put in better compiler diagnostics (e.g. checking if abs/rel would work instead on error, and then presenting an error message explaining this language detail) to help new users get over this initial speed-bump. |
…r=llogiq Ignore more pointer types in `unnecessary_cast` Spotted this because https://github.com/rust-lang/rust-clippy/blob/e2c655b4c07c912ef749be316aeea8453cb9d840/tests/ui/suspicious_to_owned.rs#L9-L10 currently fails on `aarch64-unknown-linux-gnu` as `c_char` is `u8` there The current implementation checks for `as alias`, `as _`. This adds things like - `as *const alias` - `as *const cfg_dependant` - `as *const _` changelog: none
I have found it confusing that a path in an expression context uses relative lookup (and you specify absolute paths via a leading
::
), while the paths in theuse
declarations all use absolute lookup (and one needs to use a leadingself
orsuper
to get relative lookup).It might be easily to digest these forms if the absolute paths of
use
declarations required leading::
.Update: glaebhoerl 's comment below implicitly points out that another alternative would be to use relative referencing without leading
self
inuse
declarations. This avoids the wall of::
problem (assuming that one starts off withuse ::crate
for each external crate of interest; presumablyuse ::std
would be in the prelude), but it may introduce other usability issues that we currently side-step.The text was updated successfully, but these errors were encountered: