Skip to content

Commit 2d693d5

Browse files
committed
Pass rustdocflags like rustflags
1 parent 35eaf32 commit 2d693d5

File tree

10 files changed

+25
-18
lines changed

10 files changed

+25
-18
lines changed

src/cargo/core/compiler/build_context/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,6 @@ impl<'a, 'gctx> BuildContext<'a, 'gctx> {
134134
self.build_config.jobs
135135
}
136136

137-
/// Extra compiler flags to pass to `rustdoc` for a given unit.
138-
///
139-
/// Although it depends on the caller, in the current Cargo implementation,
140-
/// these flags take precedence over those from [`BuildContext::extra_args_for`].
141-
///
142-
/// As of now, these flags come from environment variables and configurations.
143-
/// See [`TargetInfo.rustdocflags`] for more on how Cargo collects them.
144-
///
145-
/// [`TargetInfo.rustdocflags`]: TargetInfo::rustdocflags
146-
pub fn rustdocflags_args(&self, unit: &Unit) -> &[String] {
147-
&self.target_data.info(unit.kind).rustdocflags
148-
}
149-
150137
/// Extra compiler args for either `rustc` or `rustdoc`.
151138
///
152139
/// As of now, these flags come from the trailing args of either

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub struct TargetInfo {
5555
/// Extra flags to pass to `rustc`, see [`extra_args`].
5656
pub rustflags: Arc<[String]>,
5757
/// Extra flags to pass to `rustdoc`, see [`extra_args`].
58-
pub rustdocflags: Vec<String>,
58+
pub rustdocflags: Arc<[String]>,
5959
/// Whether or not rustc (stably) supports the `--check-cfg` flag.
6060
///
6161
/// Can be removed once the minimum supported rustc version of Cargo is
@@ -321,7 +321,8 @@ impl TargetInfo {
321321
Some(&cfg),
322322
kind,
323323
Flags::Rustdoc,
324-
)?,
324+
)?
325+
.into(),
325326
cfg,
326327
support_split_debuginfo,
327328
support_check_cfg,

src/cargo/core/compiler/build_runner/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
269269
}
270270
}
271271
}
272-
args.extend(self.bcx.rustdocflags_args(unit).iter().map(Into::into));
272+
args.extend(unit.rustdocflags.iter().map(Into::into));
273273

274274
use super::MessageFormat;
275275
let format = match self.bcx.build_config.message_format {

src/cargo/core/compiler/fingerprint/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ fn calculate_normal(
14151415
// hashed to take up less space on disk as we just need to know when things
14161416
// change.
14171417
let extra_flags = if unit.mode.is_doc() || unit.mode.is_doc_scrape() {
1418-
build_runner.bcx.rustdocflags_args(unit)
1418+
&unit.rustdocflags
14191419
} else {
14201420
&unit.rustflags
14211421
}

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ fn prepare_rustdoc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResu
780780

781781
rustdoc::add_output_format(build_runner, unit, &mut rustdoc)?;
782782

783-
rustdoc.args(bcx.rustdocflags_args(unit));
783+
rustdoc.args(&unit.rustdocflags);
784784

785785
if !crate_version_flag_already_present(&rustdoc) {
786786
append_crate_version_flag(unit, &mut rustdoc);

src/cargo/core/compiler/standard_lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ pub fn generate_std_roots(
218218
mode,
219219
features.clone(),
220220
target_data.info(*kind).rustflags.clone(),
221+
target_data.info(*kind).rustdocflags.clone(),
221222
/*is_std*/ true,
222223
/*dep_hash*/ 0,
223224
IsArtifact::No,

src/cargo/core/compiler/unit.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ pub struct UnitInner {
7171
/// [`BuildContext::extra_args_for`]: crate::core::compiler::build_context::BuildContext::extra_args_for
7272
/// [`TargetInfo.rustflags`]: crate::core::compiler::build_context::TargetInfo::rustflags
7373
pub rustflags: Arc<[String]>,
74+
/// Extra compiler flags to pass to `rustdoc` for a given unit.
75+
///
76+
/// Although it depends on the caller, in the current Cargo implementation,
77+
/// these flags take precedence over those from [`BuildContext::extra_args_for`].
78+
///
79+
/// As of now, these flags come from environment variables and configurations.
80+
/// See [`TargetInfo.rustdocflags`] for more on how Cargo collects them.
81+
///
82+
/// [`BuildContext::extra_args_for`]: crate::core::compiler::build_context::BuildContext::extra_args_for
83+
/// [`TargetInfo.rustdocflags`]: crate::core::compiler::build_context::TargetInfo::rustdocflags
84+
pub rustdocflags: Arc<[String]>,
7485
// if `true`, the dependency is an artifact dependency, requiring special handling when
7586
// calculating output directories, linkage and environment variables provided to builds.
7687
pub artifact: IsArtifact,
@@ -212,6 +223,7 @@ impl UnitInterner {
212223
mode: CompileMode,
213224
features: Vec<InternedString>,
214225
rustflags: Arc<[String]>,
226+
rustdocflags: Arc<[String]>,
215227
is_std: bool,
216228
dep_hash: u64,
217229
artifact: IsArtifact,
@@ -246,6 +258,7 @@ impl UnitInterner {
246258
mode,
247259
features,
248260
rustflags,
261+
rustdocflags,
249262
is_std,
250263
dep_hash,
251264
artifact,

src/cargo/core/compiler/unit_dependencies.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ fn new_unit_dep_with_profile(
860860
mode,
861861
features,
862862
state.target_data.info(kind).rustflags.clone(),
863+
state.target_data.info(kind).rustdocflags.clone(),
863864
state.is_std,
864865
/*dep_hash*/ 0,
865866
artifact.map_or(IsArtifact::No, |_| IsArtifact::Yes),

src/cargo/ops/cargo_compile/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ fn traverse_and_share(
697697
unit.mode,
698698
unit.features.clone(),
699699
unit.rustflags.clone(),
700+
unit.rustdocflags.clone(),
700701
unit.is_std,
701702
unit.dep_hash,
702703
unit.artifact,
@@ -723,6 +724,7 @@ fn traverse_and_share(
723724
unit.mode,
724725
unit.features.clone(),
725726
unit.rustflags.clone(),
727+
unit.rustdocflags.clone(),
726728
unit.is_std,
727729
new_dep_hash,
728730
unit.artifact,
@@ -885,6 +887,7 @@ fn override_rustc_crate_types(
885887
unit.mode,
886888
unit.features.clone(),
887889
unit.rustflags.clone(),
890+
unit.rustdocflags.clone(),
888891
unit.is_std,
889892
unit.dep_hash,
890893
unit.artifact,

src/cargo/ops/cargo_compile/unit_generator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ impl<'a> UnitGenerator<'a, '_> {
172172
target_mode,
173173
features.clone(),
174174
self.target_data.info(kind).rustflags.clone(),
175+
self.target_data.info(kind).rustdocflags.clone(),
175176
/*is_std*/ false,
176177
/*dep_hash*/ 0,
177178
IsArtifact::No,

0 commit comments

Comments
 (0)