Skip to content

We should forbid type parameters from shadowing other types #707

@rust-highfive

Description

@rust-highfive

Issue by erickt
Saturday Jan 17, 2015 at 16:01 GMT

For earlier discussion, see rust-lang/rust#21301

This issue was labelled with: A-associated-items in the Rust repository


This is a weird case that we should probably not allow:

mod T {
    pub type Type = i32;
}

trait Trait {
    type Type;
}

impl Trait for i32 {
    type Type = i8;
}

struct Baz<T: Trait> {
    a: T::Type,
}

fn main() {
    let x: Baz<i32> = Baz { a: 0i8 };
}

The rule appears to be that the <T: Trait> has precedence over the module, it would be easiest if we just errored out in this circumstance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.breaking-changeThe RFC proposes a breaking change.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions