Skip to content

Static methods are not resolved under the trait name cross-crate #4097

Closed
@brson

Description

@brson

In this test num::Num2::from_int2 can't be resolved. If all defined in the same crate then it's fine.

static_fn_num_aux.rs

pub mod num {
    pub trait Num2 {
        static pure fn from_int2(n: int) -> self;
    }
}

pub mod float {
    impl float: num::Num2 {
        static pure fn from_int2(n: int) -> float { return n as float;  }
    }
}

static-fn-num.rs

// aux-build:static_fn_num_aux.rs

extern mod mycore(name ="static_fn_num_aux");

use mycore::num;

fn main() {
    let _1:float = num::Num2::from_int2(1i);
}
/home/brian/dev/rust/src/test/run-pass/static-fn-num.rs:35:19: 35:39 error: not a module: Num2
/home/brian/dev/rust/src/test/run-pass/static-fn-num.rs:35     let _1:float = num::Num2::from_int2(1i);
                                                                              ^~~~~~~~~~~~~~~~~~~~
/home/brian/dev/rust/src/test/run-pass/static-fn-num.rs:35:19: 35:39 error: use of undeclared module `num::Num2`
/home/brian/dev/rust/src/test/run-pass/static-fn-num.rs:35     let _1:float = num::Num2::from_int2(1i);
                                                                              ^~~~~~~~~~~~~~~~~~~~
/home/brian/dev/rust/src/test/run-pass/static-fn-num.rs:35:19: 35:39 error: unresolved name: num::Num2::from_int2
/home/brian/dev/rust/src/test/run-pass/static-fn-num.rs:35     let _1:float = num::Num2::from_int2(1i);
                                                                              ^~~~~~~~~~~~~~~~~~~~
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