Allow publishing crates with nightly features
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 3 Jun 2018 07:10:13 +0000 (10:10 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 3 Jun 2018 07:25:05 +0000 (10:25 +0300)
src/cargo/ops/registry.rs
tests/testsuite/cargo_features.rs

index 5ed9c7f25b3217bf4b6719c2c3e90cc913060b98..7f848fd701659ce877e7e03cbd14cecd570ea290 100644 (file)
@@ -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),
index 82de8867666983f31bdd34dd47e48566c6e7cdf6..0e95257f351e5896f8ca1ebad7a0148b1745c0bf 100644 (file)
@@ -1,5 +1,5 @@
 use cargotest::ChannelChanger;
-use cargotest::support::{execs, project};
+use cargotest::support::{execs, project, publish};
 use hamcrest::assert_that;
 
 #[test]
@@ -303,7 +303,9 @@ fn z_flags_rejected() {
 }
 
 #[test]
-fn publish_rejected() {
+fn publish_allowed() {
+    publish::setup();
+
     let p = project("foo")
         .file(
             "Cargo.toml",
@@ -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),
     );
 }