Skip to content

Can't call a static method on an anonymous trait #4227

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
lucian1900 opened this issue Dec 19, 2012 · 3 comments
Closed

Can't call a static method on an anonymous trait #4227

lucian1900 opened this issue Dec 19, 2012 · 3 comments
Labels
A-trait-system Area: Trait system
Milestone

Comments

@lucian1900
Copy link

Trying to compile this

enum Node<T> {
    Empty,
    Leaf(T),
}

impl<T> Node<T> {
    fn new() -> @Node<T> {
        @Empty
    }
}

fn main() {
    let n = Node::new();
}

Errors out with this

$ rustc construct.rs 
construct.rs:13:12: 13:21 error: unresolved name
construct.rs:13     let n = Node::new();
                            ^~~~~~~~~
construct.rs:13:12: 13:21 error: use of undeclared module `Node`
construct.rs:13     let n = Node::new();
                            ^~~~~~~~~
construct.rs:13:12: 13:21 error: unresolved name: Node::new
construct.rs:13     let n = Node::new();
                            ^~~~~~~~~
error: aborting due to 3 previous errors
@thestinger
Copy link
Contributor

@lucian1900: You still have to mark static methods with the static keyword. Otherwise the compiler interprets it as using the deprecated implicit self.

@lucian1900
Copy link
Author

Oh, I see. Hopefully 'static' will be deprecated soon as well :)

@ghost ghost assigned catamorphism Feb 20, 2013
@pcwalton
Copy link
Contributor

Closing.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Mar 28, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

4 participants