Auto merge of #4828 - SimonSapin:virtual-err, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 18 Dec 2017 15:13:48 +0000 (15:13 +0000)
committerbors <bors@rust-lang.org>
Mon, 18 Dec 2017 15:13:48 +0000 (15:13 +0000)
commit510cf5eb754ad0fc819796b4dbe9d46cf1db7838
tree1605723d7942f3fa920e05b5476408753fcac66f
parent4f6b265f69187c71479c20c8cab03be02662f66e
parent3e0603395c2858d8415bd8b0619f090ee72d964f
Auto merge of #4828 - SimonSapin:virtual-err, r=alexcrichton

Don’t swallow virtual manifest parsing errors

Before this change, `cargo::util::toml::do_read_manifest` ended like this:

```rust
    return match TomlManifest::to_real_manifest(/* … */) {
        Ok(/* … */) => /* … */,
        Err(e) => match TomlManifest::to_virtual_manifest(/* … */) {
            Ok(/* … */) => /* … */,
            Err(..) => Err(e),
        }
    };
```

Errors returned by `to_virtual_manifest` were always ignored. As a result, when something was wrong in a virtual manifest, Cargo would unhelpfully exit with no more output than:

```
error: failed to parse manifest at `/tmp/a/Cargo.toml`

Caused by:
  no `package` section found.
```

http://doc.crates.io/manifest.html#virtual-manifest defines a virtual manifest as “the `package` table is not present”, so let’s first determine if a manifest is virtual based on that criteria, and then only call one of the two methods.

Although it is not mentioned in the documentation, `[project]` seems to be in the code an alias for `[package]`. So let’s preserve that here too.