From e8bc064c5ecf7775999beef233e2d82c9a534362 Mon Sep 17 00:00:00 2001 From: Gabriel Smith Date: Sun, 22 Jul 2018 20:33:04 -0400 Subject: [PATCH] Add regression test for issue #18804 Signed-off-by: Gabriel Smith --- .../run-pass/issue-18804/auxiliary/lib.rs | 20 +++++++++++++++++++ src/test/run-pass/issue-18804/main.rs | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/test/run-pass/issue-18804/auxiliary/lib.rs create mode 100644 src/test/run-pass/issue-18804/main.rs diff --git a/src/test/run-pass/issue-18804/auxiliary/lib.rs b/src/test/run-pass/issue-18804/auxiliary/lib.rs new file mode 100644 index 0000000000000..06d454b2c890a --- /dev/null +++ b/src/test/run-pass/issue-18804/auxiliary/lib.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(linkage)] + +pub fn foo() -> *const() { + extern { + #[linkage = "extern_weak"] + static FOO: *const(); + } + unsafe { FOO } +} diff --git a/src/test/run-pass/issue-18804/main.rs b/src/test/run-pass/issue-18804/main.rs new file mode 100644 index 0000000000000..de7967e8d3490 --- /dev/null +++ b/src/test/run-pass/issue-18804/main.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for issue #18804, #[linkage] does not propagate thorugh generic +// functions. Failure results in a linker error. + +// aux-build:lib.rs + +extern crate lib; + +fn main() { + lib::foo::(); +}