Making the type keyword more useful


The type keyword has one limitation:

type Vec2f = Vec2<f64>;

struct Vec2<T> {
    x: T,
    y: T,

impl<T: Num> Vec2<T> {
    fn new(x: T, y: T) -> Vec2<T> {
        Vec2 { x: x, y: y }

fn main() {
    // This is what I would like to do, but it doesn't work:
    let p = Vec2f::new(0.0, 0.0);

    // This works, but referring to the original name is what I wanted to avoid in
    // the first place.
    let p: Vec2f = Vec2::new(0.0, 0.0);

All that’s needed here is the type def expanding to Vec2::<f64> when applicable. Or maybe this is just another reason to remove :: as disambiguation.


Supporting method resolution with a path components that include type aliases is planned future work (though it may not happen for 1.0).

See e.g. discussion on PR #15443, where it was pointed out that a big motivation for that PR was to support this exact functionality in the future, and thus we needed to ensure that code written for 1.0 would not conflict with added this feature in the future.