Skip to content

Commit 2a55b90

Browse files
committed
Merge branch 'master' of https://github.com/rust-lang/cargo into help
* 'master' of https://github.com/rust-lang/cargo: (21 commits) Remove TOML incompatibility hacks Use a more compact way to compare versions Remove broken link in contrib docs. Change diesel compatibility messages Temporarily revert curl-sys update. Update curl-sys Bump Cargo's curl requirement to 7.79.0 Revert "When a dependency does not have a version, git or path, fails directly" Fix warnings from better precision of `dead_code` lint Improve "wrong output" error. Add some contributor docs for debugging testsuite tests. Fix warnings when documenting with `--document-private-items` Update changelog for 1.56 Bump to 0.58.0 Fix rustc --profile=dev unstable check. config.md: fix typo Enable some tests on windows. Fix `cargo fix --edition` on stable. Enable strip test on macos. Remove log ...
2 parents e8519ec + 790b01f commit 2a55b90

File tree

22 files changed

+290
-155
lines changed

22 files changed

+290
-155
lines changed

CHANGELOG.md

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,62 @@
11
# Changelog
22

3+
## Cargo 1.57 (2021-12-02)
4+
[18751dd3...HEAD](https://github.com/rust-lang/cargo/compare/18751dd3...HEAD)
5+
6+
### Added
7+
8+
- The `rev` option for a git dependency now supports git references that start
9+
with `refs/`. An example where this can be used is to depend on a pull
10+
request from a service like GitHub before it is merged.
11+
[#9859](https://github.com/rust-lang/cargo/pull/9859)
12+
13+
### Changed
14+
15+
### Fixed
16+
17+
- Removed a log message (from `CARGO_LOG`) that may leak tokens.
18+
[#9873](https://github.com/rust-lang/cargo/pull/9873)
19+
20+
### Nightly only
21+
22+
323
## Cargo 1.56 (2021-10-21)
4-
[cebef295...HEAD](https://github.com/rust-lang/cargo/compare/cebef295...HEAD)
24+
[cebef295...rust-1.56.0](https://github.com/rust-lang/cargo/compare/cebef295...rust-1.56.0)
525

626
### Added
727

8-
- Added support for the [`rust-version`](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-rust-version-field)
9-
field in a crate's metadata and the `--ignore-rust-version` command line option.
10-
- Build scripts can now pass additional linker arguments for binaries or all
28+
- 🎉 Cargo now supports the 2021 edition.
29+
More information may be found in the [edition
30+
guide](https://doc.rust-lang.org/nightly/edition-guide/rust-2021/index.html).
31+
[#9800](https://github.com/rust-lang/cargo/pull/9800)
32+
- 🎉 Added the
33+
[`rust-version`](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-rust-version-field)
34+
field to `Cargo.toml` to specify the minimum supported Rust version, and the
35+
`--ignore-rust-version` command line option to override it.
36+
[#9732](https://github.com/rust-lang/cargo/pull/9732)
37+
- Added the `[env]` table to config files to specify environment variables to
38+
set.
39+
[docs](https://doc.rust-lang.org/nightly/cargo/reference/config.html#env)
40+
[#9411](https://github.com/rust-lang/cargo/pull/9411)
41+
- `[patch]` tables may now be specified in config files.
42+
[docs](https://doc.rust-lang.org/nightly/cargo/reference/config.html#patch)
43+
[#9839](https://github.com/rust-lang/cargo/pull/9839)
44+
- `cargo doc` now supports the `--example` and `--examples` flags.
45+
[#9808](https://github.com/rust-lang/cargo/pull/9808)
46+
- 🎉 Build scripts can now pass additional linker arguments for binaries or all
1147
linkable targets. [docs](https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#outputs-of-the-build-script)
1248
[#9557](https://github.com/rust-lang/cargo/pull/9557)
1349
- Added support for the `-p` flag for `cargo publish` to publish a specific
1450
package in a workspace. `cargo package` also now supports `-p` and
1551
`--workspace`.
1652
[#9559](https://github.com/rust-lang/cargo/pull/9559)
53+
- Added documentation about third-party registries.
54+
[#9830](https://github.com/rust-lang/cargo/pull/9830)
55+
- Added the `{sha256-checksum}` placeholder for URLs in a registry `config.json`.
56+
[docs](https://doc.rust-lang.org/nightly/cargo/reference/registries.html#index-format)
57+
[#9801](https://github.com/rust-lang/cargo/pull/9801)
58+
- Added a warning when a dependency does not have a library.
59+
[#9771](https://github.com/rust-lang/cargo/pull/9771)
1760

1861
### Changed
1962

@@ -27,11 +70,56 @@
2770
filename. This allows multiple copies to be cached at once, and matches the
2871
behavior on other platforms (except `msvc`).
2972
[#9653](https://github.com/rust-lang/cargo/pull/9653)
73+
- `cargo new` now generates an example that doesn't generate a warning with
74+
clippy.
75+
[#9796](https://github.com/rust-lang/cargo/pull/9796)
76+
- `cargo fix --edition` now only applies edition-specific lints.
77+
[#9846](https://github.com/rust-lang/cargo/pull/9846)
78+
- Improve resolver message to include dependency requirements.
79+
[#9827](https://github.com/rust-lang/cargo/pull/9827)
80+
- `cargo fix` now has more debug logging available with the `CARGO_LOG`
81+
environment variable.
82+
[#9831](https://github.com/rust-lang/cargo/pull/9831)
83+
- Changed `cargo fix --edition` to emit a warning when on the latest stable
84+
edition when running on stable instead of generating an error.
85+
[#9792](https://github.com/rust-lang/cargo/pull/9792)
86+
- `cargo install` will now determine all of the packages to install before
87+
starting the installation, which should help with reporting errors without
88+
partially installing.
89+
[#9793](https://github.com/rust-lang/cargo/pull/9793)
90+
- The resolver report for `cargo fix --edition` now includes differences for
91+
dev-dependencies.
92+
[#9803](https://github.com/rust-lang/cargo/pull/9803)
93+
- `cargo fix` will now show better diagnostics for abnormal errors from `rustc`.
94+
[#9799](https://github.com/rust-lang/cargo/pull/9799)
95+
- Entries in `cargo --list` are now deduplicated.
96+
[#9773](https://github.com/rust-lang/cargo/pull/9773)
97+
- Aliases are now included in `cargo --list`.
98+
[#9764](https://github.com/rust-lang/cargo/pull/9764)
3099

31100
### Fixed
32101

102+
- Fixed panic with build-std of a proc-macro.
103+
[#9834](https://github.com/rust-lang/cargo/pull/9834)
104+
- Fixed running `cargo` recursively from proc-macros while running `cargo fix`.
105+
[#9818](https://github.com/rust-lang/cargo/pull/9818)
106+
- Return an error instead of a stack overflow for command alias loops.
107+
[#9791](https://github.com/rust-lang/cargo/pull/9791)
108+
33109
### Nightly only
34110

111+
- Added `[future-incompat-report]` config section.
112+
[#9774](https://github.com/rust-lang/cargo/pull/9774)
113+
- Fixed value-after-table error with custom named profiles.
114+
[#9789](https://github.com/rust-lang/cargo/pull/9789)
115+
- Added the `different-binary-name` feature to support specifying a
116+
non-rust-identifier for a binary name.
117+
[docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#different-binary-name)
118+
[#9627](https://github.com/rust-lang/cargo/pull/9627)
119+
- Added a profile option to select the codegen backend.
120+
[docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#codegen-backend)
121+
[#9118](https://github.com/rust-lang/cargo/pull/9118)
122+
35123

36124
## Cargo 1.55 (2021-09-09)
37125
[aa8b0929...rust-1.55.0](https://github.com/rust-lang/cargo/compare/aa8b0929...rust-1.55.0)
@@ -100,6 +188,9 @@
100188
includes several changes, such as new behavior when run on WSL, and using
101189
the system `xdg-open` on Linux.
102190
[#9583](https://github.com/rust-lang/cargo/pull/9583)
191+
- Updated to libcurl 7.78.
192+
[#9809](https://github.com/rust-lang/cargo/pull/9809)
193+
[#9810](https://github.com/rust-lang/cargo/pull/9810)
103194

104195
### Fixed
105196

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo"
3-
version = "0.57.0"
3+
version = "0.58.0"
44
edition = "2018"
55
authors = ["Yehuda Katz <wycats@gmail.com>",
66
"Carl Lerche <me@carllerche.com>",

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
33
use crate::{basic_manifest, paths, project, Project};
44
use lazy_static::lazy_static;
5-
use std::path::PathBuf;
5+
use std::path::{Path, PathBuf};
66
use std::sync::Mutex;
77

88
lazy_static! {
99
static ref ECHO_WRAPPER: Mutex<Option<PathBuf>> = Mutex::new(None);
10+
static ref ECHO: Mutex<Option<PathBuf>> = Mutex::new(None);
1011
}
1112

1213
/// Returns the path to an executable that works as a wrapper around rustc.
@@ -39,6 +40,45 @@ pub fn echo_wrapper() -> PathBuf {
3940
path
4041
}
4142

43+
/// Returns the path to an executable that prints its arguments.
44+
///
45+
/// Do not expect this to be anything fancy.
46+
pub fn echo() -> PathBuf {
47+
let mut lock = ECHO.lock().unwrap();
48+
if let Some(path) = &*lock {
49+
return path.clone();
50+
}
51+
if let Ok(path) = cargo_util::paths::resolve_executable(Path::new("echo")) {
52+
*lock = Some(path.clone());
53+
return path;
54+
}
55+
// Often on Windows, `echo` is not available.
56+
let p = project()
57+
.at(paths::global_root().join("basic-echo"))
58+
.file("Cargo.toml", &basic_manifest("basic-echo", "1.0.0"))
59+
.file(
60+
"src/main.rs",
61+
r#"
62+
fn main() {
63+
let mut s = String::new();
64+
let mut it = std::env::args().skip(1).peekable();
65+
while let Some(n) = it.next() {
66+
s.push_str(&n);
67+
if it.peek().is_some() {
68+
s.push(' ');
69+
}
70+
}
71+
println!("{}", s);
72+
}
73+
"#,
74+
)
75+
.build();
76+
p.cargo("build").run();
77+
let path = p.bin("basic-echo");
78+
*lock = Some(path.clone());
79+
path
80+
}
81+
4282
/// Returns a project which builds a cargo-echo simple subcommand
4383
pub fn echo_subcommand() -> Project {
4484
let p = project()

src/cargo/core/compiler/custom_build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,11 @@ impl BuildOutput {
566566
let (key, value) = match (key, value) {
567567
(Some(a), Some(b)) => (a, b.trim_end()),
568568
// Line started with `cargo:` but didn't match `key=value`.
569-
_ => bail!("Wrong output in {}: `{}`", whence, line),
569+
_ => bail!("invalid output in {}: `{}`\n\
570+
Expected a line with `cargo:key=value` with an `=` character, \
571+
but none was found.\n\
572+
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \
573+
for more information about build script outputs.", whence, line),
570574
};
571575

572576
// This will rewrite paths if the target directory has been moved.

src/cargo/core/compiler/job_queue.rs

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ use cargo_util::ProcessBuilder;
6262
use crossbeam_utils::thread::Scope;
6363
use jobserver::{Acquired, Client, HelperThread};
6464
use log::{debug, info, trace};
65+
use semver::Version;
6566

6667
use super::context::OutputFile;
6768
use super::job::{
@@ -74,9 +75,8 @@ use crate::core::compiler::future_incompat::{
7475
FutureBreakageItem, FutureIncompatReportPackage, OnDiskReports,
7576
};
7677
use crate::core::resolver::ResolveBehavior;
77-
use crate::core::{FeatureValue, PackageId, Shell, TargetKind};
78+
use crate::core::{PackageId, Shell, TargetKind};
7879
use crate::util::diagnostic_server::{self, DiagnosticPrinter};
79-
use crate::util::interning::InternedString;
8080
use crate::util::machine_message::{self, Message as _};
8181
use crate::util::CargoResult;
8282
use crate::util::{self, internal, profile};
@@ -1249,55 +1249,27 @@ impl<'cfg> DrainState<'cfg> {
12491249

12501250
fn back_compat_notice(&self, cx: &Context<'_, '_>, unit: &Unit) -> CargoResult<()> {
12511251
if unit.pkg.name() != "diesel"
1252-
|| unit.pkg.version().major != 1
1252+
|| unit.pkg.version() >= &Version::new(1, 4, 8)
12531253
|| cx.bcx.ws.resolve_behavior() == ResolveBehavior::V1
12541254
|| !unit.pkg.package_id().source_id().is_registry()
12551255
|| !unit.features.is_empty()
12561256
{
12571257
return Ok(());
12581258
}
1259-
let other_diesel = match cx
1259+
if !cx
12601260
.bcx
12611261
.unit_graph
12621262
.keys()
1263-
.find(|unit| unit.pkg.name() == "diesel" && !unit.features.is_empty())
1263+
.any(|unit| unit.pkg.name() == "diesel" && !unit.features.is_empty())
12641264
{
1265-
Some(u) => u,
1266-
// Unlikely due to features.
1267-
None => return Ok(()),
1268-
};
1269-
let mut features_suggestion: BTreeSet<_> = other_diesel.features.iter().collect();
1270-
let fmap = other_diesel.pkg.summary().features();
1271-
// Remove any unnecessary features.
1272-
for feature in &other_diesel.features {
1273-
if let Some(feats) = fmap.get(feature) {
1274-
for feat in feats {
1275-
if let FeatureValue::Feature(f) = feat {
1276-
features_suggestion.remove(&f);
1277-
}
1278-
}
1279-
}
1265+
return Ok(());
12801266
}
1281-
features_suggestion.remove(&InternedString::new("default"));
1282-
let features_suggestion = toml::to_string(&features_suggestion).unwrap();
1283-
1284-
cx.bcx.config.shell().note(&format!(
1267+
cx.bcx.config.shell().note(
12851268
"\
12861269
This error may be due to an interaction between diesel and Cargo's new
1287-
feature resolver. Some workarounds you may want to consider:
1288-
- Add a build-dependency in Cargo.toml on diesel to force Cargo to add the appropriate
1289-
features. This may look something like this:
1290-
1291-
[build-dependencies]
1292-
diesel = {{ version = \"{}\", features = {} }}
1293-
1294-
- Try using the previous resolver by setting `resolver = \"1\"` in `Cargo.toml`
1295-
(see <https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions>
1296-
for more information).
1270+
feature resolver. Try updating to diesel 1.4.8 to fix this error.
12971271
",
1298-
unit.pkg.version(),
1299-
features_suggestion
1300-
))?;
1272+
)?;
13011273
Ok(())
13021274
}
13031275
}

src/cargo/core/manifest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ struct SerializedTarget<'a> {
259259
/// Serialized as a list of strings for historical reasons.
260260
kind: &'a TargetKind,
261261
/// Corresponds to `--crate-type` compiler attribute.
262-
/// See https://doc.rust-lang.org/reference/linkage.html
262+
/// See <https://doc.rust-lang.org/reference/linkage.html>
263263
crate_types: Vec<CrateType>,
264264
name: &'a str,
265265
src_path: Option<&'a PathBuf>,
266266
edition: &'a str,
267267
#[serde(rename = "required-features", skip_serializing_if = "Option::is_none")]
268268
required_features: Option<Vec<&'a str>>,
269269
/// Whether docs should be built for the target via `cargo doc`
270-
/// See https://doc.rust-lang.org/cargo/commands/cargo-doc.html#target-selection
270+
/// See <https://doc.rust-lang.org/cargo/commands/cargo-doc.html#target-selection>
271271
doc: bool,
272272
doctest: bool,
273273
/// Whether tests should be run for the target (`test` field in `Cargo.toml`)

src/cargo/core/resolver/version_prefs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::util::interning::InternedString;
99

1010
/// A collection of preferences for particular package versions.
1111
///
12-
/// This is built up with [`prefer_package_id`] and [`prefer_dep`], then used to sort the set of
13-
/// summaries for a package during resolution via [`sort_summaries`].
12+
/// This is built up with [`Self::prefer_package_id`] and [`Self::prefer_dependency`], then used to sort the set of
13+
/// summaries for a package during resolution via [`Self::sort_summaries`].
1414
///
1515
/// As written, a version is either "preferred" or "not preferred". Later extensions may
1616
/// introduce more granular preferences.

src/cargo/ops/fix.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ use cargo_util::{exit_status_to_string, is_simple_exit_code, paths, ProcessBuild
5050
use log::{debug, trace, warn};
5151
use rustfix::diagnostics::Diagnostic;
5252
use rustfix::{self, CodeFix};
53+
use semver::Version;
5354

5455
use crate::core::compiler::{CompileKind, RustcTargetData, TargetInfo};
5556
use crate::core::resolver::features::{DiffMap, FeatureOpts, FeatureResolver};
5657
use crate::core::resolver::{HasDevUnits, Resolve, ResolveBehavior};
57-
use crate::core::{Edition, MaybePackage, Workspace};
58+
use crate::core::{Edition, MaybePackage, PackageId, Workspace};
5859
use crate::ops::resolve::WorkspaceResolve;
5960
use crate::ops::{self, CompileOptions};
6061
use crate::util::diagnostic_server::{Message, RustfixDiagnosticServer};
@@ -321,17 +322,21 @@ fn check_resolver_change(ws: &Workspace<'_>, opts: &FixOptions) -> CargoResult<(
321322
}
322323

323324
fn report_maybe_diesel(config: &Config, resolve: &Resolve) -> CargoResult<()> {
324-
if resolve
325-
.iter()
326-
.any(|pid| pid.name() == "diesel" && pid.version().major == 1)
327-
&& resolve.iter().any(|pid| pid.name() == "diesel_migrations")
328-
{
325+
fn is_broken_diesel(pid: PackageId) -> bool {
326+
pid.name() == "diesel" && pid.version() < &Version::new(1, 4, 8)
327+
}
328+
329+
fn is_broken_diesel_migration(pid: PackageId) -> bool {
330+
pid.name() == "diesel_migrations" && pid.version().major <= 1
331+
}
332+
333+
if resolve.iter().any(is_broken_diesel) && resolve.iter().any(is_broken_diesel_migration) {
329334
config.shell().note(
330335
"\
331336
This project appears to use both diesel and diesel_migrations. These packages have
332337
a known issue where the build may fail due to the version 2 resolver preventing
333-
feature unification between those two packages. See
334-
<https://github.com/rust-lang/cargo/issues/9450> for some potential workarounds.
338+
feature unification between those two packages. Please update to at least diesel 1.4.8
339+
to prevent this issue from happening.
335340
",
336341
)?;
337342
}
@@ -857,8 +862,7 @@ impl FixArgs {
857862
if edition.supports_compat_lint() {
858863
if env::var_os(SUPPORTS_FORCE_WARN).is_some() {
859864
cmd.arg("--force-warn")
860-
.arg(format!("rust-{}-compatibility", edition))
861-
.arg("-Zunstable-options");
865+
.arg(format!("rust-{}-compatibility", edition));
862866
} else {
863867
cmd.arg("-W").arg(format!("rust-{}-compatibility", edition));
864868
}

src/cargo/ops/registry.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ fn registry(
482482
registry.as_deref(),
483483
&api_host,
484484
)?;
485-
log::debug!("found token {:?}", token);
486485
Some(token)
487486
}
488487
}

src/cargo/util/command_prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pub trait ArgMatchesExt {
363363
// This is an early exit, since it allows combination with `--release`.
364364
match (specified_profile, profile_checking) {
365365
// `cargo rustc` has legacy handling of these names
366-
(Some(name @ ("test" | "bench" | "check")), ProfileChecking::LegacyRustc) |
366+
(Some(name @ ("dev" | "test" | "bench" | "check")), ProfileChecking::LegacyRustc) |
367367
// `cargo fix` and `cargo check` has legacy handling of this profile name
368368
(Some(name @ "test"), ProfileChecking::LegacyTestOnly) => return Ok(InternedString::new(name)),
369369
_ => {}

0 commit comments

Comments
 (0)