Skip to content
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

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

Merged
merged 1 commit into from
Dec 11, 2013
Merged

Conversation

lilyball
Copy link
Contributor

@lilyball lilyball commented Dec 4, 2013

This fixes #10806.

@alexcrichton
Copy link
Member

This should be discussed before merging.

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

@lilyball
Copy link
Contributor Author

lilyball commented Dec 4, 2013

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
Copy link
Member

huonw commented Dec 4, 2013

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

@pcwalton
Copy link
Contributor

pcwalton commented Dec 4, 2013

I'm in favor but needs discussion.

@alexcrichton
Copy link
Member

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

@ben0x539
Copy link
Contributor

ben0x539 commented Dec 8, 2013

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
Contributor

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

@lilyball
Copy link
Contributor Author

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

@huonw
Copy link
Member

huonw commented Dec 10, 2013

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

r? @alexcrichton

@lilyball
Copy link
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