-
Notifications
You must be signed in to change notification settings - Fork 2.6k
refactor: separate "global" mode from CompileMode #15601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
pub enum UserIntent { | ||
/// Build benchmark binaries, e.g., `cargo bench` | ||
Bench, | ||
/// Build binaries and libraray, e.g., `cargo run`, `cargo install`, `cargo build`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually should be plural 😬.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// A target that will be documented with `rustdoc`. | ||
|
||
/// Document with `rustdoc`. | ||
/// | ||
/// If `deps` is true, then it will also document all dependencies. | ||
/// if `json` is true, the documentation output is in json format. | ||
Doc { deps: bool, json: bool }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the deps field on CompileMode too and not just on UserIntent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you need it to determine whether to include deps for documenting, during computing the unit graph. I haven't found a good way to remove that.
cargo/src/cargo/core/compiler/unit_dependencies.rs
Lines 632 to 645 in bffece8
if let CompileMode::Doc { deps: true, .. } = unit.mode { | |
// Document this lib as well. | |
let doc_unit_dep = new_unit_dep( | |
state, | |
unit, | |
dep_pkg, | |
dep_lib, | |
dep_unit_for, | |
unit.kind.for_target(dep_lib), | |
unit.mode, | |
IS_NO_ARTIFACT_DEP, | |
)?; | |
ret.push(doc_unit_dep); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured you would have access to the UserIntent
when deciding if a crate should be documented, but I guess not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that. You're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went ahead and removed the deps
field as well. Thanks for the good catch!
### What does this PR try to resolve? Some more cleanup after #15601 See each commit message for details. ### How should we test and review this PR? Help review whether it has really no behavior change.
Update cargo 12 commits in 68db37499f2de8acef704c73d9031be6fbcbaee4..64a12460708cf146e16cc61f28aba5dc2463bbb4 2025-05-22 14:27:15 +0000 to 2025-05-30 18:25:08 +0000 - chore: remove HTML comments and inline guide (rust-lang/cargo#15613) - Add .git-blame-ignore-revs (rust-lang/cargo#15612) - refactor: cleanup for `CompileMode` (rust-lang/cargo#15608) - refactor: separate "global" mode from CompileMode (rust-lang/cargo#15601) - fix(doc): pass `toolchain-shared-resources` to get doc styled (rust-lang/cargo#15605) - fix(embedded): Resolve multiple bugs in frontmatter parser (rust-lang/cargo#15573) - chore: Upgrade schemars (rust-lang/cargo#15602) - Update gix & socket2 (rust-lang/cargo#15600) - Add `-Zfix-edition` (rust-lang/cargo#15596) - chore(toml): disable `toml`'s default features, unless necessary (rust-lang/cargo#15598) - docs(README): fix the link to the changelog in the Cargo book (rust-lang/cargo#15597) - Add the future edition (rust-lang/cargo#15595) r? ghost
Update cargo 12 commits in 68db37499f2de8acef704c73d9031be6fbcbaee4..64a12460708cf146e16cc61f28aba5dc2463bbb4 2025-05-22 14:27:15 +0000 to 2025-05-30 18:25:08 +0000 - chore: remove HTML comments and inline guide (rust-lang/cargo#15613) - Add .git-blame-ignore-revs (rust-lang/cargo#15612) - refactor: cleanup for `CompileMode` (rust-lang/cargo#15608) - refactor: separate "global" mode from CompileMode (rust-lang/cargo#15601) - fix(doc): pass `toolchain-shared-resources` to get doc styled (rust-lang/cargo#15605) - fix(embedded): Resolve multiple bugs in frontmatter parser (rust-lang/cargo#15573) - chore: Upgrade schemars (rust-lang/cargo#15602) - Update gix & socket2 (rust-lang/cargo#15600) - Add `-Zfix-edition` (rust-lang/cargo#15596) - chore(toml): disable `toml`'s default features, unless necessary (rust-lang/cargo#15598) - docs(README): fix the link to the changelog in the Cargo book (rust-lang/cargo#15597) - Add the future edition (rust-lang/cargo#15595) r? ghost
What does this PR try to resolve?
This separates the concern of two different "mode".
This is a preparation of adding
-Zno-link
/-Zlink-only
support,which we'll have
CompileMode::Link
but that doesn't make sense toshow up in
UserIntent
.How should we test and review this PR?
It should have no functional change.
Additional information