diff options
Diffstat (limited to 'src/test/ui/extern/auxiliary')
-rw-r--r-- | src/test/ui/extern/auxiliary/extern-take-value.rs | 5 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/extern-types-inherent-impl.rs | 9 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/extern_calling_convention.rs | 26 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/extern_mod_ordering_lib.rs | 5 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/fat_drop.rs | 13 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/invalid-utf8.txt | 1 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/issue-80074-macro.rs | 4 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/m1.rs | 1 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/m2.rs | 1 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/no-mangle-associated-fn.rs | 21 | ||||
-rw-r--r-- | src/test/ui/extern/auxiliary/reexport-should-still-link.rs | 5 |
11 files changed, 91 insertions, 0 deletions
diff --git a/src/test/ui/extern/auxiliary/extern-take-value.rs b/src/test/ui/extern/auxiliary/extern-take-value.rs new file mode 100644 index 000000000..56256aa19 --- /dev/null +++ b/src/test/ui/extern/auxiliary/extern-take-value.rs @@ -0,0 +1,5 @@ +pub extern "C" fn f() -> i32 { 1 } +pub extern "C" fn g() -> i32 { 2 } + +pub fn get_f() -> extern "C" fn() -> i32 { f } +pub fn get_g() -> extern "C" fn() -> i32 { g } diff --git a/src/test/ui/extern/auxiliary/extern-types-inherent-impl.rs b/src/test/ui/extern/auxiliary/extern-types-inherent-impl.rs new file mode 100644 index 000000000..a1efe1818 --- /dev/null +++ b/src/test/ui/extern/auxiliary/extern-types-inherent-impl.rs @@ -0,0 +1,9 @@ +#![feature(extern_types)] + +extern "C" { + pub type CrossCrate; +} + +impl CrossCrate { + pub fn foo(&self) {} +} diff --git a/src/test/ui/extern/auxiliary/extern_calling_convention.rs b/src/test/ui/extern/auxiliary/extern_calling_convention.rs new file mode 100644 index 000000000..e24cf9fda --- /dev/null +++ b/src/test/ui/extern/auxiliary/extern_calling_convention.rs @@ -0,0 +1,26 @@ +// Make sure Rust generates the correct calling convention for extern +// functions. + +#[inline(never)] +#[cfg(target_arch = "x86_64")] +pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + assert_eq!(d, 4); + + println!("a: {}, b: {}, c: {}, d: {}", + a, b, c, d) +} + +#[inline(never)] +#[cfg(not(target_arch = "x86_64"))] +pub extern "C" fn foo(a: isize, b: isize, c: isize, d: isize) { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + assert_eq!(d, 4); + + println!("a: {}, b: {}, c: {}, d: {}", + a, b, c, d) +} diff --git a/src/test/ui/extern/auxiliary/extern_mod_ordering_lib.rs b/src/test/ui/extern/auxiliary/extern_mod_ordering_lib.rs new file mode 100644 index 000000000..7357f5970 --- /dev/null +++ b/src/test/ui/extern/auxiliary/extern_mod_ordering_lib.rs @@ -0,0 +1,5 @@ +#![crate_type="lib"] + +pub mod extern_mod_ordering_lib { + pub fn f() {} +} diff --git a/src/test/ui/extern/auxiliary/fat_drop.rs b/src/test/ui/extern/auxiliary/fat_drop.rs new file mode 100644 index 000000000..768d29876 --- /dev/null +++ b/src/test/ui/extern/auxiliary/fat_drop.rs @@ -0,0 +1,13 @@ +pub static mut DROPPED: bool = false; + +pub struct S { + _unsized: [u8] +} + +impl Drop for S { + fn drop(&mut self) { + unsafe { + DROPPED = true; + } + } +} diff --git a/src/test/ui/extern/auxiliary/invalid-utf8.txt b/src/test/ui/extern/auxiliary/invalid-utf8.txt new file mode 100644 index 000000000..dc1115b82 --- /dev/null +++ b/src/test/ui/extern/auxiliary/invalid-utf8.txt @@ -0,0 +1 @@ +Ã(
\ No newline at end of file diff --git a/src/test/ui/extern/auxiliary/issue-80074-macro.rs b/src/test/ui/extern/auxiliary/issue-80074-macro.rs new file mode 100644 index 000000000..30e0f19ab --- /dev/null +++ b/src/test/ui/extern/auxiliary/issue-80074-macro.rs @@ -0,0 +1,4 @@ +// edition:2018 + +macro_rules! foo_ { () => {}; } +use foo_ as foo; diff --git a/src/test/ui/extern/auxiliary/m1.rs b/src/test/ui/extern/auxiliary/m1.rs new file mode 100644 index 000000000..b76b4321d --- /dev/null +++ b/src/test/ui/extern/auxiliary/m1.rs @@ -0,0 +1 @@ +pub fn foo() {} diff --git a/src/test/ui/extern/auxiliary/m2.rs b/src/test/ui/extern/auxiliary/m2.rs new file mode 100644 index 000000000..c5c0bc606 --- /dev/null +++ b/src/test/ui/extern/auxiliary/m2.rs @@ -0,0 +1 @@ +pub fn bar() {} diff --git a/src/test/ui/extern/auxiliary/no-mangle-associated-fn.rs b/src/test/ui/extern/auxiliary/no-mangle-associated-fn.rs new file mode 100644 index 000000000..7fc73c76c --- /dev/null +++ b/src/test/ui/extern/auxiliary/no-mangle-associated-fn.rs @@ -0,0 +1,21 @@ +#![crate_type = "lib"] + +struct Bar; + +impl Bar { + #[no_mangle] + fn bar() -> u8 { + 2 + } +} + +trait Foo { + fn baz() -> u8; +} + +impl Foo for Bar { + #[no_mangle] + fn baz() -> u8 { + 3 + } +} diff --git a/src/test/ui/extern/auxiliary/reexport-should-still-link.rs b/src/test/ui/extern/auxiliary/reexport-should-still-link.rs new file mode 100644 index 000000000..237ea8dfc --- /dev/null +++ b/src/test/ui/extern/auxiliary/reexport-should-still-link.rs @@ -0,0 +1,5 @@ +pub use foo::bar; + +mod foo { + pub fn bar() {} +} |