Skip to content

Allow publishing crates with nightly features #5603

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

Merged
merged 1 commit into from
Jun 7, 2018

Conversation

matklad
Copy link
Member

@matklad matklad commented Jun 3, 2018

closes #5427.

cc @rust-lang/cargo: I remember a vigorous debate over publishing crates with nightly Cargo features, but I can't recollect our exact plan of action. The discussion is logged here: https://paper.dropbox.com/doc/Unstable-Cargo-features-JBYMdsUYcO3FyW8Ubkjoz.

I think we just need to allow to publish crates with unstable cargo features, for the same reason we allow unstable rust features: you need explicit opt-in, even for deps. This is covered by Cargo tests:

#[test]
fn nightly_feature_requires_nightly() {
let p = project("foo")
.file(
"Cargo.toml",
r#"
cargo-features = ["test-dummy-unstable"]
[package]
name = "a"
version = "0.0.1"
authors = []
im-a-teapot = true
"#,
)
.file("src/lib.rs", "")
.build();
assert_that(
p.cargo("build").masquerade_as_nightly_cargo(),
execs().with_status(0).with_stderr(
"\
[COMPILING] a [..]
[FINISHED] [..]
",
),
);
assert_that(
p.cargo("build"),
execs().with_status(101).with_stderr(
"\
error: failed to parse manifest at `[..]`
Caused by:
the cargo feature `test-dummy-unstable` requires a nightly version of Cargo, \
but this is the `stable` channel
",
),
);
}
#[test]
fn nightly_feature_requires_nightly_in_dep() {
let p = project("foo")
.file(
"Cargo.toml",
r#"
[package]
name = "b"
version = "0.0.1"
authors = []
[dependencies]
a = { path = "a" }
"#,
)
.file("src/lib.rs", "")
.file(
"a/Cargo.toml",
r#"
cargo-features = ["test-dummy-unstable"]
[package]
name = "a"
version = "0.0.1"
authors = []
im-a-teapot = true
"#,
)
.file("a/src/lib.rs", "")
.build();
assert_that(
p.cargo("build").masquerade_as_nightly_cargo(),
execs().with_status(0).with_stderr(
"\
[COMPILING] a [..]
[COMPILING] b [..]
[FINISHED] [..]
",
),
);
assert_that(
p.cargo("build"),
execs().with_status(101).with_stderr(
"\
error: failed to load source for a dependency on `a`
Caused by:
Unable to update [..]
Caused by:
failed to parse manifest at `[..]`
Caused by:
the cargo feature `test-dummy-unstable` requires a nightly version of Cargo, \
but this is the `stable` channel
",
),
);
}
.

I am not sure if we have ever implemented crates.io side of validation?

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@matklad matklad force-pushed the publish-nightly-features branch 2 times, most recently from 90f34f7 to 65a3e85 Compare June 3, 2018 07:24
@matklad matklad force-pushed the publish-nightly-features branch from 65a3e85 to 39a3709 Compare June 3, 2018 07:25
@matklad
Copy link
Member Author

matklad commented Jun 6, 2018

ping @rust-lang/cargo, @joshtriplett and @aturon :)

This is blocking clippy folks right now I think (@oli-obk has more details).

I personally am 100% fine with allowing publishing crates with unstable features, but I want to make sure the team is OK with this as well :)

@aturon
Copy link
Member

aturon commented Jun 6, 2018

@matklad I agree with this move and your rationale. My only concern would be for unstable Cargo features that affect the publication process/metadata, but we can handle that case-by-case.

@matklad
Copy link
Member Author

matklad commented Jun 7, 2018

My only concern would be for unstable Cargo features that affect the publication process/metadata, but we can handle that case-by-case.

Double checked that current unstable features do not affect publication, and it seems to be the case. Moreover, any feature which affects metadata/publication needs some special handling from crates.io, so, in some sense, such features are crates.io features and not Cargo features.

@bors r+

@bors
Copy link
Contributor

bors commented Jun 7, 2018

📌 Commit 39a3709 has been approved by matklad

@bors
Copy link
Contributor

bors commented Jun 7, 2018

⌛ Testing commit 39a3709 with merge e2348c2...

bors added a commit that referenced this pull request Jun 7, 2018
Allow publishing crates with nightly features

closes #5427.

cc @rust-lang/cargo: I remember a vigorous debate over publishing crates with nightly Cargo features, but I can't recollect our exact plan of action. The discussion is logged here: https://paper.dropbox.com/doc/Unstable-Cargo-features-JBYMdsUYcO3FyW8Ubkjoz.

I think we just need to allow to publish crates with unstable cargo features, for the same reason we allow unstable rust features: you need explicit opt-in, even for deps. This is covered by Cargo tests: https://github.com/rust-lang/cargo/blob/9f097787b04b06cdde4fc42b26a531b22c1b37a6/tests/testsuite/cargo_features.rs#L115-L215.

I am not sure if we have ever implemented crates.io side of validation?
@bors
Copy link
Contributor

bors commented Jun 7, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: matklad
Pushing e2348c2 to master...

@bors bors merged commit 39a3709 into rust-lang:master Jun 7, 2018
@matklad matklad deleted the publish-nightly-features branch June 7, 2018 07:58
@ehuss ehuss added this to the 1.28.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The publish-lockfile option is not usable
6 participants