Skip to content

Commit a4d2e29

Browse files
committed
Gleaning rustdocflags from target.cfg(…) is not supported
The bug was `rustflags_from_target` trying to learn rustdocflags from `target.cfg(…).rustflags`, which is definitely wrong. As of this writing, either `target.cfg(…).rustdocflags` or `target.<triple>.rustdocflags` is not supported.
1 parent f8d1b30 commit a4d2e29

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,15 @@ fn rustflags_from_target(
749749
.target_cfgs()?
750750
.iter()
751751
.filter_map(|(key, cfg)| {
752-
cfg.rustflags
753-
.as_ref()
754-
.map(|rustflags| (key, &rustflags.val))
752+
match flag {
753+
Flags::Rust => cfg
754+
.rustflags
755+
.as_ref()
756+
.map(|rustflags| (key, &rustflags.val)),
757+
// `target.cfg(…).rustdocflags` is currently not supported.
758+
// In fact, neither is `target.<triple>.rustdocflags`.
759+
Flags::Rustdoc => None,
760+
}
755761
})
756762
.filter(|(key, _rustflags)| CfgExpr::matches_key(key, target_cfg))
757763
.for_each(|(_key, cfg_rustflags)| {

tests/testsuite/rustdocflags.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ fn not_affected_by_target_rustflags() {
148148
.with_stderr_contains("[RUNNING] `rustc [..] -D missing-docs[..]`")
149149
.run();
150150

151-
// This is wrong behaviour. `cargo doc` shouldn't fail.
151+
// `cargo doc` shouldn't fail.
152152
p.cargo("doc -v")
153-
.with_status(101)
154-
.with_stderr_contains("[RUNNING] `rustdoc [..] -D missing-docs[..]`")
153+
.with_stderr_contains("[RUNNING] `rustdoc [..] --cfg foo[..]`")
155154
.run();
156155
}

0 commit comments

Comments
 (0)