Skip to content

Commit 2088d99

Browse files
Rollup merge of rust-lang#137145 - RalfJung:minicore, r=jieyouxu
use add-core-stubs / minicore for a few more tests See rust-lang#131485 for context. These are some tests I worked on in the past so I figured I'd see if `minicore` works for them. :)
2 parents 98f4bcc + 4a4207a commit 2088d99

21 files changed

+154
-164
lines changed

tests/assembly/asm/aarch64-types.rs

-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#![crate_type = "rlib"]
1212
#![no_core]
1313
#![allow(asm_sub_register, non_camel_case_types)]
14-
// FIXME(f16_f128): Only needed for FIXME in check! and check_reg!
15-
#![feature(auto_traits, lang_items)]
1614

1715
extern crate minicore;
1816
use minicore::*;
@@ -63,12 +61,6 @@ impl Copy for f16x8 {}
6361
impl Copy for f32x4 {}
6462
impl Copy for f64x2 {}
6563

66-
// FIXME(f16_f128): Only needed for FIXME in check! and check_reg!
67-
#[lang = "freeze"]
68-
unsafe auto trait Freeze {}
69-
#[lang = "unpin"]
70-
auto trait Unpin {}
71-
7264
extern "C" {
7365
fn extern_func();
7466
static extern_static: u8;

tests/auxiliary/minicore.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,20 @@
1414
//! <https://github.com/rust-lang/rust/blob/c0b5cc9003f6464c11ae1c0662c6a7e06f6f5cab/compiler/rustc_codegen_cranelift/example/mini_core.rs>.
1515
// ignore-tidy-linelength
1616

17-
#![feature(no_core, lang_items, rustc_attrs, decl_macro, naked_functions, f16, f128)]
17+
#![feature(
18+
no_core,
19+
lang_items,
20+
auto_traits,
21+
freeze_impls,
22+
negative_impls,
23+
rustc_attrs,
24+
decl_macro,
25+
naked_functions,
26+
f16,
27+
f128,
28+
asm_experimental_arch
29+
)]
1830
#![allow(unused, improper_ctypes_definitions, internal_features)]
19-
#![feature(asm_experimental_arch)]
2031
#![no_std]
2132
#![no_core]
2233

@@ -42,6 +53,12 @@ pub trait Copy: Sized {}
4253
#[lang = "bikeshed_guaranteed_no_drop"]
4354
pub trait BikeshedGuaranteedNoDrop {}
4455

