Skip to content

Commit c9a332d

Browse files
Merge remote-tracking branch 'rust-lang/master' into 8251-binary-name-env-var
This fixes the nightly breakages of CI
2 parents 7cc6d95 + 40d566d commit c9a332d

File tree

11 files changed

+67
-10
lines changed

11 files changed

+67
-10
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ If you can't install an alternate target, you can set the
118118
`CFG_DISABLE_CROSS_TESTS=1` environment variable to disable these tests. The
119119
Windows cross tests only support the MSVC toolchain.
120120

121-
Some of the nightly tests require the `rustc-dev` component installed. This
122-
component includes the compiler as a library. This may already be installed
123-
with your nightly toolchain, but it if isn't, run `rustup component add
124-
rustc-dev --toolchain=nightly`.
121+
Some of the nightly tests require the `rustc-dev` and `llvm-tools-preview`
122+
rustup components installed. These components include the compiler as a
123+
library. This may already be installed with your nightly toolchain, but if it
124+
isn't, run `rustup component add rustc-dev llvm-tools-preview
125+
--toolchain=nightly`.
125126

126127
There are several other packages in the repo for running specialized tests,
127128
and you will need to run these tests separately by changing into its directory

ci/azure-install-rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ steps:
55
rustup component remove --toolchain=$TOOLCHAIN rust-docs || echo "already removed"
66
rustup update --no-self-update $TOOLCHAIN
77
if [[ "$TOOLCHAIN" == "nightly"* ]]; then
8-
rustup component add --toolchain=$TOOLCHAIN rustc-dev
8+
rustup component add --toolchain=$TOOLCHAIN rustc-dev llvm-tools-preview
99
fi
1010
rustup default $TOOLCHAIN
1111
displayName: Install rust

src/cargo/core/compiler/standard_lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ pub fn resolve_std<'cfg>(
111111
&opts,
112112
&specs,
113113
HasDevUnits::No,
114+
crate::core::resolver::features::ForceAllTargets::No,
114115
)?;
115116
Ok((
116117
resolve.pkg_set,

src/cargo/core/resolver/features.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ pub enum HasDevUnits {
9191
No,
9292
}
9393

94+
/// Flag to indicate that target-specific filtering should be disabled.
95+
#[derive(Copy, Clone, PartialEq)]
96+
pub enum ForceAllTargets {
97+
Yes,
98+
No,
99+
}
100+
94101
/// Flag to indicate if features are requested for a build dependency or not.
95102
#[derive(Copy, Clone, Debug, PartialEq)]
96103
pub enum FeaturesFor {
@@ -110,7 +117,11 @@ impl FeaturesFor {
110117
}
111118

112119
impl FeatureOpts {
113-
fn new(ws: &Workspace<'_>, has_dev_units: HasDevUnits) -> CargoResult<FeatureOpts> {
120+
fn new(
121+
ws: &Workspace<'_>,
122+
has_dev_units: HasDevUnits,
123+
force_all_targets: ForceAllTargets,
124+
) -> CargoResult<FeatureOpts> {
114125
let mut opts = FeatureOpts::default();
115126
let unstable_flags = ws.config().cli_unstable();
116127
opts.package_features = unstable_flags.package_features;
@@ -155,6 +166,9 @@ impl FeatureOpts {
155166
// Dev deps cannot be decoupled when they are in use.
156167
opts.decouple_dev_deps = false;
157168
}
169+
if let ForceAllTargets::Yes = force_all_targets {
170+
opts.ignore_inactive_targets = false;
171+
}
158172
Ok(opts)
159173
}
160174
}
@@ -269,11 +283,12 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
269283
specs: &[PackageIdSpec],
270284
requested_targets: &[CompileKind],
271285
has_dev_units: HasDevUnits,
286+
force_all_targets: ForceAllTargets,
272287
) -> CargoResult<ResolvedFeatures> {
273288
use crate::util::profile;
274289
let _p = profile::start("resolve features");
275290

276-
let opts = FeatureOpts::new(ws, has_dev_units)?;
291+
let opts = FeatureOpts::new(ws, has_dev_units, force_all_targets)?;
277292
if !opts.new_resolver {
278293
// Legacy mode.
279294
return Ok(ResolvedFeatures {

src/cargo/core/resolver/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ use self::types::{FeaturesSet, RcVecIter, RemainingDeps, ResolverProgress};
6969
pub use self::encode::Metadata;
7070
pub use self::encode::{EncodableDependency, EncodablePackageId, EncodableResolve};
7171
pub use self::errors::{ActivateError, ActivateResult, ResolveError};
72-
pub use self::features::HasDevUnits;
72+
pub use self::features::{ForceAllTargets, HasDevUnits};
7373
pub use self::resolve::{Resolve, ResolveVersion};
7474
pub use self::types::{ResolveBehavior, ResolveOpts};
7575

src/cargo/ops/cargo_compile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ pub fn create_bcx<'a, 'cfg>(
327327
&opts,
328328
&specs,
329329
has_dev_units,
330+
crate::core::resolver::features::ForceAllTargets::No,
330331
)?;
331332
let WorkspaceResolve {
332333
mut pkg_set,

src/cargo/ops/cargo_doc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
3333
&opts,
3434
&specs,
3535
HasDevUnits::No,
36+
crate::core::resolver::features::ForceAllTargets::No,
3637
)?;
3738

3839
let ids = ws_resolve.targeted_resolve.specs_to_ids(&specs)?;

src/cargo/ops/cargo_output_metadata.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ fn build_resolve_graph(
123123
&resolve_opts,
124124
&specs,
125125
HasDevUnits::Yes,
126+
crate::core::resolver::features::ForceAllTargets::No,
126127
)?;
127128
// Download all Packages. This is needed to serialize the information
128129
// for every package. In theory this could honor target filtering,

src/cargo/ops/resolve.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use crate::core::compiler::{CompileKind, RustcTargetData};
1414
use crate::core::registry::PackageRegistry;
15-
use crate::core::resolver::features::{FeatureResolver, ResolvedFeatures};
15+
use crate::core::resolver::features::{FeatureResolver, ForceAllTargets, ResolvedFeatures};
1616
use crate::core::resolver::{self, HasDevUnits, Resolve, ResolveOpts};
1717
use crate::core::summary::Summary;
1818
use crate::core::Feature;
@@ -79,6 +79,7 @@ pub fn resolve_ws_with_opts<'cfg>(
7979
opts: &ResolveOpts,
8080
specs: &[PackageIdSpec],
8181
has_dev_units: HasDevUnits,
82+
force_all_targets: ForceAllTargets,
8283
) -> CargoResult<WorkspaceResolve<'cfg>> {
8384
let mut registry = PackageRegistry::new(ws.config())?;
8485
let mut add_patches = true;
@@ -148,6 +149,7 @@ pub fn resolve_ws_with_opts<'cfg>(
148149
specs,
149150
requested_targets,
150151
has_dev_units,
152+
force_all_targets,
151153
)?;
152154

153155
Ok(WorkspaceResolve {

src/cargo/ops/tree/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use self::format::Pattern;
44
use crate::core::compiler::{CompileKind, RustcTargetData};
55
use crate::core::dependency::DepKind;
6-
use crate::core::resolver::{HasDevUnits, ResolveOpts};
6+
use crate::core::resolver::{ForceAllTargets, HasDevUnits, ResolveOpts};
77
use crate::core::{Package, PackageId, PackageIdSpec, Workspace};
88
use crate::ops::{self, Packages};
99
use crate::util::{CargoResult, Config};
@@ -150,13 +150,19 @@ pub fn build_and_print(ws: &Workspace<'_>, opts: &TreeOptions) -> CargoResult<()
150150
} else {
151151
HasDevUnits::No
152152
};
153+
let force_all = if opts.target == Target::All {
154+
ForceAllTargets::Yes
155+
} else {
156+
ForceAllTargets::No
157+
};
153158
let ws_resolve = ops::resolve_ws_with_opts(
154159
ws,
155160
&target_data,
156161
&requested_kinds,
157162
&resolve_opts,
158163
&specs,
159164
has_dev,
165+
force_all,
160166
)?;
161167
// Download all Packages. Some display formats need to display package metadata.
162168
let package_map: HashMap<PackageId, &Package> = ws_resolve

tests/testsuite/features2.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,3 +1720,32 @@ resolver = "2"
17201720
&[("Cargo.toml", &rewritten_toml)],
17211721
);
17221722
}
1723+
1724+
#[cargo_test]
1725+
fn tree_all() {
1726+
// `cargo tree` with the new feature resolver.
1727+
Package::new("log", "0.4.8").feature("serde", &[]).publish();
1728+
let p = project()
1729+
.file(
1730+
"Cargo.toml",
1731+
r#"
1732+
[package]
1733+
name = "foo"
1734+
version = "0.1.0"
1735+
1736+
[target.'cfg(whatever)'.dependencies]
1737+
log = {version="*", features=["serde"]}
1738+
"#,
1739+
)
1740+
.file("src/lib.rs", "")
1741+
.build();
1742+
p.cargo("tree --target=all -Zfeatures=all")
1743+
.masquerade_as_nightly_cargo()
1744+
.with_stdout(
1745+
"\
1746+
foo v0.1.0 ([..]/foo)
1747+
└── log v0.4.8
1748+
",
1749+
)
1750+
.run();
1751+
}

0 commit comments

Comments
 (0)