-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Make extern mod xxx
optional
#11811
Comments
I never want to be linked to crates by using an import. Additionally, this is trivially broken in the face of glob reexports. I feel like the ever-so-slight cost in extra lines is an extremely small price for ease of recognition of shadowing, as well as explicitly knowing what I'm linking to. |
Is is possible that we can have syntax such as:
as opposed to:
This way it keeps the explicitness of every crate in use, while removing all of the supposed extra |
yeah that'd be nice actually. On Sun, Jan 26, 2014 at 12:39 AM, Davis Silverman
|
I don't like this. However, I'd be totally fine with |
As others said, |
Then why not make that crystal clear? After all, in python, a simple import is all it takes. Why bother with declaring twice something that can be declared only once? By making it clear that this is required in the linking process, this decision makes much more sense. People coming from C wouldn't complain that much if they knew this is similar to their beloved "-l" linker argument. By the way, I don't know if that really makes sense, but I've seen a lot of in-crate |
A The term "crate" is cute Rust jargon, but it's not going to help in understanding the language. If we're worried about clarity then we should drop the usage of "crate" completely and call them libraries. |
I opened #11819 to cover the issue of multiple inclusions per statement. This issue should stay on the topic of removing |
It's now |
@huonw: I think it would probably link to the module name by default, as it does for Rust crates. The header is just the missing data to make it into a proper |
That would certainly work too. |
After making |
How will the compiler distinguish between a module called Anyway, I don't understand why |
The compiler can not distinguish between two modules both named |
It can distinguish between with |
Do you want |
I don't care whether or not mod foo to be optional. |
Why do you see it as a different case than |
|
Both the Both are required to compile the crate if they're unused. I don't see why you think there's a difference in terms of what can be inferred between internal and external modules. |
I agree with pcwalton's comment and cmr's comment. I vaguely recall past discussion of changing how (One big reason that I do not like the idea of inferring external linkage from the existing uses of |
@thestinger: I don't think there's a difference in terms of what can be inferred between internal and external modules. Why distinguish between them? If a type or function can't be found in internal mod, it should be linked to external crate. |
@liigo would the
|
Here, |
This seems to make the assumption that the common case will not be to use Even if it can figure out that In any case, I think we need more information about the packaging system before a clear path for |
If crate files are in local file system, rustc can find them. And you can
|
I agree that the proposed solution introduces some confusion and ambiguity.
To make clear that |
You can write use {a, b, c}. On Mon, Jan 27, 2014 at 12:30 PM, Piotr notifications@github.com wrote:
|
The conversation about allowing multiple modules per |
While doing separate archaeology, I happened to run into this RFC from 1.5 years ago: [rust-dev] RFC: Load external crates with "use" It might be useful for the proponent(s) of this feature to read over the discussion thread there. |
Closing, a change such as this now needs to go through the official RFC process |
…shearth disallow calls to `LintContext::struct_span_lint` and `TyCtxt::struct_span_lint_hir` `LintContext::struct_span_lint` and `TyCtxt::struct_span_lint_hir` don't show the link to the clippy documentation, see: rust-lang#11805 In rust-lang#11810, the last few calls to those methods were replaced with `span_lint_*`. It seems like we should just disallow them altogether so that no new code tries to use them. The existing `disallowed_methods` lint makes this easy. changelog: none
…ishearth Remove internal `compiler_lint_functions` lint This internal lint has effectively been superseded by `disallowed_methods` when we started using that in rust-lang#11811 (I didn't even know that we also had this internal lint at the time of when I created that PR). Some of the methods that this looks for also don't exist anymore (`span_lint_note` and `span_lint_help`), though there was one that that lint had but wasn't disallowed in clippy.toml (`LintContext::lint`) changelog: none
@brson suggested me open a new issue on this idea, "it seems worth exploring", he said. He don't want this to get buried in #11745 too. See comments in #11787.
The Problem
To use a crate in rust, at least two lines are required currently:
In a large project, we need to use many crates, particularly after extra's dissolution (#11787). The more crates we need, the more lines
extern mod xxx
need to write, which is a pain:The Solution
Since we must write lines such as
use xxx::a::b
, the compiler should always knows I'm using the crate xxx. So theextern mod xxx
is redundant, it should be optional, unless compiler got ambiguity in non-common situations.The text was updated successfully, but these errors were encountered: