]> git.proxmox.com Git - cargo.git/commitdiff
Auto merge of #9290 - ehuss:non-member-features, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 22 Mar 2021 14:40:21 +0000 (14:40 +0000)
committerbors <bors@rust-lang.org>
Mon, 22 Mar 2021 14:40:21 +0000 (14:40 +0000)
Refactor feature handling, and improve error messages.

This changes the way feature strings are handled with an eye towards fixing some improper handling and to improve error messages. The key change is to stop treating all features as free-form strings and instead try to handle them as typed values. This helps avoid needing to deal with parsing different feature syntax (like `dep:` or `foo/bar`) or forgetting to handle it properly.

Overview of refactoring changes:

* `RequestedFeatures` changed to an enum to differentiate between features coming from the command-line, and those that are from a dependency.
* Moved parsing of CLI features to an earlier stage (now stored in `CompileOptions`), and ensures that they are properly handled as `FeatureValue` instead of strings.
* Pushed some feature validation earlier. For example, `DetailedTomlDependency` now validates things so you can see the location for the errant `Cargo.toml` (previously some validation was deep in the resolver, which provided poor errors).

This is a pretty large PR, but at the core it is just changing `RequestedFeatures` and then dealing with the fallout from that. Hopefully this is an improvement overall.

List of user-visible changes:

* Fix handling in resolver V2 of `--features bar?/feat` and `--features dep:bar`
* Better error handling for `bar/feat` and `dep:bar` in dependency declarations.
* Feature keys in the `[features]` table can no longer contain slashes.
* Fixed a minor issue with `cargo tree -e features --all-features -Z namespaced-features`
* Fixed a panic with `cargo tree` involving `-Z weak-dep-features`

I did a small amount of benchmarking, and I wasn't able to record much of a difference.

1  2 
src/cargo/core/workspace.rs
src/cargo/ops/cargo_package.rs
src/cargo/ops/fix.rs
src/cargo/ops/registry.rs
src/cargo/util/command_prelude.rs
src/cargo/util/toml/mod.rs

Simple merge
index afa41efd21ccdab86d0c18eb787aa4432b9325ce,c8454f1250b12a741107f96f86c1a946c83afee4..fd37e2c730e9cd10eaf2e9eb378020847dbf8989
@@@ -6,7 -6,13 +6,8 @@@ use std::path::{Path, PathBuf}
  use std::rc::Rc;
  use std::sync::Arc;
  
 -use flate2::read::GzDecoder;
 -use flate2::{Compression, GzBuilder};
 -use log::debug;
 -use tar::{Archive, Builder, EntryType, Header, HeaderMode};
 -
  use crate::core::compiler::{BuildConfig, CompileMode, DefaultExecutor, Executor};
+ use crate::core::resolver::CliFeatures;
  use crate::core::{Feature, Shell, Verbosity, Workspace};
  use crate::core::{Package, PackageId, PackageSet, Resolve, Source, SourceId};
  use crate::sources::PathSource;
Simple merge
Simple merge
Simple merge
Simple merge