]> git.lizzy.rs Git - rust.git/commitdiff
Add regression test for issue #18804
authorGabriel Smith <ga29smith@gmail.com>
Mon, 23 Jul 2018 00:33:04 +0000 (20:33 -0400)
committerGabriel Smith <ga29smith@gmail.com>
Wed, 25 Jul 2018 00:15:06 +0000 (20:15 -0400)
Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
src/test/run-pass/issue-18804/auxiliary/lib.rs [new file with mode: 0644]
src/test/run-pass/issue-18804/main.rs [new file with mode: 0644]

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 (file)
index 0000000..06d454b
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>() -> *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 (file)
index 0000000..de7967e
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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::<i32>();
+}