Skip to content

reference: clarify use declaration location #31863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2016

Conversation

matklad
Copy link
Member

@matklad matklad commented Feb 24, 2016

Reference implied that use declarations may appear only at the top of blocks and modules, but it is not the case, and the following is valid:

fn foo() {
    let x = 92;
    use baz::bar;
}

r? @steveklabnik

@steveklabnik
Copy link
Member

@bors: r+ rollup

thanks!

@bors
Copy link
Collaborator

bors commented Feb 24, 2016

📌 Commit 397ab31 has been approved by steveklabnik

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 24, 2016
…labnik

Reference implied that use declarations may appear *only* at the top of blocks and modules, but it is not the case, and the following is valid:

```Rust
fn foo() {
    let x = 92;
    use baz::bar;
}
```

r? @steveklabnik
bors added a commit that referenced this pull request Feb 24, 2016
@bors bors merged commit 397ab31 into rust-lang:master Feb 25, 2016
@matklad
Copy link
Member Author

matklad commented Mar 3, 2016

and the following is valid.

I was sure I had actually compiled it! But that is in fact invalid and fails with imports are not allowed after non-item statements E0154.

However the following is valid (definitely compiled and run this time!)

fn main() {
    fn foo() {}
    use std::io;
}

So documentation fix is actually correct.

@matklad matklad deleted the clarify-reference branch July 9, 2019 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants