Skip to content

Commit

Permalink
Merge branch 'master' into license-field-as-environment-variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kerkmann committed Jun 8, 2020
2 parents 8c99e20 + 5eb53f7 commit 1e800ab
Show file tree
Hide file tree
Showing 27 changed files with 321 additions and 82 deletions.
150 changes: 148 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
# Changelog

## Cargo 1.46 (2020-08-27)
[9fcb8c1d...HEAD](https://github.com/rust-lang/cargo/compare/9fcb8c1d...HEAD)

### Added

### Changed
- A warning is now displayed if a git dependency includes a `#` fragment in
the URL. This was potentially confusing because Cargo itself displays git
URLs with this syntax, but it does not have any meaning outside of the
`Cargo.lock` file, and would not work properly.
[#8297](https://github.com/rust-lang/cargo/pull/8297)

### Fixed
- Fixed a rare situation where an update to `Cargo.lock` failed once, but then
subsequent runs allowed it proceed.
[#8274](https://github.com/rust-lang/cargo/pull/8274)
- Removed assertion that Windows dylibs must have a `.dll` extension. Some
custom JSON spec targets may change the extension.
[#8310](https://github.com/rust-lang/cargo/pull/8310)
- Updated libgit2, which brings in a fix for zlib errors for some remote
git servers like googlesource.com.
[#8320](https://github.com/rust-lang/cargo/pull/8320)

### Nightly only
- Added `-Zrustdoc-map` feature which provides external mappings for rustdoc
(such as https://docs.rs/ links).
[docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#rustdoc-map)
[#8287](https://github.com/rust-lang/cargo/pull/8287)
- Fixed feature calculation when a proc-macro is declared in `Cargo.toml` with
an underscore (like `proc_macro = true`).
[#8319](https://github.com/rust-lang/cargo/pull/8319)


## Cargo 1.45 (2020-07-16)
[ebda5065e...HEAD](https://github.com/rust-lang/cargo/compare/ebda5065e...HEAD)
[ebda5065e...rust-1.45.0](https://github.com/rust-lang/cargo/compare/ebda5065...rust-1.45.0)

### Added

Expand Down Expand Up @@ -29,11 +62,105 @@
directory. Some obscure scenarios can cause an old dylib to be referenced
between builds, and this ensures that all the latest copies are used.
[#8139](https://github.com/rust-lang/cargo/pull/8139)
- `package.exclude` can now match directory names. If a directory is
specified, the entire directory will be excluded, and Cargo will not attempt
to inspect it further. Previously Cargo would try to check every file in the
directory which could cause problems if the directory contained unreadable
files.
[#8095](https://github.com/rust-lang/cargo/pull/8095)
- When packaging with `cargo publish` or `cargo package`, Cargo can use git to
guide its decision on which files to include. Previously this git-based
logic required a `Cargo.toml` file to exist at the root of the repository.
This is no longer required, so Cargo will now use git-based guidance even if
there is not a `Cargo.toml` in the root of the repository.
[#8095](https://github.com/rust-lang/cargo/pull/8095)
- While unpacking a crate on Windows, if it fails to write a file because the
file is a reserved Windows filename (like "aux.rs"), Cargo will display an
extra message to explain why it failed.
[#8136](https://github.com/rust-lang/cargo/pull/8136)
- Failures to set mtime on files are now ignored. Some filesystems did not
support this.
[#8185](https://github.com/rust-lang/cargo/pull/8185)
- Certain classes of git errors will now recommend enabling
`net.git-fetch-with-cli`.
[#8166](https://github.com/rust-lang/cargo/pull/8166)
- When doing an LTO build, Cargo will now instruct rustc not to perform
codegen when possible. This may result in a faster build and use less disk
space. Additionally, for non-LTO builds, Cargo will instruct rustc to not
embed LLVM bitcode in libraries, which should decrease their size.
[#8192](https://github.com/rust-lang/cargo/pull/8192)
[#8226](https://github.com/rust-lang/cargo/pull/8226)
[#8254](https://github.com/rust-lang/cargo/pull/8254)
- The implementation for `cargo clean -p` has been rewritten so that it can
more accurately remove the files for a specific package.
[#8210](https://github.com/rust-lang/cargo/pull/8210)
- The way Cargo computes the outputs from a build has been rewritten to be
more complete and accurate. Newly tracked files will be displayed in JSON
messages, and may be uplifted to the output directory in some cases. Some of
the changes from this are:

- `.exp` export files on Windows MSVC dynamic libraries are now tracked.
- Proc-macros on Windows track import/export files.
- All targets (like tests, etc.) that generate separate debug files
(pdb/dSYM) are tracked.
- Added .map files for wasm32-unknown-emscripten.
- macOS dSYM directories are tracked for all dynamic libraries
(dylib/cdylib/proc-macro) and for build scripts.

There are a variety of other changes as a consequence of this:

- Binary examples on Windows MSVC with a hyphen will now show up twice in
the examples directory (`foo_bar.exe` and `foo-bar.exe`). Previously Cargo
just renamed the file instead of hard-linking it.
- Example libraries now follow the same rules for hyphen/underscore
translation as normal libs (they will now use underscores).

[#8210](https://github.com/rust-lang/cargo/pull/8210)
- Cargo attempts to scrub any secrets from the debug log for HTTP debugging.
[#8222](https://github.com/rust-lang/cargo/pull/8222)
- Context has been added to many of Cargo's filesystem operations, so that
error messages now provide more information, such as the path that caused
the problem.
[#8232](https://github.com/rust-lang/cargo/pull/8232)
- Several commands now ignore the error if stdout or stderr is closed while it
is running. For example `cargo install --list | grep -q cargo-fuzz` would
previously sometimes panic because `grep -q` may close stdout before the
command finishes. Regular builds continue to fail if stdout or stderr is
closed, matching the behavior of many other build systems.
[#8236](https://github.com/rust-lang/cargo/pull/8236)
- If `cargo install` is given an exact version, like `--version=1.2.3`, it
will now avoid updating the index if that version is already installed, and
exit quickly indicating it is already installed.
[#8022](https://github.com/rust-lang/cargo/pull/8022)
- Changes to the `[patch]` section will now attempt to automatically update
`Cargo.lock` to the new version. It should now also provide better error
messages for the rare cases where it is unable to automatically update.
[#8248](https://github.com/rust-lang/cargo/pull/8248)

### Fixed
- Fixed copying Windows `.pdb` files to the output directory when the filename
contained dashes.
[#8123](https://github.com/rust-lang/cargo/pull/8123)
- Fixed error where Cargo would fail when scanning if a package is inside a
git repository when any of its ancestor paths is a symlink.
[#8186](https://github.com/rust-lang/cargo/pull/8186)
- Fixed `cargo update` with an unused `[patch]` so that it does not get
stuck and refuse to update.
[#8243](https://github.com/rust-lang/cargo/pull/8243)
- Fixed a situation where Cargo would hang if stderr is closed, and the
compiler generated a large number of messages.
[#8247](https://github.com/rust-lang/cargo/pull/8247)
- Fixed backtraces on macOS not showing filenames or line numbers. As a
consequence of this, binary executables on apple targets do not include a
hash in the filename in Cargo's cache. This means Cargo can only track one
copy, so if you switch features or rustc versions, Cargo will need to
rebuild the executable.
[#8329](https://github.com/rust-lang/cargo/pull/8329)
[#8335](https://github.com/rust-lang/cargo/pull/8335)
- Fixed fingerprinting when using lld on Windows with a dylib. Cargo was
erroneously thinking the dylib was never fresh.
[#8290](https://github.com/rust-lang/cargo/pull/8290)
[#8335](https://github.com/rust-lang/cargo/pull/8335)

### Nightly only
- Fixed passing the full path for `--target` to `rustdoc` when using JSON spec
Expand All @@ -44,9 +171,22 @@
- Added new `resolver` field to `Cargo.toml` to opt-in to the new feature
resolver.
[#8129](https://github.com/rust-lang/cargo/pull/8129)
- `-Zbuild-std` no longer treats std dependencies as "local". This means that
it won't use incremental compilation for those dependencies, removes them
from dep-info files, and caps lints at "allow".
[#8177](https://github.com/rust-lang/cargo/pull/8177)
- Added `-Zmultitarget` which allows multiple `--target` flags to build the
same thing for multiple targets at once.
[docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#multitarget)
[#8167](https://github.com/rust-lang/cargo/pull/8167)
- Added `strip` option to the profile to remove symbols and debug information.
[docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#profile-strip-option)
[#8246](https://github.com/rust-lang/cargo/pull/8246)
- Fixed panic with `cargo tree --target=all -Zfeatures=all`.
[#8269](https://github.com/rust-lang/cargo/pull/8269)

## Cargo 1.44 (2020-06-04)
[bda50510...ebda5065e](https://github.com/rust-lang/cargo/compare/bda50510...ebda5065e)
[bda50510...rust-1.44.0](https://github.com/rust-lang/cargo/compare/bda50510...rust-1.44.0)

### Added
- 🔥 Added the `cargo tree` command.
Expand Down Expand Up @@ -96,6 +236,10 @@
[#8090](https://github.com/rust-lang/cargo/pull/8090)
- Added a certain class of HTTP2 errors as "spurious" that will get retried.
[#8102](https://github.com/rust-lang/cargo/pull/8102)
- Allow `cargo package --list` to succeed, even if there are other validation
errors (such as `Cargo.lock` generation problem, or missing dependencies).
[#8175](https://github.com/rust-lang/cargo/pull/8175)
[#8215](https://github.com/rust-lang/cargo/pull/8215)

### Fixed
- Cargo no longer buffers excessive amounts of compiler output in memory.
Expand All @@ -115,6 +259,8 @@
- Protect against some (unknown) situations where Cargo could panic when the
system monotonic clock doesn't appear to be monotonic.
[#8114](https://github.com/rust-lang/cargo/pull/8114)
- Fixed panic with `cargo clean -p` if the package has a build script.
[#8216](https://github.com/rust-lang/cargo/pull/8216)

### Nightly only
- Fixed panic with new feature resolver and required-features.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo"
version = "0.46.0"
version = "0.47.0"
edition = "2018"
authors = ["Yehuda Katz <wycats@gmail.com>",
"Carl Lerche <me@carllerche.com>",
Expand Down
5 changes: 1 addition & 4 deletions crates/cargo-platform/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub struct ParseError {
orig: String,
}

#[non_exhaustive]
#[derive(Debug)]
pub enum ParseErrorKind {
UnterminatedString,
Expand All @@ -17,9 +18,6 @@ pub enum ParseErrorKind {
IncompleteExpr(&'static str),
UnterminatedExpression(String),
InvalidTarget(String),

#[doc(hidden)]
__Nonexhaustive,
}

impl fmt::Display for ParseError {
Expand Down Expand Up @@ -53,7 +51,6 @@ impl fmt::Display for ParseErrorKind {
write!(f, "unexpected content `{}` found after cfg expression", s)
}
InvalidTarget(s) => write!(f, "invalid target specifier: {}", s),
__Nonexhaustive => unreachable!(),
}
}
}
Expand Down
22 changes: 15 additions & 7 deletions src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,15 @@ impl<'cfg> Compilation<'cfg> {
self.rustc_process.clone()
};

self.fill_env(rustc, &unit.pkg, unit.kind, true)
let cmd = fill_rustc_tool_env(rustc, unit);
self.fill_env(cmd, &unit.pkg, unit.kind, true)
}

/// See `process`.
pub fn rustdoc_process(&self, unit: &Unit) -> CargoResult<ProcessBuilder> {
let mut p = self.fill_env(
process(&*self.config.rustdoc()?),
&unit.pkg,
unit.kind,
true,
)?;
let rustdoc = process(&*self.config.rustdoc()?);
let cmd = fill_rustc_tool_env(rustdoc, unit);
let mut p = self.fill_env(cmd, &unit.pkg, unit.kind, true)?;
if unit.target.edition() != Edition::Edition2015 {
p.arg(format!("--edition={}", unit.target.edition()));
}
Expand Down Expand Up @@ -299,6 +297,16 @@ impl<'cfg> Compilation<'cfg> {
}
}

/// Prepares a rustc_tool process with additional environment variables
/// that are only relevant in a context that has a unit
fn fill_rustc_tool_env(mut cmd: ProcessBuilder, unit: &Unit) -> ProcessBuilder {
if unit.target.is_bin() {
cmd.env("CARGO_BIN_NAME", unit.target.name());
}
cmd.env("CARGO_CRATE_NAME", unit.target.crate_name());
cmd
}

fn pre_version_component(v: &Version) -> String {
if v.pre.is_empty() {
return String::new();
Expand Down
9 changes: 8 additions & 1 deletion src/cargo/core/compiler/context/compilation_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,12 @@ fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool {
// - wasm32 executables: When using emscripten, the path to the .wasm file
// is embedded in the .js file, so we don't want the hash in there.
// TODO: Is this necessary for wasm32-unknown-unknown?
// - apple executables: The executable name is used in the dSYM directory
// (such as `target/debug/foo.dSYM/Contents/Resources/DWARF/foo-64db4e4bf99c12dd`).
// Unfortunately this causes problems with our current backtrace
// implementation which looks for a file matching the exe name exactly.
// See https://github.com/rust-lang/rust/issues/72550#issuecomment-638501691
// for more details.
//
// This is only done for local packages, as we don't expect to export
// dependencies.
Expand All @@ -622,7 +628,8 @@ fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool {
if (unit.target.is_dylib()
|| unit.target.is_cdylib()
|| (unit.target.is_executable() && short_name.starts_with("wasm32-"))
|| (unit.target.is_executable() && short_name.contains("msvc")))
|| (unit.target.is_executable() && short_name.contains("msvc"))
|| (unit.target.is_executable() && short_name.contains("-apple-")))
&& unit.pkg.package_id().source_id().is_path()
&& env::var("__CARGO_DEFAULT_LIB_METADATA").is_err()
{
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ impl Fingerprint {
if a.name != b.name {
let e = format_err!("`{}` != `{}`", a.name, b.name)
.context("unit dependency name changed");
return Err(e.into());
return Err(e);
}

if a.fingerprint.hash() != b.fingerprint.hash() {
Expand All @@ -906,7 +906,7 @@ impl Fingerprint {
b.fingerprint.hash()
)
.context("unit dependency information changed");
return Err(e.into());
return Err(e);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/cargo/core/compiler/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn add_root_urls(
return Ok(());
}
let map = config.doc_extern_map()?;
if map.registries.len() == 0 && map.std.is_none() {
if map.registries.is_empty() && map.std.is_none() {
// Skip doing unnecessary work.
return Ok(());
}
Expand All @@ -90,13 +90,13 @@ pub fn add_root_urls(
.keys()
.filter_map(|name| {
if let Ok(index_url) = config.get_registry_index(name) {
return Some((name, index_url));
Some((name, index_url))
} else {
log::warn!(
"`doc.extern-map.{}` specifies a registry that is not defined",
name
);
return None;
None
}
})
.collect();
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl<'cfg> PackageRegistry<'cfg> {
.expect("loaded source not present");
let summaries = source.query_vec(dep)?;
let (summary, should_unlock) =
summary_for_patch(orig_patch, &locked, summaries, source).chain_err(|| {
summary_for_patch(orig_patch, locked, summaries, source).chain_err(|| {
format!(
"patch for `{}` in `{}` failed to resolve",
orig_patch.package_name(),
Expand Down
7 changes: 3 additions & 4 deletions src/cargo/core/resolver/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ impl Resolve {

pub fn register_used_patches(&mut self, patches: &[Summary]) {
for summary in patches {
if self.iter().any(|id| id == summary.package_id()) {
continue;
}
self.unused_patches.push(summary.package_id());
if !self.graph.contains(&summary.package_id()) {
self.unused_patches.push(summary.package_id())
};
}
}

Expand Down
13 changes: 11 additions & 2 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,16 @@ impl<'cfg> Workspace<'cfg> {
pub fn new(manifest_path: &Path, config: &'cfg Config) -> CargoResult<Workspace<'cfg>> {
let mut ws = Workspace::new_default(manifest_path.to_path_buf(), config);
ws.target_dir = config.target_dir()?;
ws.root_manifest = ws.find_root(manifest_path)?;

if manifest_path.is_relative() {
anyhow::bail!(
"manifest_path:{:?} is not an absolute path. Please provide an absolute path.",
manifest_path
)
} else {
ws.root_manifest = ws.find_root(manifest_path)?;
}

ws.find_members()?;
ws.resolve_behavior = match ws.root_maybe() {
MaybePackage::Package(p) => p.manifest().resolve_behavior(),
Expand Down Expand Up @@ -863,7 +872,7 @@ impl<'cfg> Workspace<'cfg> {
let err = anyhow::format_err!("{}", warning.message);
let cx =
anyhow::format_err!("failed to parse manifest at `{}`", path.display());
return Err(err.context(cx).into());
return Err(err.context(cx));
} else {
let msg = if self.root_manifest.is_none() {
warning.message.to_string()
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#![allow(clippy::unneeded_field_pattern)]
// false positives in target-specific code, for details see
// https://github.com/rust-lang/cargo/pull/7251#pullrequestreview-274914270
#![allow(clippy::identity_conversion)]
#![allow(clippy::useless_conversion)]

use crate::core::shell::Verbosity::Verbose;
use crate::core::Shell;
Expand Down
Loading

0 comments on commit 1e800ab

Please sign in to comment.