rust-lang / rust-lang/reference

Document the type privacy restrictions

Open
#1,557 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-visibility
Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

The following program is rejected (though the sub module alone would be accepted with a warning):

mod sub {
    struct Priv;
    pub fn get_value() -> Priv { todo!() }
}

fn main() {
    sub::get_value();
}

I believe the restrictions which cause this rejection aren't described at present in the Reference.

I think the best available documentation is in rfc2145.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Rust Reference sections covering visibility and the linked RFC 2145, then compare them with the rejected example and the warning behavior for the sub module. Done means the Reference explains the type privacy restrictions that make the complete program invalid and distinguishes them from the warning case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.