Skip to content

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

Closed
@luci1900

Description

@luci1900

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions