-
Notifications
You must be signed in to change notification settings - Fork 3
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
Decision: Separator mapping #2
Comments
I am personally a huge fan of mapping to |
The typosquatting section referenced:
I was confused about the multiple negatives and slashes in this sentence, especially when I lost the markdown formatting the first time I copied it (I've fixed it now):
To clarify, I would remove the - if `foo/bar` exists `foo-bar`/`foo_bar` cannot be published, but not vice versa.
+ if `foo/bar` exists, neither `foo-bar` nor `foo_bar` will be allowed to be published. However,
+ if `foo-bar` or `foo_bar` exist, we would choose to allow `foo/bar` to be
+ published, because we don't want to limit the use of names within a crate namespace
+ due to crates outside the namespace existing. Have I understood correctly? To put this another way, this would mean crates.io could have the crates [dependencies]
serde_gelf = "0.1.6"
"serde/gelf" = "1.0.0" and to bring items from each of these into scope, your code would need: use serde_gelf::stuff; // brings in from `serde_gelf`
use serde_gelf as serde_somethingelse_gelf; // need to choose a new name for one of them
use serde_somethingelse_gelf::other_stuff; // can then bring more names into scope with the alias Seems... non-ambiguous to the compiler but potentially a little annoying for the programmer, but probably not common? |
Correct! I've updated the RFC. The intent is to make sure that
This would have to be renamed in Cargo.toml, otherwise both would map as (Worth noting, it's already possible to publish multiple crates that have the same lib name, so Cargo needs to deal with this already)
Correct, however someone could maliciously do this to confuse people, e.g. by publishing |
Ahhh right.
LOL it's really difficult to consider this and #1 and #3 separately... hmmm.... |
Yeah to be clear discussion for that should probably belong on #3, but we might need to merge things. |
Keeping in mind that we also solve the problem of typosquatting mentioned in #3, I have a proposal: Let's make the mapping use foo::bar; // mod `bar` of crate `foo`
use foo_bar; // crate `foo_bar`/`foo-bar`
use foo__bar; // crate `foo/bar`
// We can even expand
use actix__web__middleware__cors; // crate `actix/web/middleware/cors`
// We can even combine
use foo__bar_baz; // crate `foo/bar-baz` There is a relevant issue that proposes the banning of These are the only crates that currently use either of them:
|
I like the double underscore idea, since it maps to the same number of characters. I think it provides a clear path forward:
This encapsulates the cargo side from the rustc side and allows for an easy upgrade path. |
Fixed in Manishearth/rfcs@1986c3d, we have switched to |
Related: #1
The current RFC maps
foo/bar
tofoo_bar
in Rust code.There are alternate mappings that can be selected
The text was updated successfully, but these errors were encountered: