So, there are two things going on.
On the implementation complexity:
I was a bit vague there, and in part because I don’t remember the full state of play here. What I do remember from my time trying to under name resolution – particularly in the face of globs, macro expansion, and other things – is that it is a highly complicated, fixed-point sort of procedure.
Consider things like this:
- We resolve a path like
foo::bar to some particular item.
- We use that resolution to expand a macro; this macro creates a new item that would have taken precedence.
- (In this case, for example, a macro might introduce an
extern crate.)
That said, my understanding of the current resolve algorithm is somewhat out of date. I’ll need to go bring things back into cache to say convincingly.
Let me also quote @petrochenkov here, commenting on the RFC:
The RFC gives the recipe:
First, attempt to resolve the name as an item defined in the top-level module.
Otherwise, attempt to resolve the name as an external crate, exactly as we do with extern crate today.
It’s not as simple as that.
In presence of globs and macro-expanded items the “attempt to resolve the name” can give indeterminate result. We have to loop through a fixed-point algorithm possibly trying to resolve other imports before we can resolve this one. If only determined resolution failure results in the extern crate fallback, then globs and macros expanded in the crate root may break the fallback mechanism - it will return resolution errors instead. Or we can speculatively search and load extern crates on indeterminacy, which is not desirable. Given that the fallback will have to be supported infinitely, according to the epoch policy, it would be nice if it could be avoided.
Other petrochenkov comments: =)
On the general desirability of writing use std::foo:
But let’s assume that we can make fallback work. Then we still have to decide if we want to. Personally, I am not sure. In particular, it fails to achieve the goal that one can take a path that is used in a use and use it elsewhere, at least on its own. I personally think that’s a worthwhile goal, though of course we have to decide if we find a version and we like, and it’s worth the churn.