Skip to content

Commit 767368f

Browse files
committed
Merge branch 'master' into yerke/negative_jobs
2 parents 7c932a4 + 85e79fc commit 767368f

File tree

242 files changed

+1570
-1008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+1570
-1008
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,9 +806,14 @@ impl Execs {
806806
p.build_command()
807807
}
808808

809-
pub fn masquerade_as_nightly_cargo(&mut self) -> &mut Self {
809+
/// Enables nightly features for testing
810+
///
811+
/// The list of reasons should be why nightly cargo is needed. If it is
812+
/// becuase of an unstable feature put the name of the feature as the reason,
813+
/// e.g. `&["print-im-a-teapot"]`
814+
pub fn masquerade_as_nightly_cargo(&mut self, reasons: &[&str]) -> &mut Self {
810815
if let Some(ref mut p) = self.process_builder {
811-
p.masquerade_as_nightly_cargo();
816+
p.masquerade_as_nightly_cargo(reasons);
812817
}
813818
self
814819
}
@@ -1139,17 +1144,20 @@ fn _process(t: &OsStr) -> ProcessBuilder {
11391144

11401145
/// Enable nightly features for testing
11411146
pub trait ChannelChanger {
1142-
fn masquerade_as_nightly_cargo(self) -> Self;
1147+
/// The list of reasons should be why nightly cargo is needed. If it is
1148+
/// becuase of an unstable feature put the name of the feature as the reason,
1149+
/// e.g. `&["print-im-a-teapot"]`.
1150+
fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self;
11431151
}
11441152

11451153
impl ChannelChanger for &mut ProcessBuilder {
1146-
fn masquerade_as_nightly_cargo(self) -> Self {
1154+
fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self {
11471155
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
11481156
}
11491157
}
11501158

11511159
impl ChannelChanger for snapbox::cmd::Command {
1152-
fn masquerade_as_nightly_cargo(self) -> Self {
1160+
fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self {
11531161
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
11541162
}
11551163
}

crates/resolver-tests/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::time::Instant;
1212

1313
use cargo::core::dependency::DepKind;
1414
use cargo::core::resolver::{self, ResolveOpts, VersionPreferences};
15-
use cargo::core::source::{GitReference, SourceId};
15+
use cargo::core::source::{GitReference, QueryKind, SourceId};
1616
use cargo::core::Resolve;
1717
use cargo::core::{Dependency, PackageId, Registry, Summary};
1818
use cargo::util::{CargoResult, Config, Graph, IntoUrl};
@@ -128,11 +128,15 @@ pub fn resolve_with_config_raw(
128128
fn query(
129129
&mut self,
130130
dep: &Dependency,
131+
kind: QueryKind,
131132
f: &mut dyn FnMut(Summary),
132-
fuzzy: bool,
133133
) -> Poll<CargoResult<()>> {
134134
for summary in self.list.iter() {
135-
if fuzzy || dep.matches(summary) {
135+
let matched = match kind {
136+
QueryKind::Exact => dep.matches(summary),
137+
QueryKind::Fuzzy => true,
138+
};
139+
if matched {
136140
self.used.insert(summary.package_id());
137141
f(summary.clone());
138142
}

src/bin/cargo/commands/add.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use cargo::ops::cargo_add::add;
77
use cargo::ops::cargo_add::AddOptions;
88
use cargo::ops::cargo_add::DepOp;
99
use cargo::ops::cargo_add::DepTable;
10+
use cargo::ops::resolve_ws;
1011
use cargo::util::command_prelude::*;
1112
use cargo::util::interning::InternedString;
1213
use cargo::CargoResult;
@@ -193,6 +194,12 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
193194
};
194195
add(&ws, &options)?;
195196

197+
if !dry_run {
198+
// Reload the workspace since we've changed dependencies
199+
let ws = args.workspace(config)?;
200+
resolve_ws(&ws)?;
201+
}
202+
196203
Ok(())
197204
}
198205

src/bin/cargo/commands/install.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ pub fn cli() -> App {
5555
.arg(flag("no-track", "Do not save tracking information"))
5656
.arg_features()
5757
.arg_profile("Install artifacts with the specified profile")
58-
.arg(flag("debug", "Build in debug mode instead of release mode"))
58+
.arg(flag(
59+
"debug",
60+
"Build in debug mode (with the 'dev' profile) instead of release mode",
61+
))
5962
.arg_targets_bins_examples(
6063
"Install only the specified binary",
6164
"Install all binaries",

src/bin/cargo/commands/rustc.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn cli() -> App {
3939
.arg(multi_opt(
4040
CRATE_TYPE_ARG_NAME,
4141
"CRATE-TYPE",
42-
"Comma separated list of types of crates for the compiler to emit (unstable)",
42+
"Comma separated list of types of crates for the compiler to emit",
4343
))
4444
.arg_target_dir()
4545
.arg_manifest_path()
@@ -88,9 +88,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
8888
compile_opts.target_rustc_crate_types = if crate_types.is_empty() {
8989
None
9090
} else {
91-
config
92-
.cli_unstable()
93-
.fail_if_stable_opt(CRATE_TYPE_ARG_NAME, 10083)?;
9491
Some(crate_types)
9592
};
9693
ops::compile(&ws, &compile_opts)?;

src/cargo/core/compiler/compile_kind.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::core::Target;
22
use crate::util::errors::CargoResult;
33
use crate::util::interning::InternedString;
44
use crate::util::{Config, StableHasher};
5-
use anyhow::{bail, Context as _};
5+
use anyhow::Context as _;
66
use serde::Serialize;
77
use std::collections::BTreeSet;
88
use std::fs;
@@ -65,9 +65,6 @@ impl CompileKind {
6565
};
6666

6767
if !targets.is_empty() {
68-
if targets.len() > 1 && !config.cli_unstable().multitarget {
69-
bail!("specifying multiple `--target` flags requires `-Zmultitarget`")
70-
}
7168
return dedup(targets);
7269
}
7370

src/cargo/core/compiler/future_incompat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Support for future-incompatible warning reporting.
22
33
use crate::core::compiler::BuildContext;
4-
use crate::core::{Dependency, PackageId, Workspace};
4+
use crate::core::{Dependency, PackageId, QueryKind, Workspace};
55
use crate::sources::SourceConfigMap;
66
use crate::util::{iter_join, CargoResult, Config};
77
use anyhow::{bail, format_err, Context};
@@ -293,7 +293,7 @@ fn get_updates(ws: &Workspace<'_>, package_ids: &BTreeSet<PackageId>) -> Option<
293293
Ok(dep) => dep,
294294
Err(_) => return false,
295295
};
296-
match source.query_vec(&dep) {
296+
match source.query_vec(&dep, QueryKind::Exact) {
297297
Poll::Ready(Ok(sum)) => {
298298
summaries.push((pkg_id, sum));
299299
false

src/cargo/core/features.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@
8686
//! `CliUnstable. Remove the `(unstable)` note in the clap help text if
8787
//! necessary.
8888
//! 2. Remove `masquerade_as_nightly_cargo` from any tests, and remove
89-
//! `cargo-features` from `Cargo.toml` test files if any.
89+
//! `cargo-features` from `Cargo.toml` test files if any. You can
90+
//! quickly find what needs to be removed by searching for the name
91+
//! of the feature, e.g. `print_im_a_teapot`
9092
//! 3. Update the docs in unstable.md to move the section to the bottom
9193
//! and summarize it similar to the other entries. Update the rest of the
9294
//! documentation to add the new feature.
@@ -414,7 +416,7 @@ features! {
414416
(unstable, profile_rustflags, "", "reference/unstable.html#profile-rustflags-option"),
415417

416418
// Allow specifying rustflags directly in a profile
417-
(unstable, workspace_inheritance, "", "reference/unstable.html#workspace-inheritance"),
419+
(stable, workspace_inheritance, "1.64", "reference/unstable.html#workspace-inheritance"),
418420
}
419421

420422
pub struct Feature {
@@ -720,6 +722,8 @@ const STABILISED_NAMESPACED_FEATURES: &str = "Namespaced features are now always
720722

721723
const STABILIZED_TIMINGS: &str = "The -Ztimings option has been stabilized as --timings.";
722724

725+
const STABILISED_MULTITARGET: &str = "Multiple `--target` options are now always available.";
726+
723727
fn deserialize_build_std<'de, D>(deserializer: D) -> Result<Option<Vec<String>>, D::Error>
724728
where
725729
D: serde::Deserializer<'de>,
@@ -920,7 +924,7 @@ impl CliUnstable {
920924
self.features = Some(feats);
921925
}
922926
"separate-nightlies" => self.separate_nightlies = parse_empty(k, v)?,
923-
"multitarget" => self.multitarget = parse_empty(k, v)?,
927+
"multitarget" => stabilized_warn(k, "1.64", STABILISED_MULTITARGET),
924928
"rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?,
925929
"terminal-width" => self.terminal_width = Some(parse_usize_opt(v)?),
926930
"sparse-registry" => self.sparse_registry = parse_empty(k, v)?,

src/cargo/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub use self::package_id_spec::PackageIdSpec;
88
pub use self::registry::Registry;
99
pub use self::resolver::{Resolve, ResolveVersion};
1010
pub use self::shell::{Shell, Verbosity};
11-
pub use self::source::{GitReference, Source, SourceId, SourceMap};
11+
pub use self::source::{GitReference, QueryKind, Source, SourceId, SourceMap};
1212
pub use self::summary::{FeatureMap, FeatureValue, Summary};
1313
pub use self::workspace::{
1414
find_workspace_root, resolve_relative_path, MaybePackage, Workspace, WorkspaceConfig,

src/cargo/core/registry.rs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
22
use std::task::Poll;
33

44
use crate::core::PackageSet;
5-
use crate::core::{Dependency, PackageId, Source, SourceId, SourceMap, Summary};
5+
use crate::core::{Dependency, PackageId, QueryKind, Source, SourceId, SourceMap, Summary};
66
use crate::sources::config::SourceConfigMap;
77
use crate::util::errors::CargoResult;
88
use crate::util::interning::InternedString;
@@ -19,14 +19,13 @@ pub trait Registry {
1919
fn query(
2020
&mut self,
2121
dep: &Dependency,
22+
kind: QueryKind,
2223
f: &mut dyn FnMut(Summary),
23-
fuzzy: bool,
2424
) -> Poll<CargoResult<()>>;
2525

26-
fn query_vec(&mut self, dep: &Dependency, fuzzy: bool) -> Poll<CargoResult<Vec<Summary>>> {
26+
fn query_vec(&mut self, dep: &Dependency, kind: QueryKind) -> Poll<CargoResult<Vec<Summary>>> {
2727
let mut ret = Vec::new();
28-
self.query(dep, &mut |s| ret.push(s), fuzzy)
29-
.map_ok(|()| ret)
28+
self.query(dep, kind, &mut |s| ret.push(s)).map_ok(|()| ret)
3029
}
3130

3231
fn describe_source(&self, source: SourceId) -> String;
@@ -327,7 +326,7 @@ impl<'cfg> PackageRegistry<'cfg> {
327326
.get_mut(dep.source_id())
328327
.expect("loaded source not present");
329328

330-
let summaries = match source.query_vec(dep)? {
329+
let summaries = match source.query_vec(dep, QueryKind::Exact)? {
331330
Poll::Ready(deps) => deps,
332331
Poll::Pending => {
333332
deps_pending.push(dep_remaining);
@@ -483,7 +482,7 @@ impl<'cfg> PackageRegistry<'cfg> {
483482
for &s in self.overrides.iter() {
484483
let src = self.sources.get_mut(s).unwrap();
485484
let dep = Dependency::new_override(dep.package_name(), s);
486-
let mut results = match src.query_vec(&dep) {
485+
let mut results = match src.query_vec(&dep, QueryKind::Exact) {
487486
Poll::Ready(results) => results?,
488487
Poll::Pending => return Poll::Pending,
489488
};
@@ -575,8 +574,8 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
575574
fn query(
576575
&mut self,
577576
dep: &Dependency,
577+
kind: QueryKind,
578578
f: &mut dyn FnMut(Summary),
579-
fuzzy: bool,
580579
) -> Poll<CargoResult<()>> {
581580
assert!(self.patches_locked);
582581
let (override_summary, n, to_warn) = {
@@ -671,11 +670,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
671670
}
672671
f(lock(locked, all_patches, summary))
673672
};
674-
return if fuzzy {
675-
source.fuzzy_query(dep, callback)
676-
} else {
677-
source.query(dep, callback)
678-
};
673+
return source.query(dep, kind, callback);
679674
}
680675

681676
// If we have an override summary then we query the source
@@ -694,11 +689,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
694689
n += 1;
695690
to_warn = Some(summary);
696691
};
697-
let pend = if fuzzy {
698-
source.fuzzy_query(dep, callback)?
699-
} else {
700-
source.query(dep, callback)?
701-
};
692+
let pend = source.query(dep, kind, callback);
702693
if pend.is_pending() {
703694
return Poll::Pending;
704695
}
@@ -889,7 +880,7 @@ fn summary_for_patch(
889880
// No summaries found, try to help the user figure out what is wrong.
890881
if let Some(locked) = locked {
891882
// Since the locked patch did not match anything, try the unlocked one.
892-
let orig_matches = match source.query_vec(orig_patch) {
883+
let orig_matches = match source.query_vec(orig_patch, QueryKind::Exact) {
893884
Poll::Pending => return Poll::Pending,
894885
Poll::Ready(deps) => deps,
895886
}
@@ -914,7 +905,7 @@ fn summary_for_patch(
914905
// Try checking if there are *any* packages that match this by name.
915906
let name_only_dep = Dependency::new_override(orig_patch.package_name(), orig_patch.source_id());
916907

917-
let name_summaries = match source.query_vec(&name_only_dep) {
908+
let name_summaries = match source.query_vec(&name_only_dep, QueryKind::Exact) {
918909
Poll::Pending => return Poll::Pending,
919910
Poll::Ready(deps) => deps,
920911
}

0 commit comments

Comments
 (0)