The Great Module Adventure Continues

I was going to say I liked variant 3, but I mis-read it. Why not this, i.e. without the crate:: part for local names?

use ::std::time; 
use ::top_level_name;
use super::parent_item;
use child_mod::item; // or self::child_mod::item

Advantages:

  • this works today
  • the only required change is to deprecate usage of absolute paths without leading ::

Optionally also deprecate usage of relative paths in use and pub(in X), excepting super and self keywords.

This avoids the following problem too:

The only drawback is that it isn't always immediately obvious whether ::foo refers to another crate or an item at the top of this crate (this is tentatively an advantage, allowing an external dependency to be moved to an internal module and customised easily).

3 Likes