Starting with this commit we deduplicate calls to rm_rf_prefix_list by crate name and not by directory; this can lead to more calls to rm_rf_prefix_list (especially in presence of multiple -p arguments),
but it is also more transparent in terms of progress reporting (we're just storing away whether a given directory + glob pair has already been removed)
fix(toml): Improve granularity of traces
### What does this PR try to resolve?
Once we move resolving out of `to_targets`, we won't have tracing visibility. As we don't have a top-level function for resolving, I put it on each. I mirrored this for "to_" for consistency and it seems useful when looking at the output.
### How should we test and review this PR?
### Additional information
fix(toml): Warn, rather than fail publish, if a target is excluded
### What does this PR try to resolve?
We have a couple of problems with publishing
- Inconsistent errors: if a target that `package` doesn't verify is missing `path`, it will error, while one with `path` won't, see #13456
- Users may want to exclude targets and their choices are
- Go ahead and include them. I originally excluded my examples before doc-scraping was a think. The problem was if I had to set `required-features`, I then could no longer exclude them
- Muck with `Cargo.toml` during publish and pass `--allow-dirty`
This fixes both by auto-stripping targets on publish. We will warn the user that we did so.
This is a mostly-one-way door on behavior because we are turning an error case into a warning.
For the most part, I think this is the right thing to do.
My biggest regret is that the warning is only during `package`/`publish` as it will be too late to act on it and people who want to know will want to know when the problem is introduced.
The error is also very late in the process but at least its before a non-reversible action has been taken.
Dry-run and `yank` help.
Fixes#13456Fixes#5806
### How should we test and review this PR?
Tests are added in the first commit and you can then follow the commits to see how the test output evolved.
The biggest risk factors for this change are
- If the target-stripping logic mis-identifies a path as excluded because of innocuous path differences (e.g. case)
- Setting a minimum MSRV for published packages: `auto*` were added in 1.27 (#5335) but were insta-stable. `autobins = false` did nothing until 1.32 (#6329). I have not checked to see how this behaves pre-1.32 or pre-1.27. Since my memory of that error is vague, I believe it will either do a redundant discovery *or* it will implicitly skip discovery
Resolved risks
- #13729 ensured our generated target paths don't have `\` in them
- #13729 ensures the paths are normalize so the list of packaged paths
For case-insensitive filesystems, I added tests to show the original behavior (works locally but will fail when depended on from a case-sensitive filesystem) and tracked how that changed with this PR (on publish warn that those targets are stripped). We could try to normalize the case but it will also follow symlinks and is likely indicative of larger casing problems that the user had. Weighing how broken things are now , it didn't seem changing behavior on this would be too big of a deal.
We should do a Call for Testing when this hits nightly to have people to `cargo package` and look for targets exclusion warnings that don't make sense.
### Additional information
This builds on #13701 and the work before it.
By enumerating all targets in `Cargo.toml`, it makes it so rust-lang/crates.io#5882 and rust-lang/crates.io#814 can be implemented without any other filesystem interactions.
A follow up PR is need to make much of a difference in performance because we unconditionally walk the file system just in case `autodiscover != Some(false)` or a target is missing a `path`.
We cannot turn off auto-discovery of libs, so that will always be done for bin-only packages.
This could offer performance gains when parsing a published
manifest since the targets don't need to be discovered.
To see this, we'd first need to stop discovering potential targets even when it isn't
needed.
fix(toml)!: Remove support for inheriting badges
### What does this PR try to resolve?
We allowed `[badges]` to inherit from `[workspace.package.badges]` which was a bug:
- This was not specified in the RFC
- We did not document this
- Even if someone were to try to guess to use this, it is inconsistent with how inheritance works because this should inherit from `workspace.badges` instead of `workspace.package.badges`
While keeping in mind that `[badges]` is effectively deprecated.
In that context, I think its safe to break support for this without a transition period.
Fixes#13643
### How should we test and review this PR?
### Additional information
chore(ci): Don't check `cargo` against beta channel
We already only partially check it and it has been a source of false positives.
While there is trust in the job, contributors and maintainers go into the job assuming there is a problem and it takes time to break that assumption.
If we lose trust in the job, we then won't trust it when it fails for other reasons.
This also increases the risk of us not seeing other problems `bump-checks` is meant to find if the steps in the job get re-arranged to make this one of the early ones.
We already only partially check it and it has been a source of false
positives.
While there is trust in the job, contributors and maintainers go into
the job assuming there is a problem and it takes time to break that
assumption.
If we lose trust in the job, we then won't trust it when it fails for
other reasons.
This also increases the risk of us not seeing other problems
`bump-checks` is meant to find if the steps in the job get re-arranged
to make this one of the early ones.
fix(cargo-lints): Don't always inherit workspace lints
When working on changes for #13805, I noticed that we always passed the contents of `[workspace.lints.cargo]` into the currently implemented lints, even if `[lints]` was not specified or did not contain `workspace = true`. This PR makes it so we only pass in the workspace cargo lints if `[lints]` contains `workspace = true`.
You can verify this change by looking at the first commit, where I added a test showing the current behavior, and looking at the second commit and seeing the test output no longer shows a warning about specifying `im-a-teapot`.
Update SleepTraker returns_in_order unit test
This updates the `returns_in_order` SleepTracker unit test so that it is not so sensitive to how fast the system is running. Previously it assumed that the function calls would take less than a millisecond to finish, but that is not a valid assumption for a slow-running system.
I have changed it to simplify the test, with the assumption that it takes less than 30 seconds for it to run, which should have a safety margin of a few orders of magnitude.
fix(toml): Remove underscore field support in 2024
### What does this PR try to resolve?
This is part of the 2024 Edition and is part of rust-lang/rust#123754 and #13629
### How should we test and review this PR?
### Additional information
docs(ref): Index differences between virtual / real manifests
### What does this PR try to resolve?
For a user to read the reference and to understand when each type of workspace might be right for them, they have to know to also read the section on Package Selection.
This reframes the section on needing to set `resolver = "2"` to being about differences when there isn't a root package and extends it to summarize a part of Package Selection, linking out to it. The hope is that this will make it all of the differences more discoverable without retreading too much of the same ground within Reference-style documentation.
Part of #13580
### How should we test and review this PR?
### Additional information
r? `@weihanglo`
For a user to read the reference and to understand when each type of
workspace might be right for them, they have to know to also read the
section on Package Selection.
This reframes the section on needing to set `resolver = "2"` to being
about differences when there isn't a root package and extends it to
summarize a part of Package Selection, linking out to it.
The hope is that this will make it all of the differences more
discoverable without retreading too much of the same ground within
Reference-style documentation.
Part of #13580