Skip to content

Commit 9bef78d

Browse files
committed
Merge remote-tracking branch 'upstream/master' into owner
* upstream/master: docs: fix typos in `cargo_compile/mod.rs` docs(contrib): Replace architecture with redirects docs(contrub): Remove unused file docs(contrib): Move some lower resolver details from ops to core docs(contrib): Move higher level resolver docs into doc comments docs(contrib): Pull impl info out of architecture
2 parents 786e0b6 + b1dcb62 commit 9bef78d

File tree

17 files changed

+117
-151
lines changed

17 files changed

+117
-151
lines changed

src/cargo/core/resolver/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@
3737
//! everything to bail out immediately and return success, and only if *nothing*
3838
//! works do we actually return an error up the stack.
3939
//!
40+
//! Resolution is currently performed twice
41+
//! 1. With all features enabled (this is what gets saved to `Cargo.lock`)
42+
//! 2. With only the specific features the user selected on the command-line. Ideally this
43+
//! run will get removed in the future when transitioning to the new feature resolver.
44+
//!
45+
//! A new feature-specific resolver was added in 2020 which adds more sophisticated feature
46+
//! resolution. It is located in the [`features`] module. The original dependency resolver still
47+
//! performs feature unification, as it can help reduce the dependencies it has to consider during
48+
//! resolution (rather than assuming every optional dependency of every package is enabled).
49+
//! Checking if a feature is enabled must go through the new feature resolver.
50+
//!
4051
//! ## Performance
4152
//!
4253
//! Note that this is a relatively performance-critical portion of Cargo. The

src/cargo/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
//! This is the entry point for all the compilation commands. This is a
3232
//! good place to start if you want to follow how compilation starts and
3333
//! flows to completion.
34-
//! - [`core::resolver`]:
35-
//! This is the dependency and feature resolvers.
34+
//! - [`ops::resolve`]:
35+
//! Top-level API for dependency and feature resolver (e.g. [`ops::resolve_ws`])
36+
//! - [`core::resolver`]: The core algorithm
3637
//! - [`core::compiler`]:
3738
//! This is the code responsible for running `rustc` and `rustdoc`.
3839
//! - [`core::compiler::build_context`]:

src/cargo/ops/cargo_compile/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! from the resolver. See also [`unit_dependencies`].
1616
//! 5. Construct the [`BuildContext`] with all of the information collected so
1717
//! far. This is the end of the "front end" of compilation.
18-
//! 6. Create a [`Context`] which oordinates the compilation process a
18+
//! 6. Create a [`Context`] which coordinates the compilation process
1919
//! and will perform the following steps:
2020
//! 1. Prepare the `target` directory (see [`Layout`]).
2121
//! 2. Create a [`JobQueue`]. The queue checks the

src/cargo/ops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ mod common_for_install_and_uninstall;
5353
mod fix;
5454
pub(crate) mod lockfile;
5555
pub(crate) mod registry;
56-
mod resolve;
56+
pub(crate) mod resolve;
5757
pub mod tree;
5858
mod vendor;
5959

