Skip to content

Can't define a trait with an associated type and function of the same name #27048

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

Closed
nham opened this issue Jul 15, 2015 · 2 comments
Closed
Labels
A-associated-items Area: Associated items (types, constants & functions) A-trait-system Area: Trait system

Comments

@nham
Copy link
Contributor

nham commented Jul 15, 2015

This doesn't work:

trait Foo {
    type Bar;
    fn Bar();
}

The error you get:

trait_type_method_same_name.rs:3:5: 3:14 error: duplicate definition of type or module `Bar`
trait_type_method_same_name.rs:3     fn Bar();
                                     ^~~~~~~~~
trait_type_method_same_name.rs:2:5: 2:14 note: first definition of type or module `Bar` here
trait_type_method_same_name.rs:2     type Bar;
                                     ^~~~~~~~~

It seems this should be allowed since they are in different namespaces.

@steveklabnik steveklabnik added A-trait-system Area: Trait system A-associated-items Area: Associated items (types, constants & functions) labels Jul 16, 2015
@steveklabnik
Copy link
Member

/cc @rust-lang/lang

@apasel422
Copy link
Contributor

This compiles successfully now.

@aturon aturon closed this as completed Aug 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

4 participants