refactor: separate "global" mode from CompileMode#15601
refactor: separate "global" mode from CompileMode#15601ehuss merged 2 commits intorust-lang:masterfrom
Conversation
| 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.
Actually should be plural 😬.
| /// | ||
| /// 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.
Why is the deps field on CompileMode too and not just on UserIntent?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
I missed that. You're right.
There was a problem hiding this comment.
Went ahead and removed the deps field as well. Thanks for the good catch!
What does this PR try to resolve?
This separates the concern of two different "mode".
This is a preparation of adding
-Zno-link/-Zlink-onlysupport,which we'll have
CompileMode::Linkbut 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