Skip to content

Commit 2a26aef

Browse files
committed
Rename "target" to "unit" in code related to generate_targets
1 parent cb97d06 commit 2a26aef

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/cargo/ops/cargo_compile/compile_filter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ pub enum FilterRule {
2828
/// Filter to apply to the root package to select which Cargo targets will be built.
2929
/// (examples, bins, benches, tests, ...)
3030
///
31-
/// The actual filter process happens inside [`generate_targets`].
31+
/// The actual filter process happens inside [`generate_units`].
3232
///
3333
/// Not to be confused with [`Packages`], which opts in packages to be built.
3434
///
35-
/// [`generate_targets`]: super::TargetGenerator::generate_targets
35+
/// [`generate_units`]: super::UnitGenerator::generate_units
3636
/// [`Packages`]: crate::ops::Packages
3737
#[derive(Debug)]
3838
pub enum CompileFilter {
@@ -176,7 +176,7 @@ impl CompileFilter {
176176
/// may include additional example targets to ensure they can be compiled.
177177
///
178178
/// Note that the actual behavior is subject to `filter_default_targets`
179-
/// and `generate_targets` though.
179+
/// and `generate_units` though.
180180
pub fn all_test_targets() -> Self {
181181
Self::Only {
182182
all_targets: false,
@@ -234,7 +234,7 @@ impl CompileFilter {
234234
}
235235

236236
/// Selects targets for "cargo run". for logic to select targets for other
237-
/// subcommands, see `generate_targets` and `filter_default_targets`.
237+
/// subcommands, see `generate_units` and `filter_default_targets`.
238238
pub fn target_run(&self, target: &Target) -> bool {
239239
match *self {
240240
CompileFilter::Default { .. } => true,

src/cargo/ops/cargo_compile/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! - Download any packages needed (see [`PackageSet`](crate::core::PackageSet)).
1111
//! - Generate a list of top-level "units" of work for the targets the user
1212
//! requested on the command-line. Each [`Unit`] corresponds to a compiler
13-
//! invocation. This is done in this module ([`TargetGenerator::generate_targets`]).
13+
//! invocation. This is done in this module ([`UnitGenerator::generate_units`]).
1414
//! - Build the graph of `Unit` dependencies (see [`unit_dependencies`]).
1515
//! - Create a [`Context`] which will perform the following steps:
1616
//! - Prepare the `target` directory (see [`Layout`]).
@@ -54,9 +54,9 @@ use crate::util::{profile, CargoResult, StableHasher};
5454
mod compile_filter;
5555
pub use compile_filter::{CompileFilter, FilterRule, LibRule};
5656

57-
mod target_generator;
58-
pub use target_generator::resolve_all_features;
59-
use target_generator::TargetGenerator;
57+
mod unit_generator;
58+
pub use unit_generator::resolve_all_features;
59+
use unit_generator::UnitGenerator;
6060

6161
mod packages;
6262

@@ -345,11 +345,11 @@ pub fn create_bcx<'a, 'cfg>(
345345
.collect();
346346

347347
// Passing `build_config.requested_kinds` instead of
348-
// `explicit_host_kinds` here so that `generate_targets` can do
348+
// `explicit_host_kinds` here so that `generate_units` can do
349349
// its own special handling of `CompileKind::Host`. It will
350350
// internally replace the host kind by the `explicit_host_kind`
351351
// before setting as a unit.
352-
let generator = TargetGenerator {
352+
let generator = UnitGenerator {
353353
ws,
354354
packages: &to_builds,
355355
filter,
@@ -364,19 +364,19 @@ pub fn create_bcx<'a, 'cfg>(
364364
interner,
365365
has_dev_units,
366366
};
367-
let mut units = generator.generate_targets()?;
367+
let mut units = generator.generate_units()?;
368368

369369
if let Some(args) = target_rustc_crate_types {
370370
override_rustc_crate_types(&mut units, args, interner)?;
371371
}
372372

373373
let should_scrape = build_config.mode.is_doc() && config.cli_unstable().rustdoc_scrape_examples;
374374
let mut scrape_units = if should_scrape {
375-
let scrape_generator = TargetGenerator {
375+
let scrape_generator = UnitGenerator {
376376
mode: CompileMode::Docscrape,
377377
..generator
378378
};
379-
let all_units = scrape_generator.generate_targets()?;
379+
let all_units = scrape_generator.generate_units()?;
380380

381381
let valid_units = all_units
382382
.into_iter()

src/cargo/ops/cargo_compile/target_generator.rs renamed to src/cargo/ops/cargo_compile/unit_generator.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ struct Proposal<'a> {
3333
mode: CompileMode,
3434
}
3535

36-
/// The context needed for generating targets.
37-
pub(super) struct TargetGenerator<'a, 'cfg> {
36+
/// The context needed for generating units.
37+
pub(super) struct UnitGenerator<'a, 'cfg> {
3838
pub ws: &'a Workspace<'cfg>,
3939
pub packages: &'a [&'a Package],
4040
pub filter: &'a CompileFilter,
@@ -50,7 +50,7 @@ pub(super) struct TargetGenerator<'a, 'cfg> {
5050
pub has_dev_units: HasDevUnits,
5151
}
5252

53-
impl<'a> TargetGenerator<'a, '_> {
53+
impl<'a> UnitGenerator<'a, '_> {
5454
/// Helper for creating a list of `Unit` structures
5555
fn new_units(
5656
&self,
@@ -657,9 +657,9 @@ impl<'a> TargetGenerator<'a, '_> {
657657
Ok(units)
658658
}
659659

660-
/// Generates all the base targets for the packages the user has requested to
661-
/// compile. Dependencies for these targets are computed later in `unit_dependencies`.
662-
pub fn generate_targets(&self) -> CargoResult<Vec<Unit>> {
660+
/// Generates all the base units for the packages the user has requested to
661+
/// compile. Dependencies for these units are computed later in `unit_dependencies`.
662+
pub fn generate_units(&self) -> CargoResult<Vec<Unit>> {
663663
let proposals = self.create_proposals()?;
664664
self.proposals_to_units(proposals)
665665
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module. The compilation can be conceptually broken into these steps:
99

1010
1. Perform dependency resolution (see [the resolution chapter]).
1111
2. Generate the root `Unit`s, the things the user requested to compile on the
12-
command-line. This is done in [`generate_targets`].
12+
command-line. This is done in [`generate_units`].
1313
3. Starting from the root `Unit`s, generate the [`UnitGraph`] by walking the
1414
dependency graph from the resolver. The `UnitGraph` contains all of the
1515
`Unit` structs, and information about the dependency relationships between

src/doc/contrib/src/tests/writing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ environment. The general process is:
269269
* `/path/to/my/cargo/target/debug/cargo check`
270270
* Using a debugger like `lldb` or `gdb`:
271271
1. `lldb /path/to/my/cargo/target/debug/cargo`
272-
2. Set a breakpoint, for example: `b generate_targets`
272+
2. Set a breakpoint, for example: `b generate_units`
273273
3. Run with arguments: `r check`
274274

275275
[`testsuite`]: https://github.com/rust-lang/cargo/tree/master/tests/testsuite/

0 commit comments

Comments
 (0)