Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ pub(crate) struct Options {

/// Arguments to be used when compiling doctests.
pub(crate) doctest_build_args: Vec<String>,

/// Target modifiers.
pub(crate) target_modifiers: BTreeMap<OptionsTargetModifiers, String>,
}

impl fmt::Debug for Options {
Expand Down Expand Up @@ -846,6 +849,7 @@ impl Options {
unstable_features,
expanded_args: args,
doctest_build_args,
target_modifiers,
};
let render_options = RenderOptions {
output,
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ pub(crate) fn create_config(
scrape_examples_options,
expanded_args,
remap_path_prefix,
target_modifiers,
..
}: RustdocOptions,
render_options: &RenderOptions,
Expand Down Expand Up @@ -277,6 +278,7 @@ pub(crate) fn create_config(
} else {
OutputTypes::new(&[])
},
target_modifiers,
..Options::default()
};

Expand Down
7 changes: 7 additions & 0 deletions tests/run-make/rustdoc-target-modifiers/c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![allow(internal_features)]
#![feature(lang_items, no_core)]
#![no_core]

fn f() {
d::f();
}
12 changes: 12 additions & 0 deletions tests/run-make/rustdoc-target-modifiers/d.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![allow(internal_features)]
#![feature(lang_items, no_core)]
#![no_core]

#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}

pub fn f() {}
28 changes: 28 additions & 0 deletions tests/run-make/rustdoc-target-modifiers/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Test that target modifiers are taken into account by `rustdoc`.
//!
//! Otherwise, `rustdoc` errors when trying to generate documentation
//! using dependencies (e.g. `core`) that set a target modifier.
//!
//! Please see https://github.com/rust-lang/rust/issues/144521.

use run_make_support::{rustc, rustdoc};

fn main() {
rustc()
.input("d.rs")
.edition("2024")
.crate_type("rlib")
.emit("metadata")
.sysroot("/dev/null")
.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")
.run();
}
Loading