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.
This commit is contained in:
Weihang Lo 2022-11-01 14:55:03 +00:00
parent f8d1b30ad3
commit a4d2e29e21
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7
2 changed files with 11 additions and 6 deletions

View File

@ -749,9 +749,15 @@ fn rustflags_from_target(
.target_cfgs()?
.iter()
.filter_map(|(key, cfg)| {
cfg.rustflags
.as_ref()
.map(|rustflags| (key, &rustflags.val))
match flag {
Flags::Rust => cfg
.rustflags
.as_ref()
.map(|rustflags| (key, &rustflags.val)),
// `target.cfg(…).rustdocflags` is currently not supported.
// In fact, neither is `target.<triple>.rustdocflags`.
Flags::Rustdoc => None,
}
})
.filter(|(key, _rustflags)| CfgExpr::matches_key(key, target_cfg))
.for_each(|(_key, cfg_rustflags)| {

View File

@ -148,9 +148,8 @@ fn not_affected_by_target_rustflags() {
.with_stderr_contains("[RUNNING] `rustc [..] -D missing-docs[..]`")
.run();
// This is wrong behaviour. `cargo doc` shouldn't fail.
// `cargo doc` shouldn't fail.
p.cargo("doc -v")
.with_status(101)
.with_stderr_contains("[RUNNING] `rustdoc [..] -D missing-docs[..]`")
.with_stderr_contains("[RUNNING] `rustdoc [..] --cfg foo[..]`")
.run();
}