rust-lang / rust-lang/reference
'use' declarations are private to the containing *scope*, not *module*
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- PR merge metrics
- PR metrics pending
Description
Like items,
usedeclarations are private to the containing module, by default.
However, I think this should say:
Like items,
usedeclarations are private to the containing scope, by default.
For example, this code doesn't compile because the use is private to the function's scope, not the module that contains both the const and the function:
const FOO: NonZeroI8 = NonZeroI8::new(5);
fn bar() {
use std::num::NonZeroI8;
let another = NonZeroI8::new(3);
}
The usage of the word "module" here caused confusion in the book (which I'm also working on clarifying, but the filer assumed the reference would be more precise than the book and I don't think it is in this case): https://github.com/rust-lang/book/issues/2766
This would also be a great place to link to the scopes section that this PR adds (and which I like a lot): https://github.com/rust-lang/reference/pull/1040
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open src/items/use-declarations.md at the cited sentence and compare its wording with the scope example in the issue. Change the reference from "module" to "scope" and consider linking the scopes section introduced by PR 1040. The documentation should accurately describe the scope of a use declaration and avoid the confusion noted in the Rust Book issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100