Skip to content

Commit abbe0d0

Browse files
authored
Rollup merge of #124073 - saethlin:rust-get-test-int, r=wesleywiser
Remove libc from rust_get_test_int uses `rust_test_helpers.c` has a few unfortunate signatures which have made some of our UI tests _technically_ need the `libc` crate. This is my attempt to evict the need of `libc` for `rust_get_test_int`. I've deleted `tests/ui/abi/foreign/foreign-no-abi.rs` because the test was originally written to check that `native mod` will compile without an ABI specifier. `native mod` was removed years before 1.0 and the test hasn't checked for anything for a long time.
2 parents 116c0f7 + 6298d8f commit abbe0d0

File tree

8 files changed

+18
-54
lines changed

8 files changed

+18
-54
lines changed

tests/ui/abi/anon-extern-mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//@ run-pass
22
//@ pretty-expanded FIXME #23616
33

4-
#![feature(rustc_private)]
5-
6-
extern crate libc;
7-
84
#[link(name = "rust_test_helpers", kind = "static")]
95
extern "C" {
10-
fn rust_get_test_int() -> libc::intptr_t;
6+
fn rust_get_test_int() -> isize;
117
}
128

139
pub fn main() {

tests/ui/abi/c-stack-as-value.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
//@ run-pass
22
//@ pretty-expanded FIXME #23616
33

4-
#![feature(rustc_private)]
5-
64
mod rustrt {
7-
extern crate libc;
8-
95
#[link(name = "rust_test_helpers", kind = "static")]
106
extern "C" {
11-
pub fn rust_get_test_int() -> libc::intptr_t;
7+
pub fn rust_get_test_int() -> isize;
128
}
139
}
1410

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#![crate_name = "anonexternmod"]
2-
#![feature(rustc_private)]
3-
4-
extern crate libc;
52

63
#[link(name = "rust_test_helpers", kind = "static")]
74
extern "C" {
8-
pub fn rust_get_test_int() -> libc::intptr_t;
5+
pub fn rust_get_test_int() -> isize;
96
}
+12-12
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
#![crate_name = "foreign_lib"]
2-
#![feature(rustc_private)]
32

43
pub mod rustrt {
5-
extern crate libc;
6-
74
#[link(name = "rust_test_helpers", kind = "static")]
85
extern "C" {
9-
pub fn rust_get_test_int() -> libc::intptr_t;
6+
pub fn rust_get_test_int() -> isize;
107
}
118
}
129

1310
pub mod rustrt2 {
14-
extern crate libc;
15-
1611
extern "C" {
17-
pub fn rust_get_test_int() -> libc::intptr_t;
12+
pub fn rust_get_test_int() -> isize;
1813
}
1914
}
2015

2116
pub mod rustrt3 {
22-
// Different type, but same ABI (on all supported platforms).
23-
// Ensures that we don't ICE or trigger LLVM asserts when
24-
// importing the same symbol under different types.
25-
// See https://github.com/rust-lang/rust/issues/32740.
17+
// The point of this test is to ensure that we don't ICE or trigger LLVM asserts when importing
18+
// the same symbol with different types. This is not really possible to test portably; there is
19+
// no different signature we can come up with that is different to LLVM but which for sure has
20+
// the same behavior on all platforms. The signed-ness of integers is ignored by LLVM as well
21+
// as pointee types. So the only ways to make our signatures differ are to use
22+
// differently-sized integers which is definitely an ABI mismatch, or to rely on pointers and
23+
// isize/usize having the same ABI, which is wrong on CHERI and probably other niche platforms.
24+
// If this test causes you trouble, please file an issue.
25+
// See https://github.com/rust-lang/rust/issues/32740 for the bug that prompted this test.
2626
extern "C" {
2727
pub fn rust_get_test_int() -> *const u8;
2828
}
@@ -32,6 +32,6 @@ pub fn local_uses() {
3232
unsafe {
3333
let x = rustrt::rust_get_test_int();
3434
assert_eq!(x, rustrt2::rust_get_test_int());
35-
assert_eq!(x as *const _, rustrt3::rust_get_test_int());
35+
assert_eq!(x as *const u8, rustrt3::rust_get_test_int());
3636
}
3737
}

tests/ui/abi/foreign/foreign-dupe.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
// Check that we can still call duplicated extern (imported) functions
55
// which were declared in another crate. See issues #32740 and #32783.
66

7-
87
extern crate foreign_lib;
98

109
pub fn main() {
1110
unsafe {
1211
let x = foreign_lib::rustrt::rust_get_test_int();
1312
assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int());
14-
assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int());
13+
assert_eq!(x as *const u8, foreign_lib::rustrt3::rust_get_test_int());
1514
}
1615
}

tests/ui/abi/foreign/foreign-no-abi.rs

-21
This file was deleted.

tests/ui/attributes/item-attributes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ mod test_foreign_items {
148148
#![rustc_dummy]
149149

150150
#[rustc_dummy]
151-
fn rust_get_test_int() -> u32;
151+
fn rust_get_test_int() -> isize;
152152
}
153153
}
154154
}

tests/ui/extern/issue-1251.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
#![allow(unused_attributes)]
33
#![allow(dead_code)]
44
//@ pretty-expanded FIXME #23616
5-
#![feature(rustc_private)]
65

76
mod rustrt {
8-
extern crate libc;
9-
107
extern "C" {
11-
pub fn rust_get_test_int() -> libc::intptr_t;
8+
pub fn rust_get_test_int() -> isize;
129
}
1310
}
1411

0 commit comments

Comments
 (0)