-
Notifications
You must be signed in to change notification settings - Fork 626
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 feature names to begin with numbers #1331
Allow feature names to begin with numbers #1331
Conversation
Diesel 1.2 had planned on renaming our `large-tables` and `huge-tables` features to `32-column-tables` and `64-column-tables` respectively, while also introducing the `128-column-tables` feature. This change was made several months ago in Diesel. Cargo will happily accept those as feature names, and resolve them properly from other crates. However while publishing Diesel 1.2, I ran into a snag mid-release when I realized that Cargo is incorrectly assuming that a feature name must be the same as a crate name. I suspect this is an artifact of the fact that feature names often are crate names (and perhaps in the past that was the only form of feature?). However, now they are an entirely separate thing, and we should allow the same set of feature names that Cargo does. (As an aside, do we want to apply the same 64 character limit that we apply to crate names to feature names?) Fixes rust-lang#1329.
711f849
to
4bf9efa
Compare
The workaround we had to do (putting an |
Before merging this, I'd like to make sure we're not removing an important restriction... but this restriction is from before my time. @alexcrichton do you recall why feature names have to be valid crate names (and have the restriction that they not start with a number)? It looks like |
To be clear, I don't think the current code is checking that the feature name is that of an existing crate, I think the code is checking that a valid feature name has the same restrictions as valid crate names. |
Crate names needed to not start with a number in the sense that they're Rust identifiers, and IIRC it was just easy to use the same validation for feature names. AFAIK feature names are always specified as strings or not interpreted in an identifier context so it should be fine to allow things like numbers out in front. |
Thanks @alexcrichton! I'm good with this then. Will comment again when I've got this deployed to prod. bors: r+ |
1331: Allow feature names to begin with numbers r=carols10cents Diesel 1.2 had planned on renaming our `large-tables` and `huge-tables` features to `32-column-tables` and `64-column-tables` respectively, while also introducing the `128-column-tables` feature. This change was made several months ago in Diesel. Cargo will happily accept those as feature names, and resolve them properly from other crates. However while publishing Diesel 1.2, I ran into a snag mid-release when I realized that Cargo is incorrectly assuming that a feature name must be the same as a crate name. I suspect this is an artifact of the fact that feature names often are crate names (and perhaps in the past that was the only form of feature?). However, now they are an entirely separate thing, and we should allow the same set of feature names that Cargo does. (As an aside, do we want to apply the same 64 character limit that we apply to crate names to feature names?) Fixes #1329.
Build succeeded |
Deployed, and I was able to publish a crate with a feature that starts with a number! |
Permit '+' in feature name, as in "c++20" Up front: I am familiar with the several discussions linked by rust-lang/crates-io-cargo-teams#41 (comment), and the conversation beginning at #1331 (comment). This PR is not motivated by attempting to match whatever behavior Cargo currently has. Instead, it's a small thing I think we can decide now whether to allow. But it's necessary to say no corresponding Cargo change is required to accommodate this crates.io change. This PR updates feature validation during publish to accept e.g. "c++20" and "dependency/c++20". We continue to not accept "c++20/feature" as the prefix before the slash would normally refer to a crate name of a dependency and a '+' would not be allowed in those. I am interested in using such feature names in https://github.com/dtolnay/cxx. In a Cargo.toml plusses appear as: ```toml [features] default = ["c++20"] "c++20" = ["my-dependency/c++20"] ``` To give some slight further justification for why this particular ascii character above other possible characters we might allow: `+` is pretty common in OS package names in a way that no other currently disallowed character is. Some examples pulled arbitrarily from `apt-cache pkgnames | rg '\+'`: - https://packages.debian.org/buster/dvd+rw-tools - https://packages.debian.org/buster/elpa-ghub+ - https://packages.debian.org/buster/libarpack++2-dev - https://packages.debian.org/buster/libdwarf++0 - https://packages.debian.org/buster/libelf++0 - https://packages.debian.org/buster/magics++ - https://packages.debian.org/buster/memtest86+ - https://packages.debian.org/buster/minisat+ - https://packages.debian.org/buster/paw++ - https://packages.debian.org/buster/swish++ - https://packages.debian.org/buster/vera++ - https://packages.debian.org/buster/voro++ The actual names of the projects contain `+`; various ones in the descriptions in the above links are styled as ARPACK++, Memtest86+, Magics++, Paw++, MinSat+, SWISH++, Vera++, Voro++. When binding to something like this behind a feature, using `+` in the feature name is the most intuitive.
Diesel 1.2 had planned on renaming our
large-tables
andhuge-tables
features to
32-column-tables
and64-column-tables
respectively,while also introducing the
128-column-tables
feature. This change wasmade several months ago in Diesel. Cargo will happily accept those
as feature names, and resolve them properly from other crates.
However while publishing Diesel 1.2, I ran into a snag mid-release when
I realized that Cargo is incorrectly assuming that a feature name must
be the same as a crate name. I suspect this is an artifact of the fact
that feature names often are crate names (and perhaps in the past that
was the only form of feature?).
However, now they are an entirely separate thing, and we should allow
the same set of feature names that Cargo does. (As an aside, do we want
to apply the same 64 character limit that we apply to crate names to
feature names?)
Fixes #1329.