{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/17591","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/17591/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/17591/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/17591/events","html_url":"https://github.com/rust-lang/rust/issues/17591","id":44187983,"number":17591,"title":"Compile error using re-exported empty generic struct from another crate","user":{"login":"tomassedovic","id":104339,"avatar_url":"https://avatars.githubusercontent.com/u/104339?v=3","gravatar_id":"","url":"https://api.github.com/users/tomassedovic","html_url":"https://github.com/tomassedovic","followers_url":"https://api.github.com/users/tomassedovic/followers","following_url":"https://api.github.com/users/tomassedovic/following{/other_user}","gists_url":"https://api.github.com/users/tomassedovic/gists{/gist_id}","starred_url":"https://api.github.com/users/tomassedovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomassedovic/subscriptions","organizations_url":"https://api.github.com/users/tomassedovic/orgs","repos_url":"https://api.github.com/users/tomassedovic/repos","events_url":"https://api.github.com/users/tomassedovic/events{/privacy}","received_events_url":"https://api.github.com/users/tomassedovic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-compiletime","name":"I-compiletime","color":"e11d21"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-wrong","name":"I-wrong","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-09-27T19:33:21Z","updated_at":"2015-06-01T17:52:37Z","closed_at":null,"body":"I've defined a unit-like struct that is generic over one type (`Phantom<T>`) in an inner module of a library. It is then re-exported from the root module. Instantiating it within the library works fine, but trying to use it from a program that links to the library results in a compile error.\r\n\r\nlibrary `foo.rs`:\r\n```\r\npub use inner::Phantom;\r\n\r\npub mod inner {\r\n    pub struct Phantom<T>;\r\n}\r\n```\r\n\r\nbinary `main.rs`:\r\n```\r\nextern crate foo;\r\n\r\nuse foo::Phantom;\r\n\r\nstruct A;\r\n\r\nfn main() {\r\n    Phantom::<A>;\r\n}\r\n```\r\n\r\ncompile error:\r\n```\r\n$ rustc --crate-type lib foo.rs && rustc main.rs -L .\r\nmain.rs:8:15: 8:16 error: too many type parameters provided: expected at most 0 parameter(s), found 1 parameter(s) [E0087]\r\nmain.rs:8     Phantom::<A>;\r\n                        ^\r\nerror: aborting due to previous error\r\n```\r\n\r\nFor this to trigger, `foo` has to be a separate crate -- if I recreate the same module hierarchy within `main.rs`, it compiles.\r\n\r\nIf `main.rs` doesn't use the re-export, but accesses the struct directly (`use foo::inner::Phantom`) it also compiles fine.\r\n\r\nIf I add any fields to the struct, it compiles without any issues as well.\r\n\r\nTriggered on:\r\n```\r\n$ rustc --version verbose\r\nrustc 0.12.0-nightly (d64b4103d 2014-09-26 21:47:47 +0000)\r\nbinary: rustc\r\ncommit-hash: d64b4103d688f38c2e9e2daf966d50beeb383f1e\r\ncommit-date: 2014-09-26 21:47:47 +0000\r\nhost: x86_64-unknown-linux-gnu\r\nrelease: 0.12.0-nightly\r\n```"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/107653302","html_url":"https://github.com/rust-lang/rust/issues/17591#issuecomment-107653302","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/17591","id":107653302,"user":{"login":"nham","id":546409,"avatar_url":"https://avatars.githubusercontent.com/u/546409?v=3","gravatar_id":"","url":"https://api.github.com/users/nham","html_url":"https://github.com/nham","followers_url":"https://api.github.com/users/nham/followers","following_url":"https://api.github.com/users/nham/following{/other_user}","gists_url":"https://api.github.com/users/nham/gists{/gist_id}","starred_url":"https://api.github.com/users/nham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nham/subscriptions","organizations_url":"https://api.github.com/users/nham/orgs","repos_url":"https://api.github.com/users/nham/repos","events_url":"https://api.github.com/users/nham/events{/privacy}","received_events_url":"https://api.github.com/users/nham/received_events","type":"User","site_admin":false},"created_at":"2015-06-01T17:52:37Z","updated_at":"2015-06-01T17:52:37Z","body":"Triage: testing this now (`rustc 1.2.0-nightly (78c4d5387 2015-05-30) (built 2015-05-31)`)\r\nresults in compilation of `foo.rs` failing:\r\n\r\n```\r\nlib.rs:4:24: 4:25 error: parameter `T` is never used [E0392]\r\nlib.rs:4     pub struct Phantom<T>;\r\n                                ^\r\nlib.rs:4:24: 4:25 help: consider removing `T` or using a marker such as `core::marker::PhantomData`\r\nerror: aborting due to previous error\r\n```\r\n\r\nThis appears to be consistent with [RFC 738](https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md), so it seems this issue can be closed."}}