Workspace giving two different behaviors in Rust
<p>I am learning about Cargo workspaces and have set up the following structure:</p>

<p>Top-level:</p>

<pre><code>[package]
name = "workspacer"
version = "0.1.0"
authors = ["ustulation &lt;zzzzzz@gmail.com&gt;"]

[workspace]
members = ["safe_core", "safe_authenticator", "safe_app"]

# If this is removed then each of the sub-projects will have thier own Cargo.lock file
# will build binaries/objects in their own target/ directories. With this present, it's
# always the parent-projects Cargo.lock and target/ directory used. Need to check if this
# is standard behaviour or some bug about to be fixed.
[lib]
crate_type = ["rlib", "cdylib", "staticlib"]
</code></pre>

<p>A lib called <strong>safe_core</strong> which only needs to produce a <code>.rlib</code></p>

<pre><code>[package]
authors = ["ustulation &lt;zzzzzz@gmail.com&gt;"]
name = "safe_core"
version = "0.1.0"

[dependencies]
maidsafe_utilities = "~0.10.0"
</code></pre>

<p>A lib called <strong>safe_app</strong> which depends on <strong>safe_core</strong> and needs to produce all 3 <code>.rlib</code>, <code>.a</code> and <code>.so</code>:</p>

<pre><code>[package]
name = "safe_app"
version = "0.1.0"
authors = ["ustulation &lt;zzzzzz@gmail.com&gt;"]

[dependencies]
maidsafe_utilities = "~0.10.0"
safe_core = { path = "../safe_core" }

[lib]
crate_type = ["rlib", "cdylib", "staticlib"]
</code></pre>

<p>A lib called <strong>safe_authenticator</strong> which depends on <strong>safe_core</strong> and needs to produce all 3 <code>.rlib</code>, <code>.a</code> and <code>.so</code>:</p>

<pre><code>[package]
name = "safe_authenticator"
version = "0.1.0"
authors = ["ustulation &lt;zzzzzz@gmail.com&gt;"]

[dependencies]
safe_core = { path = "../safe_core" }

[lib]
crate_type = ["rlib", "cdylib", "staticlib"]
</code></pre>

<p>The tree looks like:</p>

<pre class="lang-none prettyprint-override"><code>workspacer
├── Cargo.toml
├── safe_app
│   ├── Cargo.toml
│   └── src
│       └── lib.rs
├── safe_authenticator
│   ├── Cargo.toml
│   └── src
│       └── lib.rs
└── safe_core
    ├── Cargo.toml
    └── src
        └── lib.rs
</code></pre>

<p>If I go to <code>safe_core</code> and build, it creates a <code>target/</code> folder and <code>Cargo.lock</code> files inside the top level <code>workspacer/</code>, which is good. </p>

<p>If I go to <code>safe_authenticator</code> folder and build that it too uses the same <code>target/</code> and <code>Cargo.lock</code> files and hence does not recompile <code>safe_core</code> which is what I want too. Same with <code>safe_app</code>.</p>

<p>However if I remove the <code>[lib]</code> section from the top-level <code>workspacer/Cargo.toml</code>, each of the sub-projects start creating their own <code>Cargo.lock</code> files and their own <code>/target</code> directories inside their respective sub-directories. I have mentioned this in the inline comment in the <code>Cargo.toml</code> of <code>workspacer</code> above (the 1st snippet above).</p>

<p>Is this an expected behavior or a bug or am I doing something wrong ?</p>

<pre class="lang-none prettyprint-override"><code>~$ rustc --version &amp;&amp; cargo --version
rustc 1.15.0-nightly (ba872f270 2016-11-17)
cargo 0.15.0-nightly (1877f59 2016-11-16)
</code></pre>