-
Notifications
You must be signed in to change notification settings - Fork 13.3k
use core::prelude::*
conflicts with use collections::slice::SliceExt
#20513
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
Comments
This is a feature not a bug, the work around is to only import the items you need from the prelude, rather than using a glob import. This is kind of a pain at the moment and I'm working on a tool to help with it (but 1.0 things prevent that moving very fast right now). Closing for now, if you have ideas for how to resolve this (without allowing any import shadowing) or I have misunderstood, feel free to reopen. |
So you’re saying I don’t really have a better suggestion. I’m just saying that using |
I'm saying To clarify what is going on here, there is already a |
The problem is not the names (which an be changed locally with One solution is to only have Is having a single To take a step back, I was using |
Worth looking at this RFC issue for the import side: rust-lang/rfcs#553 cc @aturon about the mess with having two overlapping SliceExt traits. That all sounds worse than I thought. Perhaps it is worth taking SliceExt out of core::Prelude? |
Yes, overlapping traits is the core of the specific issue I encountered here.
I don’t know, aside from the overlap with its libcollections friend, SliceExt really belongs in core::prelude. |
So the intent with I think a way forward would be to have @alexcrichton thoughts? |
If a linear hierarchy like libcore ⊂ libcollections ⊂ libstd makes sense, libcollections could also provides its own prelude that could be used instead of |
(I’m also pondering whether I should bother with |
Very good point! That solution would likely have side benefits for convenient |
In Nightly c894171 2015-01-02, it is apparently not possible to use methods from
collections::slice::SliceExt
such asto_vec
in a scope whereuse core::prelude::*;
(very useful in#![no_std]
crates) is also used.Imports can not shadow each other, a name conflict is fatal:
Renaming the trait at import doesn’t help,
core
methods are now duplicated in the scope:As a work around when upgrading rust-wtf8, I moved
use collections::slice::SliceExt;
into the block that usesto_vec
but does not use other slice methods.The text was updated successfully, but these errors were encountered: