Skip to content

Commit 730348a

Browse files
committed
fix(package): Ensure we can package directories ending with '.rs'
This might have also broken dependencies whose path ends with `.rs` as well This broke in #14961
1 parent 45da135 commit 730348a

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/cargo/util/toml/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ pub use embedded::ScriptSource;
4545
/// See also `bin/cargo/commands/run.rs`s `is_manifest_command`
4646
pub fn is_embedded(path: &Path) -> bool {
4747
let ext = path.extension();
48-
ext == Some(OsStr::new("rs")) ||
48+
(ext == Some(OsStr::new("rs")) ||
4949
// Provide better errors by not considering directories to be embedded manifests
50-
(ext.is_none() && path.is_file())
50+
ext.is_none())
51+
&& path.is_file()
5152
}
5253

5354
/// Loads a `Cargo.toml` from a file on disk.

tests/testsuite/package.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -6646,17 +6646,21 @@ fn workspace_with_dot_rs_dir() {
66466646
p.cargo("package -Zpackage-workspace")
66476647
.masquerade_as_nightly_cargo(&["package-workspace"])
66486648
.replace_crates_io(reg.index_url())
6649-
.with_status(101)
66506649
.with_stderr_data(
66516650
str![[r#"
66526651
[PACKAGING] foo v0.16.2 ([ROOT]/foo/crates/foo.rs)
6653-
[ERROR] failed to prepare local package for uploading
6654-
6655-
Caused by:
6656-
Unable to update [ROOT]/foo/crates/foo.rs
6657-
6658-
Caused by:
6659-
Single file packages cannot be used as dependencies
6652+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
6653+
[PACKAGING] bar v0.16.2 ([ROOT]/foo/crates/bar.rs)
6654+
[UPDATING] crates.io index
6655+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
6656+
[VERIFYING] foo v0.16.2 ([ROOT]/foo/crates/foo.rs)
6657+
[COMPILING] foo v0.16.2 ([ROOT]/foo/target/package/foo-0.16.2)
6658+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
6659+
[VERIFYING] bar v0.16.2 ([ROOT]/foo/crates/bar.rs)
6660+
[UNPACKING] foo v0.16.2 (registry `[ROOT]/foo/target/package/tmp-registry`)
6661+
[COMPILING] foo v0.16.2
6662+
[COMPILING] bar v0.16.2 ([ROOT]/foo/target/package/bar-0.16.2)
6663+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
66606664
66616665
"#]]
66626666
.unordered(),

tests/testsuite/script.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ fn cmd_check_with_missing_script_rs() {
13581358
.with_status(101)
13591359
.with_stdout_data("")
13601360
.with_stderr_data(str![[r#"
1361-
[ERROR] manifest path `script.rs` does not exist
1361+
[ERROR] the manifest-path must be a path to a Cargo.toml file
13621362
13631363
"#]])
13641364
.run();

0 commit comments

Comments
 (0)