diff --git a/Cargo.lock b/Cargo.lock index 162f36780ea..cc692d5daa0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -351,6 +351,7 @@ dependencies = [ "memchr", "opener", "openssl", + "openssl-sys", "os_info", "pasetors", "pathdiff", @@ -2824,18 +2825,18 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-src" -version = "300.4.1+3.4.0" +version = "111.28.2+1.1.1w" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa4eac4138c62414b5622d1b31c5c304f34b406b013c079c2bbc652fdd6678c" +checksum = "bb1830e20a48a975ca898ca8c1d036a36c3c6c5cb7dabc1c216706587857920f" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.105" +version = "0.9.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc" +checksum = "db7e971c2c2bba161b2d2fdf37080177eff520b3bc044787c7f1f5f9e78d869b" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index 452cac1f124..a6468a4b205 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -234,6 +234,7 @@ cargo-credential-macos-keychain.workspace = true [target.'cfg(not(windows))'.dependencies] openssl = { workspace = true, optional = true } +openssl-sys = { workspace = true, optional = true } # HACK: for pinning to openssl v1. [target.'cfg(windows)'.dependencies] cargo-credential-wincred.workspace = true diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 0273d8fa4d3..107329d2abf 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -3,7 +3,6 @@ use std::collections::{BTreeMap, HashMap}; use std::fmt; use std::hash::{Hash, Hasher}; use std::path::{Path, PathBuf}; -use std::rc::Rc; use std::sync::Arc; use anyhow::Context as _; @@ -62,10 +61,10 @@ impl EitherManifest { #[derive(Clone, Debug)] pub struct Manifest { // alternate forms of manifests: - contents: Rc, - document: Rc>, - original_toml: Rc, - normalized_toml: Rc, + contents: Arc, + document: Arc>, + original_toml: Arc, + normalized_toml: Arc, summary: Summary, // this form of manifest: @@ -108,10 +107,10 @@ pub struct Warnings(Vec); #[derive(Clone, Debug)] pub struct VirtualManifest { // alternate forms of manifests: - contents: Rc, - document: Rc>, - original_toml: Rc, - normalized_toml: Rc, + contents: Arc, + document: Arc>, + original_toml: Arc, + normalized_toml: Arc, // this form of manifest: replace: Vec<(PackageIdSpec, Dependency)>, @@ -484,10 +483,10 @@ compact_debug! { impl Manifest { pub fn new( - contents: Rc, - document: Rc>, - original_toml: Rc, - normalized_toml: Rc, + contents: Arc, + document: Arc>, + original_toml: Arc, + normalized_toml: Arc, summary: Summary, default_kind: Option, @@ -726,10 +725,10 @@ impl Manifest { impl VirtualManifest { pub fn new( - contents: Rc, - document: Rc>, - original_toml: Rc, - normalized_toml: Rc, + contents: Arc, + document: Arc>, + original_toml: Arc, + normalized_toml: Arc, replace: Vec<(PackageIdSpec, Dependency)>, patch: HashMap>, workspace: WorkspaceConfig, diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 3d7c84a4266..ddb394c0021 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -5,7 +5,7 @@ use std::fmt; use std::hash; use std::mem; use std::path::{Path, PathBuf}; -use std::rc::Rc; +use std::sync::Arc; use std::time::{Duration, Instant}; use anyhow::Context as _; @@ -42,7 +42,7 @@ use crate::util::{self, internal, GlobalContext, Progress, ProgressStyle}; /// A package is a `Cargo.toml` file plus all the files that are part of it. #[derive(Clone)] pub struct Package { - inner: Rc, + inner: Arc, } #[derive(Clone)] @@ -101,7 +101,7 @@ impl Package { /// Creates a package from a manifest and its location. pub fn new(manifest: Manifest, manifest_path: &Path) -> Package { Package { - inner: Rc::new(PackageInner { + inner: Arc::new(PackageInner { manifest, manifest_path: manifest_path.to_path_buf(), }), @@ -118,7 +118,7 @@ impl Package { } /// Gets the manifest. pub fn manifest_mut(&mut self) -> &mut Manifest { - &mut Rc::make_mut(&mut self.inner).manifest + &mut Arc::make_mut(&mut self.inner).manifest } /// Gets the path to the manifest. pub fn manifest_path(&self) -> &Path { @@ -179,7 +179,7 @@ impl Package { pub fn map_source(self, to_replace: SourceId, replace_with: SourceId) -> Package { Package { - inner: Rc::new(PackageInner { + inner: Arc::new(PackageInner { manifest: self.manifest().clone().map_source(to_replace, replace_with), manifest_path: self.manifest_path().to_owned(), }), diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 85aeb8697a7..19a7e785a61 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -3,8 +3,8 @@ use std::borrow::Cow; use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::ffi::OsStr; use std::path::{Path, PathBuf}; -use std::rc::Rc; use std::str::{self, FromStr}; +use std::sync::Arc; use crate::core::summary::MissingDependencyError; use crate::AlreadyPrintedError; @@ -45,9 +45,10 @@ pub use embedded::ScriptSource; /// See also `bin/cargo/commands/run.rs`s `is_manifest_command` pub fn is_embedded(path: &Path) -> bool { let ext = path.extension(); - ext == Some(OsStr::new("rs")) || + (ext == Some(OsStr::new("rs")) || // Provide better errors by not considering directories to be embedded manifests - (ext.is_none() && path.is_file()) + ext.is_none()) + && path.is_file() } /// Loads a `Cargo.toml` from a file on disk. @@ -1750,10 +1751,10 @@ pub fn to_real_manifest( let default_run = normalized_package.default_run.clone(); let metabuild = normalized_package.metabuild.clone().map(|sov| sov.0); let manifest = Manifest::new( - Rc::new(contents), - Rc::new(document), - Rc::new(original_toml), - Rc::new(normalized_toml), + Arc::new(contents), + Arc::new(document), + Arc::new(original_toml), + Arc::new(normalized_toml), summary, default_kind, forced_kind, @@ -1929,10 +1930,10 @@ fn to_virtual_manifest( bail!("virtual manifests must be configured with [workspace]"); } let manifest = VirtualManifest::new( - Rc::new(contents), - Rc::new(document), - Rc::new(original_toml), - Rc::new(normalized_toml), + Arc::new(contents), + Arc::new(document), + Arc::new(original_toml), + Arc::new(normalized_toml), replace, patch, workspace_config, diff --git a/tests/testsuite/global_cache_tracker.rs b/tests/testsuite/global_cache_tracker.rs index 4bbdb8b228e..045f34db28c 100644 --- a/tests/testsuite/global_cache_tracker.rs +++ b/tests/testsuite/global_cache_tracker.rs @@ -2004,16 +2004,7 @@ fn compatible_with_older_cargo() { assert_eq!(get_registry_names("src"), ["middle-1.0.0", "new-1.0.0"]); assert_eq!( get_registry_names("cache"), - // Duplicate crates from two different cache location - // because we're changing how SourceId is hashed. - // This change should be reverted once rust-lang/cargo#14917 lands. - [ - "middle-1.0.0.crate", - "middle-1.0.0.crate", - "new-1.0.0.crate", - "new-1.0.0.crate", - "old-1.0.0.crate" - ] + ["middle-1.0.0.crate", "new-1.0.0.crate", "old-1.0.0.crate"] ); // T-0 months: Current version, make sure it can read data from stable, @@ -2036,10 +2027,7 @@ fn compatible_with_older_cargo() { assert_eq!(get_registry_names("src"), ["new-1.0.0"]); assert_eq!( get_registry_names("cache"), - // Duplicate crates from two different cache location - // because we're changing how SourceId is hashed. - // This change should be reverted once rust-lang/cargo#14917 lands. - ["middle-1.0.0.crate", "new-1.0.0.crate", "new-1.0.0.crate"] + ["middle-1.0.0.crate", "new-1.0.0.crate"] ); } diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index ae1c5d71024..ae4de6e2938 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -6430,6 +6430,78 @@ fn workspace_with_local_and_remote_deps() { .run(); } +#[cargo_test] +fn workspace_with_dot_rs_dir() { + let reg = registry::init(); + + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["crates/*"] + "#, + ) + .file( + "crates/foo.rs/Cargo.toml", + r#" + [package] + name = "foo" + version = "0.16.2" + edition = "2015" + authors = [] + license = "MIT" + description = "main" + repository = "bar" + + [dependencies] + "#, + ) + .file("crates/foo.rs/src/lib.rs", "pub fn foo() {}") + .file( + "crates/bar.rs/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.16.2" + edition = "2015" + authors = [] + license = "MIT" + description = "main" + repository = "bar" + + [dependencies] + foo = { path = "../foo.rs", version = "0.16.2" } + "#, + ) + .file("crates/bar.rs/src/lib.rs", "pub fn foo() {}") + .build(); + + p.cargo("package -Zpackage-workspace") + .masquerade_as_nightly_cargo(&["package-workspace"]) + .replace_crates_io(reg.index_url()) + .with_stderr_data( + str![[r#" +[PACKAGING] foo v0.16.2 ([ROOT]/foo/crates/foo.rs) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[PACKAGING] bar v0.16.2 ([ROOT]/foo/crates/bar.rs) +[UPDATING] crates.io index +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.16.2 ([ROOT]/foo/crates/foo.rs) +[COMPILING] foo v0.16.2 ([ROOT]/foo/target/package/foo-0.16.2) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[VERIFYING] bar v0.16.2 ([ROOT]/foo/crates/bar.rs) +[UNPACKING] foo v0.16.2 (registry `[ROOT]/foo/target/package/tmp-registry`) +[COMPILING] foo v0.16.2 +[COMPILING] bar v0.16.2 ([ROOT]/foo/target/package/bar-0.16.2) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), + ) + .run(); +} + #[cargo_test] fn registry_not_in_publish_list() { let p = project() diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index 5c6a46bb271..20fa7bcb3fb 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -1358,7 +1358,7 @@ fn cmd_check_with_missing_script_rs() { .with_status(101) .with_stdout_data("") .with_stderr_data(str![[r#" -[ERROR] manifest path `script.rs` does not exist +[ERROR] the manifest-path must be a path to a Cargo.toml file "#]]) .run();