Open
Description
While working on #123974, I had a failure when running doctests of the unstable book. Rustdoc generates this code:
#![allow(unused_extern_crates)]
#![allow(internal_features)]
#![feature(test)]
#![feature(rustc_attrs)]
#![feature(coverage_attribute)]
#![feature(link_arg_attribute)]
#![allow(unused)]
extern crate test;
mod __doctest_0 {
fn main() {
#[link(kind = "link-arg", name = "--start-group")]
#[link(kind = "static", name = "c")] // Causing the segfault
#[link(kind = "static", name = "gcc")]
#[link(kind = "link-arg", name = "--end-group")]
extern "C" {}
}
#[rustc_test_marker = "/home/imperio/rust/rust/src/doc/unstable-book/src/language-features/link-arg-attribute.md - The_tracking_issue_for_this_feature_is__ (line 11)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("/home/imperio/rust/rust/src/doc/unstable-book/src/language-features/link-arg-attribute.md - The_tracking_issue_for_this_feature_is__ (line 11)"),
ignore: false,
ignore_message: None,
source_file: "_home_imperio_rust_rust_src_doc_unstable_book_src_language_features_link_arg_attribute_md",
start_line: 11,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
#[rustc_main]
#[coverage(off)]
fn main() {
test::test_main(&["rustdoctest".to_string(),], vec![__doctest_0::TEST], None);
}
If you compile and run this program (on linux x86_64), it'll segfault. Commenting #[link(kind = "static", name = "c")]
will make it run without problem.