Skip to content

Commit 39a3709

Browse files
committed
Allow publishing crates with nightly features
1 parent 9f09778 commit 39a3709

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/cargo/ops/registry.rs

-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ pub struct PublishOpts<'cfg> {
4343
pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
4444
let pkg = ws.current()?;
4545

46-
// Allow publishing if a registry has been provided, or if there are no nightly
47-
// features enabled.
48-
if opts.registry.is_none() && !pkg.manifest().features().activated().is_empty() {
49-
bail!("cannot publish crates which activate nightly-only cargo features to crates.io")
50-
}
51-
5246
if let Some(ref allowed_registries) = *pkg.publish() {
5347
if !match opts.registry {
5448
Some(ref registry) => allowed_registries.contains(registry),

tests/testsuite/cargo_features.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cargotest::ChannelChanger;
2-
use cargotest::support::{execs, project};
2+
use cargotest::support::{execs, project, publish};
33
use hamcrest::assert_that;
44

55
#[test]
@@ -303,7 +303,9 @@ fn z_flags_rejected() {
303303
}
304304

305305
#[test]
306-
fn publish_rejected() {
306+
fn publish_allowed() {
307+
publish::setup();
308+
307309
let p = project("foo")
308310
.file(
309311
"Cargo.toml",
@@ -319,9 +321,10 @@ fn publish_rejected() {
319321
.file("src/lib.rs", "")
320322
.build();
321323
assert_that(
322-
p.cargo("publish").masquerade_as_nightly_cargo(),
323-
execs().with_status(101).with_stderr(
324-
"error: cannot publish crates which activate nightly-only cargo features to crates.io",
325-
),
324+
p.cargo("publish")
325+
.arg("--index")
326+
.arg(publish::registry().to_string())
327+
.masquerade_as_nightly_cargo(),
328+
execs().with_status(0),
326329
);
327330
}

0 commit comments

Comments
 (0)