{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/30094","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/30094/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/30094/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/30094/events","html_url":"https://github.com/rust-lang/rust/issues/30094","id":119308353,"node_id":"MDU6SXNzdWUxMTkzMDgzNTM=","number":30094,"title":"rustdoc --test ignores visibility","user":{"login":"ilammy","id":1256587,"node_id":"MDQ6VXNlcjEyNTY1ODc=","avatar_url":"https://avatars0.githubusercontent.com/u/1256587?v=4","gravatar_id":"","url":"https://api.github.com/users/ilammy","html_url":"https://github.com/ilammy","followers_url":"https://api.github.com/users/ilammy/followers","following_url":"https://api.github.com/users/ilammy/following{/other_user}","gists_url":"https://api.github.com/users/ilammy/gists{/gist_id}","starred_url":"https://api.github.com/users/ilammy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilammy/subscriptions","organizations_url":"https://api.github.com/users/ilammy/orgs","repos_url":"https://api.github.com/users/ilammy/repos","events_url":"https://api.github.com/users/ilammy/events{/privacy}","received_events_url":"https://api.github.com/users/ilammy/received_events","type":"User","site_admin":false},"labels":[{"id":630652267,"node_id":"MDU6TGFiZWw2MzA2NTIyNjc=","url":"https://api.github.com/repos/rust-lang/rust/labels/C-feature-request","name":"C-feature-request","color":"f5f1fd","default":false},{"id":178802147,"node_id":"MDU6TGFiZWwxNzg4MDIxNDc=","url":"https://api.github.com/repos/rust-lang/rust/labels/I-needs-decision","name":"I-needs-decision","color":"e11d21","default":false},{"id":602425123,"node_id":"MDU6TGFiZWw2MDI0MjUxMjM=","url":"https://api.github.com/repos/rust-lang/rust/labels/T-dev-tools","name":"T-dev-tools","color":"bfd4f2","default":false},{"id":203738,"node_id":"MDU6TGFiZWwyMDM3Mzg=","url":"https://api.github.com/repos/rust-lang/rust/labels/T-rustdoc","name":"T-rustdoc","color":"bfd4f2","default":false}],"state":"closed","locked":false,"assignee":{"login":"QuietMisdreavus","id":5217170,"node_id":"MDQ6VXNlcjUyMTcxNzA=","avatar_url":"https://avatars2.githubusercontent.com/u/5217170?v=4","gravatar_id":"","url":"https://api.github.com/users/QuietMisdreavus","html_url":"https://github.com/QuietMisdreavus","followers_url":"https://api.github.com/users/QuietMisdreavus/followers","following_url":"https://api.github.com/users/QuietMisdreavus/following{/other_user}","gists_url":"https://api.github.com/users/QuietMisdreavus/gists{/gist_id}","starred_url":"https://api.github.com/users/QuietMisdreavus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuietMisdreavus/subscriptions","organizations_url":"https://api.github.com/users/QuietMisdreavus/orgs","repos_url":"https://api.github.com/users/QuietMisdreavus/repos","events_url":"https://api.github.com/users/QuietMisdreavus/events{/privacy}","received_events_url":"https://api.github.com/users/QuietMisdreavus/received_events","type":"User","site_admin":false},"assignees":[{"login":"QuietMisdreavus","id":5217170,"node_id":"MDQ6VXNlcjUyMTcxNzA=","avatar_url":"https://avatars2.githubusercontent.com/u/5217170?v=4","gravatar_id":"","url":"https://api.github.com/users/QuietMisdreavus","html_url":"https://github.com/QuietMisdreavus","followers_url":"https://api.github.com/users/QuietMisdreavus/followers","following_url":"https://api.github.com/users/QuietMisdreavus/following{/other_user}","gists_url":"https://api.github.com/users/QuietMisdreavus/gists{/gist_id}","starred_url":"https://api.github.com/users/QuietMisdreavus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuietMisdreavus/subscriptions","organizations_url":"https://api.github.com/users/QuietMisdreavus/orgs","repos_url":"https://api.github.com/users/QuietMisdreavus/repos","events_url":"https://api.github.com/users/QuietMisdreavus/events{/privacy}","received_events_url":"https://api.github.com/users/QuietMisdreavus/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2015-11-28T17:24:55Z","updated_at":"2018-10-24T21:03:13Z","closed_at":"2018-10-24T21:03:13Z","author_association":"NONE","body":"Consider [the following use case](https://gist.github.com/ilammy/9d39d412bcb9c816596d).\n\nI'd expect rustdoc to compile and run doctests only for the _public::function_ since that's the only thing exported from the _example_ crate and thus accessible to rustdoc.\n\nHowever, this is what I see (actual for current stable (1.4.0) and nightly (1.6, bac2b13a5) builds):\n\n```\nilammy@ferocity ~/dev/rustdoc-visibility-issues\n$ rustc --crate-type lib example.rs\n\nilammy@ferocity ~/dev/rustdoc-visibility-issues\n$ rustdoc --test --library-path . example.rs\n\nrunning 3 tests\ntest public::complex_helper_0 ... FAILED\ntest private::real_job_0 ... FAILED\ntest public::function_0 ... ok\n\nfailures:\n\n---- public::complex_helper_0 stdout ----\n        <anon>:2:16: 2:30 error: unresolved name `complex_helper` [E0425]\n<anon>:2     assert_eq!(complex_helper(1, 2), 3);\n                        ^~~~~~~~~~~~~~\n<anon>:2:5: 2:41 note: in this expansion of assert_eq! (defined in <std macros>)\n\nerror: aborting due to previous error\n\n---- private::real_job_0 stdout ----\n        <anon>:3:9: 3:25 error: module `private` is private\n<anon>:3     use example::private;\n                 ^~~~~~~~~~~~~~~~\nerror: aborting due to previous error\n\n\nfailures:\n    private::real_job_0\n    public::complex_helper_0\n\ntest result: FAILED. 1 passed; 2 failed; 0 ignored; 0 measured\n```\n\nRustdoc's intent, as I understand it, is documenting _public_ API. Private items do not show up in docs (unless one explicitly [disables the pass that strips them](https://github.com/rust-lang/rust/issues/15347#issuecomment-47828041)). I believe this should also include doctests.\n\nIt's natural to use the items being documented in doctest examples, but such examples for private items would not compile due to obvious reasons. I believe analyzing the code snippets is a bit overkill for rustdoc, but it's pretty reasonable to simply strip any doctests for private items (at least by default), assuming that they contain internal code examples and will not not compile outside of the crate being documented.\n\nNot using documentation comments for private items or marking private code examples with `ignore` avoids the issue, but personally I think that these are poor workarounds. If private doctests are ignored by default then exporting a previously private item (together with its documentation) is simply a matter of adding **pub** to it (or to its module import in the crate). However, if any of these workarounds are used then one must explicitly convert regular comments to documentation comments and/or remove `ignore` from doctests in order to get everything right.\n\nSome links to (somewhat) related issues:\n- #15347 Add option to include private definition in the documentation\n- #27104 Have rustdoc document private items, except `use` and `extern crate`\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/432827297","html_url":"https://github.com/rust-lang/rust/issues/30094#issuecomment-432827297","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/30094","id":432827297,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjgyNzI5Nw==","user":{"login":"QuietMisdreavus","id":5217170,"node_id":"MDQ6VXNlcjUyMTcxNzA=","avatar_url":"https://avatars2.githubusercontent.com/u/5217170?v=4","gravatar_id":"","url":"https://api.github.com/users/QuietMisdreavus","html_url":"https://github.com/QuietMisdreavus","followers_url":"https://api.github.com/users/QuietMisdreavus/followers","following_url":"https://api.github.com/users/QuietMisdreavus/following{/other_user}","gists_url":"https://api.github.com/users/QuietMisdreavus/gists{/gist_id}","starred_url":"https://api.github.com/users/QuietMisdreavus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuietMisdreavus/subscriptions","organizations_url":"https://api.github.com/users/QuietMisdreavus/orgs","repos_url":"https://api.github.com/users/QuietMisdreavus/repos","events_url":"https://api.github.com/users/QuietMisdreavus/events{/privacy}","received_events_url":"https://api.github.com/users/QuietMisdreavus/received_events","type":"User","site_admin":false},"created_at":"2018-10-24T21:03:13Z","updated_at":"2018-10-24T21:03:13Z","author_association":"MEMBER","body":"Based on the discussion in that PR, it seems like introducing such a change would be too controversial and will cause some existing doctests to stop being executed (by default). I do agree that such doctests are not useful to write, but introducing such a change is basically like breaking existing code - even though we're not causing something to fail that wasn't, we'd be stopping tests from executing that were being run before. Since that behavior has been in place all this time (the original issue was filed almost three years ago!), it's basically too entrenched to give up. I'm closing this issue in light of this."}}
{"actor":{"display_login":"QuietMisdreavus"}}