Skip to content

Support imports of the form use {foo,bar}#10808

Merged
bors merged 1 commit into
rust-lang:masterfrom
lilyball:use-braces
Dec 11, 2013
Merged

Support imports of the form use {foo,bar}#10808
bors merged 1 commit into
rust-lang:masterfrom
lilyball:use-braces

Conversation

@lilyball

@lilyball lilyball commented Dec 4, 2013

Copy link
Copy Markdown
Contributor

This fixes #10806.

@alexcrichton

Copy link
Copy Markdown
Member

This should be discussed before merging.

Personally, I'm not sure I'm entirely in favor of this.

@lilyball

lilyball commented Dec 4, 2013

Copy link
Copy Markdown
Contributor Author

Any particular reason why not? I was surprised that it wasn't already supported. If I define a bunch of things at the top level of my library, and I need to use them from sub-modules, I see no reason why I should have to use a separate use statement for every item.

@huonw

huonw commented Dec 4, 2013

Copy link
Copy Markdown
Contributor

Iirc, we already support the more general use foo, bar::{baz,aux}, quz::*;.

@pcwalton

pcwalton commented Dec 4, 2013

Copy link
Copy Markdown
Contributor

I'm in favor but needs discussion.

@alexcrichton

Copy link
Copy Markdown
Member

I have added this to the meeting agenda. As always, this could be decided before that though!

@ben0x539

ben0x539 commented Dec 8, 2013

Copy link
Copy Markdown
Contributor

If we support use foo, bar; I don't really see the point of allowing use {foo, bar}; It seems reasonable that the {} globbing only works after a ::, we already can't do use blah::blah_{foo, bar};

@pcwalton

Copy link
Copy Markdown
Contributor

Consensus at the meeting was to get rid of use foo, bar; and accept this PR.

@lilyball

Copy link
Copy Markdown
Contributor Author

I didn't even know use foo, bar was legal until @ben0x539's comment.

@huonw

huonw commented Dec 10, 2013

Copy link
Copy Markdown
Contributor

The check-fast driver concatenates all the non xfail-fast rpass tests into one file as submodules, so the crate root is different; I guess just xfailing the test would be ok.

@lilyball

Copy link
Copy Markdown
Contributor Author

Hrm, make check-fast fail on my machine with xfail-fast, but it fails for a different reason, so I guess that's.. good?

@lilyball

Copy link
Copy Markdown
Contributor Author

r? @alexcrichton

@lilyball

Copy link
Copy Markdown
Contributor Author

Pushed a fix for the pretty-printer. make check-stage1-pretty now passes. r? @alexcrichton

bors added a commit that referenced this pull request Dec 11, 2013
@bors bors merged commit bd36b06 into rust-lang:master Dec 11, 2013
@lilyball lilyball deleted the use-braces branch December 11, 2013 18:40
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 2, 2023
These unit tests generate non-compilable code.  I did NOT `bless` them on purpose because the stderr output is not good.

I'm surprised we don't auto-compile the suggestions here - is this something that can be easily enabled?

See rust-lang#10808
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 2, 2023
Fix missing block for unsafe code

If a block is declared as unsafe, it needs an extra layer of curly braces around it.

Fixes rust-lang#10808

This code adds handling for `UnsafeSource::UserProvided` block, i.e. `unsafe { ... }`. Note that we do not handle the `UnsafeSource::CompilerGenerated` as it seems to not be possible to generate that with the user code (?), or at least doesn't seem to be needed to be handled explicitly.

There is an issue with this code: it does not add an extra indentation for the unsafe blocks. I think this is a relatively minor concern for such an edge case, and should probably be done by a separate PR (fixing compile bug is more important than getting styling perfect especially when `rustfmt` will fix it anyway)

```rust
// original code
unsafe {
  ...
}

// code that is now generated by this PR
{ unsafe {
  ...
} }

// what we would ideally like to get
{
  unsafe {
    ...
  }
}
```

changelog: [`single_match`](https://rust-lang.github.io/rust-clippy/master/#single_match): Fix suggestion for `unsafe` blocks
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.

Cannot parse use {foo, bar}

6 participants