[rust-dev] name resolution rule for enum variants?

Phil Dawes rustphil at phildawes.net
Sat Jul 5 13:43:07 PDT 2014


Hello!

I was surprised to find the following compile and run without any bother:

#[deriving(Show)]
pub enum MyEnum {
    Path
}
fn main() {
    let p = Path::new("/filepath/");
    let p2 = Path;

    println!("{}",p.as_str());
    println!("{}",p2);
}

% ./run
Some(/filepath)
Path

What is the name resolution rule that stops MyEnum's Path overriding the
posix Path struct? I'm interested because racer gets this wrong at the
moment.

Thanks,

Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140705/0a00fb51/attachment.html>


More information about the Rust-dev mailing list