Skip to content

'use' declarations are private to the containing *scope*, not *module* #1187

Description

@carols10cents

This sentence says:

Like items, use declarations are private to the containing module, by default.

However, I think this should say:

Like items, use declarations 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): rust-lang/book#2766

This would also be a great place to link to the scopes section that this PR adds (and which I like a lot): #1040

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-useArea: use imports

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions