Rollup merge of #148068 - tmiasko:doctest-target-modifiers, r=GuillaumeGomez

rustdoc: Use configured target modifiers when collecting doctests

To support loading dependencies with target modifiers and avoid ABI mismatch errors.

Fixes rust-lang/rust#146465.
This commit is contained in:
Guillaume Gomez 2025-11-03 17:20:33 +01:00 committed by GitHub
commit c0bbebfa26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 0 deletions

View file

@ -166,6 +166,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
remap_path_prefix: options.remap_path_prefix.clone(),
unstable_opts: options.unstable_opts.clone(),
error_format: options.error_format.clone(),
target_modifiers: options.target_modifiers.clone(),
..config::Options::default()
};

View file

@ -25,4 +25,43 @@ fn main() {
.target("aarch64-unknown-none-softfloat")
.arg("-Zfixed-x18")
.run();
rustdoc()
.input("c.rs")
.crate_type("rlib")
.extern_("d", "libd.rmeta")
.target("aarch64-unknown-none-softfloat")
.arg("-Zfixed-x18")
.arg("--test")
.run();
rustdoc()
.input("c.rs")
.edition("2024")
.crate_type("rlib")
.extern_("d", "libd.rmeta")
.target("aarch64-unknown-none-softfloat")
.arg("-Zfixed-x18")
.arg("--test")
.run();
// rustdoc --test detects ABI mismatch
rustdoc()
.input("c.rs")
.crate_type("rlib")
.extern_("d", "libd.rmeta")
.target("aarch64-unknown-none-softfloat")
.arg("--test")
.run_fail()
.assert_stderr_contains("mixing `-Zfixed-x18` will cause an ABI mismatch");
// rustdoc --test -Cunsafe-allow-abi-mismatch=... ignores the mismatch
rustdoc()
.input("c.rs")
.crate_type("rlib")
.extern_("d", "libd.rmeta")
.target("aarch64-unknown-none-softfloat")
.arg("--test")
.arg("-Cunsafe-allow-abi-mismatch=fixed-x18")
.run();
}