Skip to content

Can't have impls for a type outside of the defining module. #10071

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
alexcrichton opened this issue Oct 25, 2013 · 1 comment
Closed

Can't have impls for a type outside of the defining module. #10071

alexcrichton opened this issue Oct 25, 2013 · 1 comment

Comments

@alexcrichton
Copy link
Member

I may have regressed this at some point during resolve, but this program fails to compile

pub mod a {                               
    struct A;                             
    impl A {                              
        fn foo(&self) {}                  
    }                                     
}                                         

pub mod b {                               
    use a::A;                             

    impl A {                              
        fn bar(&self) {}                  
    }                                     
}                                         
fn main() {}                                         

with the error message

foo.rs:11:9: 11:10 error: found value name used as a type: DefMod(syntax::ast::DefId{crate: 0, node: 19})        
foo.rs:11     impl A {                                                                                           
                   ^                                                                                             
task '<unnamed>' failed at 'explicit failure', /Users/alex/code/rust-opt/src/libsyntax/diagnostic.rs:75          
task '<unnamed>' failed at 'explicit failure', /Users/alex/code/rust-opt/src/librustc/rustc.rs:396               

I'm not sure if we event want to allow this. If we do, this should get fixed. If we don't, then the error message should be improved.

This seems to me like something that should work, but there may be reasons that it shouldn't...

@alexcrichton
Copy link
Member Author

Closing as a dupe of #7607 (one of the comments on that bug is the exact same as this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant