Skip to content

Commit 7553724

Browse files
authored
Merge pull request #1 from rust-lang/master
Update fork
2 parents 80cf934 + 6a2d62f commit 7553724

File tree

11 files changed

+100
-35
lines changed

11 files changed

+100
-35
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
- Windows GNU targets now copy `.dll.a` import library files for DLL crate
2626
types to the output directory.
2727
[#8141](https://github.com/rust-lang/cargo/pull/8141)
28+
- Dylibs for all dependencies are now unconditionally copied to the output
29+
directory. Some obscure scenarios can cause an old dylib to be referenced
30+
between builds, and this ensures that all the latest copies are used.
31+
[#8139](https://github.com/rust-lang/cargo/pull/8139)
2832

2933
### Fixed
3034
- Fixed copying Windows `.pdb` files to the output directory when the filename

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
133133
.map(|unit| (unit, LazyCell::new()))
134134
.collect();
135135
CompilationFiles {
136-
ws: &cx.bcx.ws,
136+
ws: cx.bcx.ws,
137137
host,
138138
target,
139139
export_dir: cx.bcx.build_config.export_dir.clone(),

src/cargo/core/manifest.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ compact_debug! {
353353
kinds.clone(),
354354
self.src_path.path().unwrap().to_path_buf(),
355355
self.edition,
356-
).inner.clone(),
356+
).inner,
357357
format!("lib_target({:?}, {:?}, {:?}, {:?})",
358358
self.name, kinds, self.src_path, self.edition),
359359
)
@@ -366,21 +366,21 @@ compact_debug! {
366366
&self.name,
367367
path.to_path_buf(),
368368
self.edition,
369-
).inner.clone(),
369+
).inner,
370370
format!("custom_build_target({:?}, {:?}, {:?})",
371371
self.name, path, self.edition),
372372
)
373373
}
374374
TargetSourcePath::Metabuild => {
375375
(
376-
Target::metabuild_target(&self.name).inner.clone(),
376+
Target::metabuild_target(&self.name).inner,
377377
format!("metabuild_target({:?})", self.name),
378378
)
379379
}
380380
}
381381
}
382382
_ => (
383-
Target::new(self.src_path.clone(), self.edition).inner.clone(),
383+
Target::new(self.src_path.clone(), self.edition).inner,
384384
format!("with_path({:?}, {:?})", self.src_path, self.edition),
385385
),
386386
}

src/cargo/ops/cargo_compile.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ pub fn create_bcx<'a, 'cfg>(
419419
&resolved_features,
420420
&pkg_set,
421421
&profiles,
422-
&interner,
422+
interner,
423423
)?;
424424

425425
let std_roots = if let Some(crates) = &config.cli_unstable().build_std {
@@ -442,7 +442,7 @@ pub fn create_bcx<'a, 'cfg>(
442442
std_features,
443443
build_config.requested_kind,
444444
&pkg_set,
445-
&interner,
445+
interner,
446446
&profiles,
447447
)?
448448
} else {
@@ -491,7 +491,7 @@ pub fn create_bcx<'a, 'cfg>(
491491
build_config.mode,
492492
&target_data,
493493
&profiles,
494-
&interner,
494+
interner,
495495
)?;
496496

497497
let bcx = BuildContext::new(

src/cargo/ops/cargo_package.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -823,25 +823,12 @@ fn check_filename(file: &Path, shell: &mut Shell) -> CargoResult<()> {
823823
file.display()
824824
)
825825
}
826-
let mut check_windows = |name| -> CargoResult<()> {
827-
if restricted_names::is_windows_reserved(name) {
828-
shell.warn(format!(
829-
"file {} is a reserved Windows filename, \
826+
if restricted_names::is_windows_reserved_path(file) {
827+
shell.warn(format!(
828+
"file {} is a reserved Windows filename, \
830829
it will not work on Windows platforms",
831-
file.display()
832-
))?;
833-
}
834-
Ok(())
835-
};
836-
for component in file.iter() {
837-
if let Some(component) = component.to_str() {
838-
check_windows(component)?;
839-
}
840-
}
841-
if file.extension().is_some() {
842-
if let Some(stem) = file.file_stem().and_then(|s| s.to_str()) {
843-
check_windows(stem)?;
844-
}
830+
file.display()
831+
))?;
845832
}
846833
Ok(())
847834
}

src/cargo/ops/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ fn get_source_id(
811811
reg: Option<&String>,
812812
) -> CargoResult<SourceId> {
813813
match (reg, index) {
814-
(Some(r), _) => SourceId::alt_registry(config, &r),
814+
(Some(r), _) => SourceId::alt_registry(config, r),
815815
(_, Some(i)) => SourceId::for_registry(&i.into_url()?),
816816
_ => {
817817
let map = SourceConfigMap::new(config)?;

src/cargo/ops/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub fn resolve_ws_with_opts<'cfg>(
127127
let pkg_set = get_resolved_packages(&resolved_with_overrides, registry)?;
128128

129129
let member_ids = ws
130-
.members_with_features(&specs, &opts.features)?
130+
.members_with_features(specs, &opts.features)?
131131
.into_iter()
132132
.map(|(p, _fts)| p.package_id())
133133
.collect::<Vec<_>>();
@@ -136,7 +136,7 @@ pub fn resolve_ws_with_opts<'cfg>(
136136
&member_ids,
137137
has_dev_units,
138138
requested_target,
139-
&target_data,
139+
target_data,
140140
)?;
141141

142142
let resolved_features = FeatureResolver::resolve(

src/cargo/sources/registry/mod.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ use crate::sources::PathSource;
178178
use crate::util::errors::CargoResultExt;
179179
use crate::util::hex;
180180
use crate::util::into_url::IntoUrl;
181-
use crate::util::{CargoResult, Config, Filesystem};
181+
use crate::util::{restricted_names, CargoResult, Config, Filesystem};
182182

183183
const PACKAGE_SOURCE_LOCK: &str = ".cargo-ok";
184184
pub const CRATES_IO_INDEX: &str = "https://github.com/rust-lang/crates.io-index";
@@ -495,11 +495,18 @@ impl<'cfg> RegistrySource<'cfg> {
495495
prefix
496496
)
497497
}
498-
499-
// Once that's verified, unpack the entry as usual.
500-
entry
501-
.unpack_in(parent)
502-
.chain_err(|| format!("failed to unpack entry at `{}`", entry_path.display()))?;
498+
// Unpacking failed
499+
let mut result = entry.unpack_in(parent).map_err(anyhow::Error::from);
500+
if cfg!(windows) && restricted_names::is_windows_reserved_path(&entry_path) {
501+
result = result.chain_err(|| {
502+
format!(
503+
"`{}` appears to contain a reserved Windows path, \
504+
it cannot be extracted on Windows",
505+
entry_path.display()
506+
)
507+
});
508+
}
509+
result.chain_err(|| format!("failed to unpack entry at `{}`", entry_path.display()))?;
503510
}
504511

505512
// Write to the lock file to indicate that unpacking was successful.

src/cargo/util/restricted_names.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::util::CargoResult;
44
use anyhow::bail;
5+
use std::path::Path;
56

67
/// Returns `true` if the name contains non-ASCII characters.
78
pub fn is_non_ascii_name(name: &str) -> bool {
@@ -81,3 +82,13 @@ pub fn validate_package_name(name: &str, what: &str, help: &str) -> CargoResult<
8182
}
8283
Ok(())
8384
}
85+
86+
// Check the entire path for names reserved in Windows.
87+
pub fn is_windows_reserved_path(path: &Path) -> bool {
88+
path.iter()
89+
.filter_map(|component| component.to_str())
90+
.any(|component| {
91+
let stem = component.split('.').next().unwrap();
92+
is_windows_reserved(stem)
93+
})
94+
}

src/doc/src/reference/external-tools.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ alter the way the JSON messages are computed and rendered. See the description
4848
of the `--message-format` option in the [build command documentation] for more
4949
details.
5050

51+
If you are using Rust, the [cargo_metadata] crate can be used to parse these
52+
messages.
53+
5154
[build command documentation]: ../commands/cargo-build.md
55+
[cargo_metadata]: https://crates.io/crates/cargo_metadata
5256

5357
#### Compiler messages
5458

0 commit comments

Comments
 (0)