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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ pub struct PublishOpts<'cfg> {
pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
let pkg = ws.current()?;

// Allow publishing if a registry has been provided, or if there are no nightly
// features enabled.
if opts.registry.is_none() && !pkg.manifest().features().activated().is_empty() {
bail!("cannot publish crates which activate nightly-only cargo features to crates.io")
}

if let Some(ref allowed_registries) = *pkg.publish() {
if !match opts.registry {
Some(ref registry) => allowed_registries.contains(registry),
Expand Down
15 changes: 9 additions & 6 deletions tests/testsuite/cargo_features.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cargotest::ChannelChanger;
use cargotest::support::{execs, project};
use cargotest::support::{execs, project, publish};
use hamcrest::assert_that;

#[test]
Expand Down Expand Up @@ -303,7 +303,9 @@ fn z_flags_rejected() {
}

#[test]
fn publish_rejected() {
fn publish_allowed() {
publish::setup();

let p = project("foo")
.file(
"Cargo.toml",
Expand All @@ -319,9 +321,10 @@ fn publish_rejected() {
.file("src/lib.rs", "")
.build();
assert_that(
p.cargo("publish").masquerade_as_nightly_cargo(),
execs().with_status(101).with_stderr(
"error: cannot publish crates which activate nightly-only cargo features to crates.io",
),
p.cargo("publish")
.arg("--index")
.arg(publish::registry().to_string())
.masquerade_as_nightly_cargo(),
execs().with_status(0),
);
}