Support vendoring with different revs from same git repo
### What does this PR try to resolve?
Fixes#10667
### How should we test and review this PR?
test case is included
fix: deduplicate dependencies by artifact target
### What does this PR try to resolve?
In cases when a compile target is specified for a bindep and the crate depending on it, cargo fails to deduplicate the crate dependencies and attempts to build the dependent crate only once with non-deterministic feature set, which breaks e.g. https://github.com/rvolosatovs/musl-bindep-feature-bug
Fix the issue by including the optional artifact compile target in the `Unit` in order to avoid wrongfully deduplicating the dependent crates
Fixes https://github.com/rust-lang/cargo/issues/11463
Fixes https://github.com/rust-lang/cargo/issues/10837
Fixes https://github.com/rust-lang/cargo/issues/10525
Note, that this issue is already accounted for by `cargo`, but in different context a similar situation can occur while building the build script, which:
1. may be built for different target than the actual package target
2. may contain dependencies with different feature sets than the same dependencies in the dependency graph of the package itself
That's why this PR is simply reusing the existing functionality for deduplication
### How should we test and review this PR?
Build https://github.com/rvolosatovs/musl-bindep-feature-bug
### Additional information
This is based on analysis by `@weihanglo` in https://github.com/rust-lang/cargo/issues/10837#issuecomment-1339365374
I experimented with adding the whole `UnitFor` to the internal unit struct, but that seems unnecessary.
It would probably be nicer to refactor `IsArtifact` and instead turn it into a 3-variant enum with a possible compile target, but I decided against that to minimize the diff. Perhaps it's worth a follow-up?
Add warning if potentially-scrapable examples are skipped due to dev-dependencies
### What does this PR try to resolve?
Another point of feedback I've received on the scrape-examples feature is that the dev-dependency situation is quite confusing and subtle. To make users more aware of the issue, I added a warning where Cargo will alert users when examples are skipped due to a dev-dependency requirement, along with proposing a fix.
### How should we test and review this PR?
The test `docscrape::no_scrape_with_dev_deps` has been updated to reflect this new warning.
r? `@weihanglo`
(PS thank you for the reviews Weihang. I know I'm doing lots of little patches right now to get this feature finalized. If you want to share the reviewing burden on scrape-examples with anyone else, let me know!)
Don't scrape examples from library targets by default
### What does this PR try to resolve?
Based on some [early feedback](https://www.reddit.com/r/rust/comments/zosle6/feedback_requested_rustdocs_scraped_examples/) about the scrape-examples feature, both documentation authors and consumers did not consider examples useful if they are scraped from a library's internals, at least in the common case. Therefore this PR changes the default behavior of `-Zrustdoc-scrape-examples` to *only* scrape from example targets, although library targets can still be configured for scraping.
### How should we test and review this PR?
I have updated the `docscrape` tests to reflect this new policy, as well as the Unstable Options page in the Cargo book.
r? `@weihanglo`
Stabilize terminal-width
This stabilized the passing of the `--diagnostic-width` flag to rustc and rustdoc so that they will format diagnostics to fit within the terminal size. Previously they always assume the width is 140. The diagnostics are trimmed with `...` to elide parts of extra-long lines.
In cases where the width isn't known (such as not when used on a tty, or with mintty), then cargo does not pass the flag and the default of 140 is still used.
At this time there is no way for the user to override the width (unlike with the progress bar width). That can be added in the future if there is demand. https://github.com/rust-lang/rust/issues/84673#issuecomment-1179096971 contains some thoughts on some different ideas.
Closes https://github.com/rust-lang/rust/issues/84673
Use workspace lockfile when running `cargo package` and `cargo publish`
### What does this PR try to resolve?
Fix#11148.
### How should we test and review this PR?
Please run the integration test in `tests/testsuite/publish_lockfile.rs` or try the steps from the issue.
Fix examples of proc-macro crates being scraped for examples
This PR fixes#11496, where examples in proc-macro crates would crash the build with `-Zrustdoc-scrape-examples`. The fix is to change `unit_needs_doc_scrape` to check if a unit is coming from a `proc-macro` package. I added a test to ensure the simple example passes. I also ensured that [automod](https://github.com/dtolnay/automod) also documents correctly.
r? `@weihanglo`
Display CPU info in CI
This displays the CPU information on the CI runners in the logs. This can be helpful for diagnosing CI issues and to better understand the environment they are running under.
Fix collision_doc_profile test error
This fixes the `collision_doc_profile` test which was sporadically failing on CI. My theory is that the first `common` build finishes quickly (or the other job slot is delayed). The proc-macro `pm` starts (likely very quickly due to pipelining), and it can jump ahead before the second `common` build starts (or at least before the `Message::Run` message gets delivered).
The order isn't really important or relevant to this test (all that matters is that "common" shows up twice), so this ignores the order of the messages.
cc #11334