Skip to content

Commit e8ac524

Browse files
committed
Auto merge of #1871 - hyd-dev:no-mangle-method, r=RalfJung
Update tests for `#[no_mangle]` on associated functions rust-lang/rust#86492 has landed: - The code in #1837 starts to work (even without `AssocFn::foo();` at line 12) in Miri. - `pub` is not necessary for `#[no_mangle]` associated functions in `test-cargo-miri/exported-symbol-dep/src/lib.rs` anymore. Closes #1837.
2 parents 13fae3d + 838ed1d commit e8ac524

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

test-cargo-miri/exported-symbol-dep/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ fn exported_symbol() -> i32 {
33
123456
44
}
55

6-
pub struct AssocFn;
6+
struct AssocFn;
77

88
impl AssocFn {
99
#[no_mangle]
10-
pub fn assoc_fn_as_exported_symbol() -> i32 {
10+
fn assoc_fn_as_exported_symbol() -> i32 {
1111
-123456
1212
}
1313
}

tests/run-pass/function_calls/exported_symbol.rs

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ fn baz() -> i32 {
1515
-3
1616
}
1717

18+
struct AssocFn;
19+
20+
impl AssocFn {
21+
#[no_mangle]
22+
fn qux() -> i32 {
23+
-4
24+
}
25+
}
26+
27+
1828
fn main() {
1929
// Repeat calls to make sure the `Instance` cache is not broken.
2030
for _ in 0..3 {
@@ -32,10 +42,12 @@ fn main() {
3242
extern "Rust" {
3343
fn bar() -> i32;
3444
fn baz() -> i32;
45+
fn qux() -> i32;
3546
}
3647

3748
assert_eq!(unsafe { bar() }, -2);
3849
assert_eq!(unsafe { baz() }, -3);
50+
assert_eq!(unsafe { qux() }, -4);
3951

4052
#[allow(clashing_extern_declarations)]
4153
{
@@ -53,6 +65,7 @@ fn main() {
5365
extern "C" {
5466
fn bar() -> i32;
5567
fn baz() -> i32;
68+
fn qux() -> i32;
5669
}
5770

5871
unsafe {
@@ -61,6 +74,7 @@ fn main() {
6174
};
6275
assert_eq!(transmute(bar)(), -2);
6376
assert_eq!(transmute(baz)(), -3);
77+
assert_eq!(transmute(qux)(), -4);
6478
}
6579
}
6680
}

0 commit comments

Comments
 (0)