{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/16734","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/16734/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/16734/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/16734/events","html_url":"https://github.com/rust-lang/rust/issues/16734","id":41018664,"number":16734,"title":"Linker error with non-reachable type","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-visibility","name":"A-visibility","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/P-low","name":"P-low","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2014-08-24T20:44:29Z","updated_at":"2015-11-14T17:56:25Z","closed_at":null,"body":"```rust\r\n// foo.rs\r\npub use foo::Bar;\r\n\r\npub fn test() -> Bar<int> {\r\n    fail!()\r\n}\r\n\r\nmod foo {\r\n    pub type Bar<T> = Result<T, Baz>;\r\n\r\n    pub struct Baz;\r\n\r\n    impl Baz {\r\n        pub fn foo(&self) {}\r\n    }\r\n}\r\n```\r\n\r\n```rust\r\n// bar.rs\r\nextern crate foo;\r\n\r\nfn main() {\r\n    match foo::test() {\r\n        Ok(..) => {}\r\n        Err(e) => e.foo()\r\n    }\r\n}\r\n```\r\n\r\n```\r\n$ rustc --crate-type lib foo.rs      \r\nfoo.rs:13:9: 13:29 warning: code is never used: `foo`, #[warn(dead_code)] on by default\r\nfoo.rs:13         pub fn foo(&self) {}\r\n                  ^~~~~~~~~~~~~~~~~~~~\r\n$ rustc bar.rs -L.    \r\nerror: linking with `cc` failed: exit code: 1\r\nnote: cc '-m64' '-L' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'bar' 'bar.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-nodefaultlibs' '-Wl,--gc-sections' '-pie' '-Wl,--as-needed' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-4e7c5e5c.rlib' '/home/alex/libfoo.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsync-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustrt-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4e7c5e5c.rlib' '-L' '.' '-L' '/home/alex/.rust' '-L' '/home/alex' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-ldl' '-lpthread' '-lgcc_s' '-lpthread' '-lc' '-lm' '-lcompiler-rt'\r\nnote: bar.o: In function `main::hbeb79415393a4115faa':\r\nbar.rs:(.text._ZN4main20hbeb79415393a4115faaE+0x45): undefined reference to `foo::Baz::foo::h3d69757c908833a5Yaa'\r\ncollect2: error: ld returned 1 exit status\r\n\r\nerror: aborting due to previous error\r\n\r\n```\r\n\r\nThere are a number of problems with this, and they may likely all be inter-related.\r\n\r\n* [ ] linker error\r\n* [ ] dead code which is not actually dead code\r\n* [ ] it should be an error that `Baz` is a publicly visible private type.\r\n\r\nNominating due to the publicly visible private type not generating an error."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/156727851","html_url":"https://github.com/rust-lang/rust/issues/16734#issuecomment-156727851","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/16734","id":156727851,"user":{"login":"petrochenkov","id":5751617,"avatar_url":"https://avatars.githubusercontent.com/u/5751617?v=3","gravatar_id":"","url":"https://api.github.com/users/petrochenkov","html_url":"https://github.com/petrochenkov","followers_url":"https://api.github.com/users/petrochenkov/followers","following_url":"https://api.github.com/users/petrochenkov/following{/other_user}","gists_url":"https://api.github.com/users/petrochenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/petrochenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petrochenkov/subscriptions","organizations_url":"https://api.github.com/users/petrochenkov/orgs","repos_url":"https://api.github.com/users/petrochenkov/repos","events_url":"https://api.github.com/users/petrochenkov/events{/privacy}","received_events_url":"https://api.github.com/users/petrochenkov/received_events","type":"User","site_admin":false},"created_at":"2015-11-14T17:56:25Z","updated_at":"2015-11-14T17:56:25Z","body":">It should complain that make_greeter() returns a private type.\r\n\r\nСommon sense may say this, but the current edition of [RFC 136](https://github.com/rust-lang/rfcs/blob/master/text/0136-no-privates-in-public.md) says otherwise.\r\nBasically, if a type is marked as `pub`, then you can use it in any public interfaces even if other crates can't name it."}}