Skip to content

Commit db3328e

Browse files
committed
Add a warning if both package.include and package.exclude are specified.
1 parent 3ca96e9 commit db3328e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/cargo/ops/cargo_package.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult<Option
5656

5757
verify_dependencies(pkg)?;
5858

59+
if !pkg.manifest().exclude().is_empty() && !pkg.manifest().include().is_empty() {
60+
config.shell().warn(
61+
"both package.include and package.exclude are specified; \
62+
the exclude list will be ignored",
63+
)?;
64+
}
5965
// `list_files` outputs warnings as a side effect, so only do it once.
6066
let src_files = src.list_files(pkg)?;
6167

tests/testsuite/package.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ fn include() {
445445
"\
446446
[WARNING] manifest has no description[..]
447447
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
448+
[WARNING] both package.include and package.exclude are specified; the exclude list will be ignored
448449
[PACKAGING] foo v0.0.1 ([..])
449450
[ARCHIVING] [..]
450451
[ARCHIVING] [..]

0 commit comments

Comments
 (0)