src/cargo/ops/resolve.rs

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,59 @@
11
//! High-level APIs for executing the resolver.
22
//!
3-
//! This module provides functions for running the resolver given a workspace.
3+
//! This module provides functions for running the resolver given a workspace, including loading
4+
//! the `Cargo.lock` file and checkinf if it needs updating.
5+
//!
46
//! There are roughly 3 main functions:
57
//!
6-
//! - `resolve_ws`: A simple, high-level function with no options.
7-
//! - `resolve_ws_with_opts`: A medium-level function with options like
8+
//! - [`resolve_ws`]: A simple, high-level function with no options.
9+
//! - [`resolve_ws_with_opts`]: A medium-level function with options like
810
//! user-provided features. This is the most appropriate function to use in
911
//! most cases.
10-
//! - `resolve_with_previous`: A low-level function for running the resolver,
12+
//! - [`resolve_with_previous`]: A low-level function for running the resolver,
1113
//! providing the most power and flexibility.
14+
//!
15+
//! ### Data Structures
16+
//!
17+
//! - [`Workspace`]:
18+
//! Usually created by [`crate::util::command_prelude::ArgMatchesExt::workspace`] which discovers the root of the
19+
//! workspace, and loads all the workspace members as a [`Package`] object
20+
//! - [`Package`]
21+
//! Corresponds with `Cargo.toml` manifest (deserialized as [`Manifest`]) and its associated files.
22+
//! - [`Target`]s are crates such as the library, binaries, integration test, or examples.
23+
//! They are what is actually compiled by `rustc`.
24+
//! Each `Target` defines a crate root, like `src/lib.rs` or `examples/foo.rs`.
25+
//! - [`PackageId`] --- A unique identifier for a package.
26+
//! - [`PackageRegistry`]:
27+
//! The primary interface for how the dependency
28+
//! resolver finds packages. It contains the `SourceMap`, and handles things
29+
//! like the `[patch]` table. The dependency resolver
30+
//! sends a query to the `PackageRegistry` to "get me all packages that match
31+
//! this dependency declaration". The `Registry` trait provides a generic interface
32+
//! to the `PackageRegistry`, but this is only used for providing an alternate
33+
//! implementation of the `PackageRegistry` for testing.
34+
//! - [`SourceMap`]: Map of all available sources.
35+
//! - [`Source`]: An abstraction for something that can fetch packages (a remote
36+
//! registry, a git repo, the local filesystem, etc.). Check out the [source
37+
//! implementations] for all the details about registries, indexes, git
38+
//! dependencies, etc.
39+
//! * [`SourceId`]: A unique identifier for a source.
40+
//! - [`Summary`]: A of a [`Manifest`], and is essentially
41+
//! the information that can be found in a registry index. Queries against the
42+
//! `PackageRegistry` yields a `Summary`. The resolver uses the summary
43+
//! information to build the dependency graph.
44+
//! - [`PackageSet`] --- Contains all of the `Package` objects. This works with the
45+
//! [`Downloads`] struct to coordinate downloading packages. It has a reference
46+
//! to the `SourceMap` to get the `Source` objects which tell the `Downloads`
47+
//! struct which URLs to fetch.
48+
//!
49+
//! [`Package`]: crate::core::package
50+
//! [`Target`]: crate::core::Target
51+
//! [`Manifest`]: crate::core::Manifest
52+
//! [`Source`]: crate::core::Source
53+
//! [`SourceMap`]: crate::core::SourceMap
54+
//! [`PackageRegistry`]: crate::core::registry::PackageRegistry
55+
//! [source implementations]: crate::sources
56+
//! [`Downloads`]: crate::core::package::Downloads
1257
1358
use crate::core::compiler::{CompileKind, RustcTargetData};
1459
use crate::core::registry::{LockedPatchDependency, PackageRegistry};

src/doc/contrib/book.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ git-repository-url = "https://github.com/rust-lang/cargo/tree/master/src/doc/con
88

99
[output.html.redirect]
1010
"/apidoc/cargo/index.html" = "https://doc.rust-lang.org/nightly/nightly-rustc/cargo/"
11+
"/architecture/index.html" = "../implementation/architecture.html"
12+
"/architecture/console.html" = "../implementation/console.html"
13+
"/architecture/subcommands.html" = "../implementation/subcommands.html"
14+
"/architecture/codebase.html" = "https://doc.rust-lang.org/nightly/nightly-rustc/cargo"
15+
"/architecture/compilation.html" = "https://doc.rust-lang.org/nightly/nightly-rustc/cargo"
16+
"/architecture/files.html" = "https://doc.rust-lang.org/nightly/nightly-rustc/cargo"
17+
"/architecture/packages.html" = "https://doc.rust-lang.org/nightly/nightly-rustc/cargo"

src/doc/contrib/src/SUMMARY.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
- [Release process](./process/release.md)
88
- [Unstable features](./process/unstable.md)
99
- [Design Principles](./design.md)
10-
- [Architecture](./architecture/index.md)
11-
- [Codebase Overview](./architecture/codebase.md)
12-
- [SubCommands](./architecture/subcommands.md)
13-
- [Console Output](./architecture/console.md)
14-
- [Packages and Resolution](./architecture/packages.md)
15-
- [Compilation](./architecture/compilation.md)
16-
- [Files](./architecture/files.md)
10+
- [Implementing a Change](./implementation/index.md)
11+
- [Architecture](./implementation/architecture.md)
12+
- [New subcommands](./implementation/subcommands.md)
13+
- [Console Output](./implementation/console.md)
14+
- [Filesystem](./implementation/filesystem.md)
15+
- [Debugging](./implementation/debugging.md)
1716
- [Tests](./tests/index.md)
1817
- [Running Tests](./tests/running.md)
1918
- [Writing Tests](./tests/writing.md)

src/doc/contrib/src/architecture/codebase.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/doc/contrib/src/architecture/compilation.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/doc/contrib/src/architecture/index.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)