{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/22261","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/22261/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/22261/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/22261/events","html_url":"https://github.com/rust-lang/rust/issues/22261","id":57568418,"number":22261,"title":"private type in return type of public API is allowed?","user":{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars.githubusercontent.com/u/173127?v=3","gravatar_id":"","url":"https://api.github.com/users/pnkfelix","html_url":"https://github.com/pnkfelix","followers_url":"https://api.github.com/users/pnkfelix/followers","following_url":"https://api.github.com/users/pnkfelix/following{/other_user}","gists_url":"https://api.github.com/users/pnkfelix/gists{/gist_id}","starred_url":"https://api.github.com/users/pnkfelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnkfelix/subscriptions","organizations_url":"https://api.github.com/users/pnkfelix/orgs","repos_url":"https://api.github.com/users/pnkfelix/repos","events_url":"https://api.github.com/users/pnkfelix/events{/privacy}","received_events_url":"https://api.github.com/users/pnkfelix/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-nominated","name":"I-nominated","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-13T07:33:15Z","updated_at":"2015-02-13T07:42:22Z","closed_at":null,"body":"While reviewing the list of active feature gates and double-checking the behavior of `visible_private_types`, I found that the check is not working for e.g. the program below:\r\n\r\n```rust\r\nmod a {\r\n    #[derive(Debug)]\r\n    struct S { x: i32 }\r\n    pub fn foo() -> S { S { x: 3 } }\r\n    impl S { }\r\n}\r\n\r\nmod b {\r\n    use a;\r\n\r\n    #[cfg(expected)]\r\n    pub fn call_foo() {\r\n        let s: a::S = a::foo();\r\n        println!(\"{:?}\", s);\r\n    }\r\n\r\n    #[cfg(not(expected))]\r\n    pub fn call_foo() {\r\n        let s = a::foo();\r\n        println!(\"{:?}\", s);\r\n    }\r\n}\r\n\r\nfn main() {\r\n    b::call_foo();\r\n}\r\n```\r\n\r\nIn the playpen, the above compiles and runs.  I expected to see an error due to the type of `a::foo` returning the private type `a::S`. "},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/74216382","html_url":"https://github.com/rust-lang/rust/issues/22261#issuecomment-74216382","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/22261","id":74216382,"user":{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars.githubusercontent.com/u/173127?v=3","gravatar_id":"","url":"https://api.github.com/users/pnkfelix","html_url":"https://github.com/pnkfelix","followers_url":"https://api.github.com/users/pnkfelix/followers","following_url":"https://api.github.com/users/pnkfelix/following{/other_user}","gists_url":"https://api.github.com/users/pnkfelix/gists{/gist_id}","starred_url":"https://api.github.com/users/pnkfelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnkfelix/subscriptions","organizations_url":"https://api.github.com/users/pnkfelix/orgs","repos_url":"https://api.github.com/users/pnkfelix/repos","events_url":"https://api.github.com/users/pnkfelix/events{/privacy}","received_events_url":"https://api.github.com/users/pnkfelix/received_events","type":"User","site_admin":false},"created_at":"2015-02-13T07:42:22Z","updated_at":"2015-02-13T07:42:22Z","body":"Reading over the original PR #17401 i noticed that it seems like there was no `compile-fail` test covering return types of top-level functions (even though that was the reference example given in the description for the PR).  (Is it possible that this case was not actually implemented?  Seems super unlikely, but ...)"}}