3 ms·
Yeah I can't see myself ever writing "crate struct Foo" or "crate use foo". :/
by ben0x539 8y ago
Yeah I can't see myself ever writing "crate struct Foo" or "crate use foo". :/
- steveklabnik 8y agoThere’s no plans to remove pub(crate), so you can still use it if you like.
- chrismorgan 8y agoReflecting on it months later, I’m more open to the rest of those changes (I was never against any of them, but I had reservations), but I’m still a bit baffled that bare `crate` as a visibility modifier, instead of `pub(crate)`, was approved. The rest has rationale, but that just doesn’t have compelling rationale (apart saying “this lets us forget about `pub(…)` syntax completely” counts), and met with quite a bit of resistance as well. I may still end up writing it if it goes out in that form; I’m not sure. Certainly removing the need for `extern crate` reduces the probability of confusion for developers old and new after the dust settles.
- burntsushi 8y agoI think you also need to consider consistency with the fact that `crate` can be used to start paths local to the crate in Rust 2018. (I'm not bothered by these changes personally, but I'm not really bothered by the status quo either.)
- ben0x539 8y agoPlain `pub` was concise and local and simple. :<
- steveklabnik 8y agoYou can do that too! pub isn’t going away.
- epage 8y agoI think I saw something about a lint for bare `pub` that isn't visible to the user. I think one of the intents is to make it easier to audit for what is publicly exposed and what isn't. Found it: https://github.com/rust-lang/rust/issues/45521 https://github.com/rust-lang/rust/issues/45521
- ben0x539 8y agoYeah, that's gonna be seriously annoying. :/
- Rusky 8y agoPlain `pub` actually isn't quite local, and that's part of the confusion that `crate` is intended to address. There's also the confusion of looking at a `pub` declaration and not knowing whether or not it's visible to the parent module or visible to the world- at which point maybe you don't want a purely local visibility mechanism.
- ben0x539 8y agoNah it's extremely local, that's why everybody is mad at it
- epage 8y agoI never really thought about it before when seeing the proposals but when looking at the guide's sample code, I wonder if this decision is something we'll end up regretting. As it reads, it sounds like you are declaring something is a crate akin to `mod` which I can see being confusing for new users.
- nixpulvis 8y agoI don't see it as a problem yet, `mod` still means submodule, and `crate` still means top level. The fact one is defining a new grouping structure and the other is defining visibility is slightly unfortunate, but probably not a huge deal.