56+
#[lang = "freeze"]
57+
pub unsafe auto trait Freeze {}
58+
59+
#[lang = "unpin"]
60+
pub auto trait Unpin {}
61+
4562
impl_marker_trait!(
4663
Copy => [
4764
bool, char,
@@ -83,6 +100,7 @@ impl<T: Copy + ?Sized> Copy for ManuallyDrop<T> {}
83100
pub struct UnsafeCell<T: ?Sized> {
84101
value: T,
85102
}
103+
impl<T: ?Sized> !Freeze for UnsafeCell<T> {}
86104

87105
#[rustc_builtin_macro]
88106
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {

tests/codegen/abi-win64-zst.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags: -Z merge-functions=disabled
2+
//@ add-core-stubs
23

34
//@ revisions: windows-gnu
45
//@[windows-gnu] compile-flags: --target x86_64-pc-windows-gnu
@@ -13,12 +14,12 @@
1314
//@[linux] compile-flags: --target x86_64-unknown-linux-gnu
1415
//@[linux] needs-llvm-components: x86
1516

16-
#![feature(no_core, lang_items, rustc_attrs, abi_vectorcall)]
17+
#![feature(no_core, rustc_attrs, abi_vectorcall)]
1718
#![no_core]
1819
#![crate_type = "lib"]
1920

20-
#[lang = "sized"]
21-
trait Sized {}
21+
extern crate minicore;
22+
use minicore::*;
2223

2324
// Make sure the argument is always passed when explicitly requesting a Windows ABI.
2425
// Our goal here is to match clang: <https://clang.godbolt.org/z/Wr4jMWq3P>.

tests/codegen/align-byval-alignment-mismatch.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ignore-tidy-linelength
2+
//@ add-core-stubs
23
//@ revisions:i686-linux x86_64-linux
34

45
//@[i686-linux] compile-flags: --target i686-unknown-linux-gnu -C panic=abort
@@ -16,18 +17,14 @@
1617
// on i686-unknown-linux-gnu, since the alignment needs to be increased, and should codegen
1718
// to a direct call on x86_64-unknown-linux-gnu, where byval alignment matches Rust alignment.
1819

19-
#![feature(no_core, lang_items)]
20+
#![feature(no_core)]
2021
#![crate_type = "lib"]
2122
#![no_std]
2223
#![no_core]
2324
#![allow(non_camel_case_types)]
2425

25-
#[lang = "sized"]
26-
trait Sized {}
27-
#[lang = "freeze"]
28-
trait Freeze {}
29-
#[lang = "copy"]
30-
trait Copy {}
26+
extern crate minicore;
27+
use minicore::*;
3128

3229
// This type has align 1 in Rust, but as a byval argument on i686-linux, it will have align 4.
3330
#[repr(C)]

tests/codegen/align-byval-vector.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ add-core-stubs
12
//@ revisions:x86-linux x86-darwin
23

34
//@[x86-linux] compile-flags: --target i686-unknown-linux-gnu
@@ -7,18 +8,14 @@
78

89
// Tests that aggregates containing vector types get their alignment increased to 16 on Darwin.
910

10-
#![feature(no_core, lang_items, repr_simd, simd_ffi)]
11+
#![feature(no_core, repr_simd, simd_ffi)]
1112
#![crate_type = "lib"]
1213
#![no_std]
1314
#![no_core]
1415
#![allow(non_camel_case_types)]
1516

16-
#[lang = "sized"]
17-
trait Sized {}
18-
#[lang = "freeze"]
19-
trait Freeze {}
20-
#[lang = "copy"]
21-
trait Copy {}
17+
extern crate minicore;
18+
use minicore::*;
2219

2320
#[repr(simd)]
2421
pub struct i32x4([i32; 4]);

tests/codegen/align-byval.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ignore-tidy-linelength
2+
//@ add-core-stubs
23
//@ revisions:m68k x86_64-linux x86_64-windows i686-linux i686-windows
34

45
//@[m68k] compile-flags: --target m68k-unknown-linux-gnu
@@ -16,20 +17,13 @@
1617
// The only targets that use `byval` are m68k, x86-64, and x86.
1718
// Note also that Windows mandates a by-ref ABI here, so it does not use byval.
1819

19-
#![feature(no_core, lang_items)]
20+
#![feature(no_core)]
2021
#![crate_type = "lib"]
2122
#![no_std]
2223
#![no_core]
2324

24-
#[lang = "sized"]
25-
trait Sized {}
26-
#[lang = "freeze"]
27-
trait Freeze {}
28-
#[lang = "copy"]
29-
trait Copy {}
30-
31-
impl Copy for i32 {}
32-
impl Copy for i64 {}
25+
extern crate minicore;
26+
use minicore::*;
3327

3428
// This struct can be represented as a pair, so it exercises the OperandValue::Pair
3529
// codepath in `codegen_argument`.

tests/ui/abi/c-zst.aarch64-darwin.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
6060
conv: C,
6161
can_unwind: false,
6262
}
63-
--> $DIR/c-zst.rs:63:1
63+
--> $DIR/c-zst.rs:64:1
6464
|
6565
LL | extern "C" fn pass_zst(_: ()) {}
6666
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/abi/c-zst.powerpc-linux.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
7171
conv: C,
7272
can_unwind: false,
7373
}
74-
--> $DIR/c-zst.rs:63:1
74+
--> $DIR/c-zst.rs:64:1
7575
|
7676
LL | extern "C" fn pass_zst(_: ()) {}
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/abi/c-zst.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ add-core-stubs
12
//@ normalize-stderr: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
23
/*!
34
C doesn't have zero-sized types... except it does.
@@ -52,12 +53,12 @@ extern "C" fn(i32, (), i32);
5253
//@[x86_64-pc-windows-gnu] needs-llvm-components: x86
5354

5455

55-
#![feature(lang_items, no_core, rustc_attrs)]
56+
#![feature(no_core, rustc_attrs)]
5657
#![no_core]
5758
#![crate_type = "lib"]
5859

59-
#[lang = "sized"]
60-
trait Sized {}
60+
extern crate minicore;
61+
use minicore::*;
6162

6263
#[rustc_abi(debug)]
6364
extern "C" fn pass_zst(_: ()) {} //~ ERROR: fn_abi

tests/ui/abi/c-zst.s390x-linux.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
7171
conv: C,
7272
can_unwind: false,
7373
}
74-
--> $DIR/c-zst.rs:63:1
74+
--> $DIR/c-zst.rs:64:1
7575
|
7676
LL | extern "C" fn pass_zst(_: ()) {}
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/abi/c-zst.sparc64-linux.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
7171
conv: C,
7272
can_unwind: false,
7373
}
74-
--> $DIR/c-zst.rs:63:1
74+
--> $DIR/c-zst.rs:64:1
7575
|
7676
LL | extern "C" fn pass_zst(_: ()) {}
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/abi/c-zst.x86_64-linux.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
6060
conv: C,
6161
can_unwind: false,
6262
}
63-
--> $DIR/c-zst.rs:63:1
63+
--> $DIR/c-zst.rs:64:1
6464
|
6565
LL | extern "C" fn pass_zst(_: ()) {}
6666
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
7171
conv: C,
7272
can_unwind: false,
7373
}
74-
--> $DIR/c-zst.rs:63:1
74+
--> $DIR/c-zst.rs:64:1
7575
|
7676
LL | extern "C" fn pass_zst(_: ()) {}
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/simd-abi-checks-empty-list.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
//@ add-core-stubs
12
//@ needs-llvm-components: sparc
23
//@ compile-flags: --target=sparc-unknown-none-elf --crate-type=rlib
34
//@ build-pass
45
//@ ignore-pass (test emits codegen-time warnings)
56
#![no_core]
6-
#![feature(no_core, lang_items, repr_simd)]
7+
#![feature(no_core, repr_simd)]
78
#![allow(improper_ctypes_definitions)]
8-
#[lang = "sized"]
9-
trait Sized {}
109

11-
#[lang = "copy"]
12-
trait Copy {}
10+
extern crate minicore;
11+
use minicore::*;
1312

1413
#[repr(simd)]
1514
pub struct SimdVec([i32; 4]);

tests/ui/simd-abi-checks-empty-list.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI
2-
--> $DIR/simd-abi-checks-empty-list.rs:17:1
2+
--> $DIR/simd-abi-checks-empty-list.rs:16:1
33
|
44
LL | pub extern "C" fn pass_by_vec(_: SimdVec) {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
@@ -12,7 +12,7 @@ warning: 1 warning emitted
1212

1313
Future incompatibility report: Future breakage diagnostic:
1414
warning: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI
15-
--> $DIR/simd-abi-checks-empty-list.rs:17:1
15+
--> $DIR/simd-abi-checks-empty-list.rs:16:1
1616
|
1717
LL | pub extern "C" fn pass_by_vec(_: SimdVec) {}
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here

tests/ui/simd-abi-checks-s390x.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ add-core-stubs
12
//@ revisions: z10 z13_no_vector z13_soft_float
23
//@ build-fail
34
//@[z10] compile-flags: --target s390x-unknown-linux-gnu
@@ -8,20 +9,14 @@
89
//@[z13_soft_float] compile-flags: --target s390x-unknown-linux-gnu -C target-cpu=z13 -C target-feature=-vector,+soft-float
910
//@[z13_soft_float] needs-llvm-components: systemz
1011

11-
#![feature(no_core, lang_items, repr_simd, s390x_target_feature)]
12+
#![feature(no_core, repr_simd, s390x_target_feature)]
1213
#![no_core]
1314
#![crate_type = "lib"]
1415
#![allow(non_camel_case_types, improper_ctypes_definitions)]
1516
#![deny(abi_unsupported_vector_types)]
1617

17-
#[lang = "sized"]
18-
pub trait Sized {}
19-
#[lang = "copy"]
20-
pub trait Copy {}
21-
#[lang = "freeze"]
22-
pub trait Freeze {}
23-
24-
impl<T: Copy, const N: usize> Copy for [T; N] {}
18+
extern crate minicore;
19+
use minicore::*;
2520

2621
#[repr(simd)]
2722
pub struct i8x8([i8; 8]);
@@ -34,8 +29,6 @@ pub struct Wrapper<T>(T);
3429
#[repr(transparent)]
3530
pub struct TransparentWrapper<T>(T);
3631

37-
impl Copy for i8 {}
38-
impl Copy for i64 {}
3932
impl Copy for i8x8 {}
4033
impl Copy for i8x16 {}
4134
impl Copy for i8x32 {}

0 commit comments

Comments
 (0)