Skip to content

Conversation

@matklad
Copy link
Contributor

@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
Contributor

@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
Contributor 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