The Cargo exclude directive for excluding a path doesn't appear to error or warn on negative space (things that don't exist).
exclude = ["directory-that-is-now-gone"]
This becomes a maintenance burden since the exclude is used at various life-cycles of the application, and can become outdated, such that at one time the directory existed and now it does not, and yet the exclude directive silently remains.
I did a brief search, although I don't see any lints that would solve this, either. I tested on both the 2021 and 2024 edition with the same results.
This commit alters Cargo's behavior to prevent publishing a crate by default if
any files in that crate are determined to be dirty, that is either modified or
not part of the working tree.
I'm not entirely certain how Cargo determines what is part of the working tree.
I've somewhat answered my own question with "cargo package --list" which shows that if I do not add something to exclude, it does still get packaged. Therefore "exclude" is still useful, although it should warn if the excluded file or directory does not exist.
I think you could write very simple bash/python script that loads Cargo.toml, looks at excluded list, iterates over paths, and checks if they are present. Then you could put it as git pre-commit hook, or maybe in your CI.
Yes, indeed a shell script as part of CI would also suffice. And, if nobody else is really finding this to be an issue, I may do that. Thanks for the input.