-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow extern crate
to take a list of crates
#1875
Conversation
@sbeckeriv I think the macro should be sufficient, and it should be provided by a lib. |
@goandylok I understand its not very useful for projects with small amounts of crates. My recent small project had 16 externs, cargo currently has 20, librustc_driver has 21 and some servo libs have over 50. I would be interested in more data but I am unsure how I would gather it. I listed the diff issue in the drawbacks. There have been suggestions on how to make it better in Thanks |
This seems quite sensible and sufficiently consistent with |
Seems like a win to me, albeit a minor one (I can't say multiple |
extern crate
to take a list of crates
👍 I like this change. Its minor but still an improvement, and much better than suggestions by other people who suggested to remove extern crate entirely when cargo is being used (wouldn't like that to happen). |
@Diggsey It's also not consistent with I dislike this change. It's confusing, it drops readability, diffability, and grepability, and I don't think it gives enough of a benefit. You write
Basically, I don't think it's a good change. I wouldn't want |
@ubsan I left grepability out of the list of drawbacks because Crates can be related. The list format could be used to group them together. I will try to add this idea to the RFC. Thanks |
I don't like this. If we're going to try to make the crate system easier to use, we should just move to the implicit extern idea. There should only be one place in which information is placed: if you are depending on a crate in I don't dislike this because of syntax, I dislike it because it feels like a stopgap measure until we do do the automatic extern crate thing, which I consider inevitable. |
As @ubsan noted, the analog to And, like @camlorn, I think there's a good change we will make adding the |
Note that I will also disagree with implicit extern. I don't think that it's useful enough either. |
@ubsan I don't think we will do it because it is a significant improvement for Rust programmers: putting something that explicitly names the crate in two places is annoying, but way less annoying than the least annoying bits of C++. However, it is a learnability point, putting the same info in two places is an anti-pattern, and it should not be hard to specify or implement. Maybe this is a bit off topic. |
I see someone was assigned and then unassigned. I updated the rfc drawbacks with the concerns around future crate improvements and the differing opinions around use/mod/extern. The conversation here seems to have died off. It appears to be a small improvement. Do concerns around formatting and its constancy related to mod/use out weigh the small improvement? Thanks everyone for your input! |
the
It is consistent with future use/mod items:
|
There are extern blocks to list FFI functions.
Maybe have something similar for crates.
|
5e342b4
to
4afb6de
Compare
Dearest Reviewer, I hope all is well. I have been enjoying rust immensely. Recently I was working on converting an old ruby project to rust. I was adding my 20ish crate to my project and after scrolling down I thought, "Do I need all the `extern crate` lines?". I set out by making a macro, my first, which was easy and fun. I posted my macro to reddit wondering if I had missed something. After many great comments someone suggested an rfc with a wink face[1](https://www.reddit.com/r/rust/comments/5q7ssv/long_list_of_externs/). I figured why not. I wrote up this start and then went over to [internals.rust-lang.org](https://internals.rust-lang.org/t/pre-rfc-boil-down-externs/4676). Here I received advice on syntax and missing cases to my rfc. Excellent feedback again! I hope its considered to allow one line of `extern crate` to accept many crates. I understand completely if it is not. Thanks again Becker Updated with alt-syntax
@liigo I added the suggestion to the rfc. Thanks! |
@withoutboats ping on this RFC. I suspect that, given the questions in the air about where we want to take the module system within the ergonomics initiative, we should probably postpone this for the time being. What do you think? |
@rfcbot fcp postpone I agree; for now a macro seems sufficient. |
Team member @withoutboats has proposed to postpone this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period is now complete. |
Closing as postponed. Thanks @sbeckeriv! We'll look forward to a more general RFC on |
Rendered
Dearest Reviewer,
I hope all is well. I have been enjoying rust immensely. Recently I was
working on converting an old ruby project to rust. I was adding my 20ish
crate to my project and after scrolling down I thought, "Do I need all the
extern crate
lines?".I set out by making a macro, my first, which was easy and fun. I posted
my macro to reddit wondering if I had missed something. After many
great comments someone suggested an rfc with a wink
face1.
I figured why not. I wrote up this start and then went over to
internals.rust-lang.org.
Here I received advice on syntax and missing cases to my rfc. Excellent
feedback again!
I hope its considered to allow one line of
extern crate
to accept manycrates. I understand completely if it is not.
Thanks again
Becker