authorbors <bors@rust-lang.org> 2024-05-31 12:18:57 UTC
committerbors <bors@rust-lang.org> 2024-05-31 12:18:57 UTC
log2a2c29aafa50bf6fe53d66b32070eba59f860ac3
tree278b17527f858913de99475f1d9ecdc41d297f89
parent99cb42c29641aee2cce6521e07960d4de93205c8
parent0ea498aa9fc7ddf696d53fe961d30e63e4d38438

Auto merge of #125759 - nnethercote:format-some-tests, r=GuillaumeGomez

Format some tests There are more directories under `tests/` still to do, but this is enough for one PR. r? `@GuillaumeGomez`

391 files changed, 2150 insertions(+), 2020 deletions(-)

rustfmt.toml+21-3
......@@ -10,9 +10,27 @@ ignore = [
1010 "/build-*/",
1111 "/vendor/",
1212
13 # Tests for now are not formatted, as they are sometimes pretty-printing constrained
14 # (and generally rustfmt can move around comments in UI-testing incompatible ways).
15 "/tests/",
13 # Some tests are not formatted, for multiple reasons:
14 # - some contain syntax errors that cause rustfmt to give an error
15 # - some UI tests are broken by different formatting
16 # - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
17 "/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
18 "/tests/crashes/", # Many tests contain syntax errors.
19 "/tests/debuginfo/", # Tests are somewhat sensitive to source code layout.
20 "/tests/incremental/", # Tests are somewhat sensitive to source code layout.
21 "/tests/mir-opt/",
22 "/tests/pretty/",
23 "/tests/run-make/translation/test.rs", # Contains syntax errors.
24 "/tests/run-make-fulldeps/",
25 "/tests/run-pass-valgrind/",
26 "/tests/rustdoc/",
27 "/tests/rustdoc-gui/",
28 "/tests/rustdoc-js/",
29 "/tests/rustdoc-json/",
30 "/tests/rustdoc-js-std/",
31 "/tests/rustdoc-ui/",
32 "/tests/ui/",
33 "/tests/ui-fulldeps/",
1634
1735 # Do not format submodules.
1836 # FIXME: sync submodule list with tidy/bootstrap/etc
tests/assembly/align_offset.rs+1-1
......@@ -1,7 +1,7 @@
11//@ assembly-output: emit-asm
22//@ compile-flags: -Copt-level=1
33//@ only-x86_64
4#![crate_type="rlib"]
4#![crate_type = "rlib"]
55
66// CHECK-LABEL: align_offset_byte_ptr
77// CHECK: leaq 31
tests/assembly/asm/inline-asm-avx.rs+1-1
......@@ -5,8 +5,8 @@
55
66#![feature(portable_simd)]
77
8use std::simd::Simd;
98use std::arch::asm;
9use std::simd::Simd;
1010
1111#[target_feature(enable = "avx")]
1212#[no_mangle]
tests/assembly/closure-inherit-target-feature.rs+6-7
......@@ -18,7 +18,8 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 {
1818 // CHECK: {{call .*_mm_blend_ps.*}}
1919 // CHECK-NOT: blendps
2020 // CHECK: ret
21 #[inline(never)] |x, y| _mm_blend_ps(x, y, 0b0101)
21 #[inline(never)]
22 |x, y| _mm_blend_ps(x, y, 0b0101)
2223 };
2324 f(x, y)
2425}
......@@ -33,9 +34,8 @@ pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 {
3334 // CHECK: blendps
3435 // CHECK-NOT: _mm_blend_ps
3536 // CHECK: ret
36 #[inline(never)] |x, y| unsafe {
37 _mm_blend_ps(x, y, 0b0101)
38 }
37 #[inline(never)]
38 |x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
3939 };
4040 f(x, y)
4141}
......@@ -52,9 +52,8 @@ pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 {
5252 // CHECK-NOT: _mm_blend_ps
5353 // CHECK: ret
5454 let f = {
55 #[inline] |x, y| unsafe {
56 _mm_blend_ps(x, y, 0b0101)
57 }
55 #[inline]
56 |x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
5857 };
5958 f(x, y)
6059}
tests/assembly/is_aligned.rs+2-5
......@@ -4,8 +4,7 @@
44//@ revisions: opt-speed opt-size
55//@ [opt-speed] compile-flags: -Copt-level=2 -Cdebug-assertions=no
66//@ [opt-size] compile-flags: -Copt-level=s -Cdebug-assertions=no
7#![crate_type="rlib"]
8
7#![crate_type = "rlib"]
98#![feature(core_intrinsics)]
109#![feature(pointer_is_aligned_to)]
1110
......@@ -16,9 +15,7 @@
1615// CHECK: retq
1716#[no_mangle]
1817pub unsafe fn is_aligned_to_unchecked(ptr: *const u8, align: usize) -> bool {
19 unsafe {
20 std::intrinsics::assume(align.is_power_of_two())
21 }
18 unsafe { std::intrinsics::assume(align.is_power_of_two()) }
2219 ptr.is_aligned_to(align)
2320}
2421
tests/assembly/pic-relocation-model.rs+6-9
......@@ -3,10 +3,9 @@
33//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic
44//@ [x64] needs-llvm-components: x86
55
6
76#![feature(no_core, lang_items)]
87#![no_core]
9#![crate_type="rlib"]
8#![crate_type = "rlib"]
109
1110#[lang = "sized"]
1211trait Sized {}
......@@ -17,9 +16,7 @@ trait Copy {}
1716// CHECK: {{(jmpq|callq)}} *other_fn@GOTPCREL(%rip)
1817#[no_mangle]
1918pub fn call_other_fn() -> u8 {
20 unsafe {
21 other_fn()
22 }
19 unsafe { other_fn() }
2320}
2421
2522// CHECK-LABEL: other_fn:
......@@ -27,9 +24,9 @@ pub fn call_other_fn() -> u8 {
2724#[no_mangle]
2825#[inline(never)]
2926pub fn other_fn() -> u8 {
30 unsafe {
31 foreign_fn()
32 }
27 unsafe { foreign_fn() }
3328}
3429
35extern "C" {fn foreign_fn() -> u8;}
30extern "C" {
31 fn foreign_fn() -> u8;
32}
tests/assembly/pie-relocation-model.rs+6-9
......@@ -3,10 +3,9 @@
33//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie
44//@ [x64] needs-llvm-components: x86
55
6
76#![feature(no_core, lang_items)]
87#![no_core]
9#![crate_type="rlib"]
8#![crate_type = "rlib"]
109
1110#[lang = "sized"]
1211trait Sized {}
......@@ -18,9 +17,7 @@ trait Copy {}
1817// CHECK: {{(jmp|callq)}} other_fn
1918#[no_mangle]
2019pub fn call_other_fn() -> u8 {
21 unsafe {
22 other_fn()
23 }
20 unsafe { other_fn() }
2421}
2522
2623// CHECK-LABEL: other_fn:
......@@ -30,9 +27,9 @@ pub fn call_other_fn() -> u8 {
3027#[no_mangle]
3128#[inline(never)]
3229pub fn other_fn() -> u8 {
33 unsafe {
34 foreign_fn()
35 }
30 unsafe { foreign_fn() }
3631}
3732
38extern "C" {fn foreign_fn() -> u8;}
33extern "C" {
34 fn foreign_fn() -> u8;
35}
tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs+1-10
......@@ -10,12 +10,9 @@
1010//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
1111
1212#![crate_type = "lib"]
13
1413#![allow(incomplete_features)]
15
1614#![feature(unsized_locals, unsized_fn_params)]
1715
18
1916// CHECK-LABEL: emptyfn:
2017#[no_mangle]
2118pub fn emptyfn() {
......@@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
139136 // missing-NOT: __security_check_cookie
140137}
141138
142
143139// CHECK-LABEL: local_string_addr_taken
144140#[no_mangle]
145141pub fn local_string_addr_taken(f: fn(&String)) {
......@@ -205,7 +201,7 @@ pub struct Gigastruct {
205201 not: u64,
206202 have: u64,
207203 array: u64,
208 members: u64
204 members: u64,
209205}
210206
211207// CHECK-LABEL: local_large_var_moved
......@@ -259,7 +255,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
259255 // EOF
260256 // ```
261257
262
263258 // all: __security_check_cookie
264259 // strong: __security_check_cookie
265260 // basic: __security_check_cookie
......@@ -267,7 +262,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
267262 // missing-NOT: __security_check_cookie
268263}
269264
270
271265extern "C" {
272266 // A call to an external `alloca` function is *not* recognized as an
273267 // `alloca(3)` operation. This function is a compiler built-in, as the
......@@ -320,7 +314,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
320314 // missing-NOT: __security_check_cookie
321315}
322316
323
324317// CHECK-LABEL: alloca_dynamic_arg
325318#[no_mangle]
326319pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
......@@ -340,7 +333,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
340333// this is support for the "unsized locals" unstable feature:
341334// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
342335
343
344336// CHECK-LABEL: unsized_fn_param
345337#[no_mangle]
346338pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
......@@ -354,7 +346,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
354346 // alloca, and is therefore not protected by the `strong` or `basic`
355347 // heuristics.
356348
357
358349 // We should have a __security_check_cookie call in `all` and `strong` modes but
359350 // LLVM does not support generating stack protectors in functions with funclet
360351 // based EH personalities.
tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs+1-10
......@@ -10,12 +10,9 @@
1010//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
1111
1212#![crate_type = "lib"]
13
1413#![allow(incomplete_features)]
15
1614#![feature(unsized_locals, unsized_fn_params)]
1715
18
1916// CHECK-LABEL: emptyfn:
2017#[no_mangle]
2118pub fn emptyfn() {
......@@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
139136 // missing-NOT: __security_check_cookie
140137}
141138
142
143139// CHECK-LABEL: local_string_addr_taken
144140#[no_mangle]
145141pub fn local_string_addr_taken(f: fn(&String)) {
......@@ -213,7 +209,7 @@ pub struct Gigastruct {
213209 not: u64,
214210 have: u64,
215211 array: u64,
216 members: u64
212 members: u64,
217213}
218214
219215// CHECK-LABEL: local_large_var_moved
......@@ -267,7 +263,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
267263 // EOF
268264 // ```
269265
270
271266 // all: __security_check_cookie
272267 // strong: __security_check_cookie
273268 // basic: __security_check_cookie
......@@ -275,7 +270,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
275270 // missing-NOT: __security_check_cookie
276271}
277272
278
279273extern "C" {
280274 // A call to an external `alloca` function is *not* recognized as an
281275 // `alloca(3)` operation. This function is a compiler built-in, as the
......@@ -328,7 +322,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
328322 // missing-NOT: __security_check_cookie
329323}
330324
331
332325// CHECK-LABEL: alloca_dynamic_arg
333326#[no_mangle]
334327pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
......@@ -348,7 +341,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
348341// this is support for the "unsized locals" unstable feature:
349342// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
350343
351
352344// CHECK-LABEL: unsized_fn_param
353345#[no_mangle]
354346pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
......@@ -362,7 +354,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
362354 // alloca, and is therefore not protected by the `strong` or `basic`
363355 // heuristics.
364356
365
366357 // We should have a __security_check_cookie call in `all` and `strong` modes but
367358 // LLVM does not support generating stack protectors in functions with funclet
368359 // based EH personalities.
tests/assembly/stack-protector/stack-protector-heuristics-effect.rs+1-6
......@@ -143,7 +143,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
143143 // missing-NOT: __stack_chk_fail
144144}
145145
146
147146// CHECK-LABEL: local_string_addr_taken
148147#[no_mangle]
149148pub fn local_string_addr_taken(f: fn(&String)) {
......@@ -194,7 +193,7 @@ pub struct Gigastruct {
194193 not: u64,
195194 have: u64,
196195 array: u64,
197 members: u64
196 members: u64,
198197}
199198
200199// CHECK-LABEL: local_large_var_moved
......@@ -255,7 +254,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
255254 // missing-NOT: __stack_chk_fail
256255}
257256
258
259257extern "C" {
260258 // A call to an external `alloca` function is *not* recognized as an
261259 // `alloca(3)` operation. This function is a compiler built-in, as the
......@@ -308,7 +306,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
308306 // missing-NOT: __stack_chk_fail
309307}
310308
311
312309// CHECK-LABEL: alloca_dynamic_arg
313310#[no_mangle]
314311pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
......@@ -328,7 +325,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
328325// this is support for the "unsized locals" unstable feature:
329326// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
330327
331
332328// CHECK-LABEL: unsized_fn_param
333329#[no_mangle]
334330pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
......@@ -342,7 +338,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
342338 // alloca, and is therefore not protected by the `strong` or `basic`
343339 // heuristics.
344340
345
346341 // all: __stack_chk_fail
347342 // strong-NOT: __stack_chk_fail
348343 // basic-NOT: __stack_chk_fail
tests/assembly/static-relocation-model.rs+7-13
......@@ -9,15 +9,15 @@
99
1010#![feature(no_core, lang_items)]
1111#![no_core]
12#![crate_type="rlib"]
12#![crate_type = "rlib"]
1313
14#[lang="sized"]
14#[lang = "sized"]
1515trait Sized {}
1616
17#[lang="copy"]
17#[lang = "copy"]
1818trait Copy {}
1919
20#[lang="sync"]
20#[lang = "sync"]
2121trait Sync {}
2222
2323#[lang = "drop_in_place"]
......@@ -42,9 +42,7 @@ extern "C" {
4242// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG]], :lo12:chaenomeles]
4343#[no_mangle]
4444pub fn banana() -> u8 {
45 unsafe {
46 *(chaenomeles as *mut u8)
47 }
45 unsafe { *(chaenomeles as *mut u8) }
4846}
4947
5048// CHECK-LABEL: peach:
......@@ -53,9 +51,7 @@ pub fn banana() -> u8 {
5351// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:banana]
5452#[no_mangle]
5553pub fn peach() -> u8 {
56 unsafe {
57 *(banana as *mut u8)
58 }
54 unsafe { *(banana as *mut u8) }
5955}
6056
6157// CHECK-LABEL: mango:
......@@ -65,9 +61,7 @@ pub fn peach() -> u8 {
6561// A64-NEXT: ldr {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:EXOCHORDA]
6662#[no_mangle]
6763pub fn mango() -> u8 {
68 unsafe {
69 *EXOCHORDA
70 }
64 unsafe { *EXOCHORDA }
7165}
7266
7367// CHECK-LABEL: orange:
tests/assembly/thin-lto.rs+1-2
......@@ -4,5 +4,4 @@
44
55// CHECK: main
66
7pub fn main() {
8}
7pub fn main() {}
tests/assembly/wasm_exceptions.rs+17-9
......@@ -8,7 +8,7 @@
88#![feature(core_intrinsics)]
99#![feature(rustc_attrs)]
1010
11extern {
11extern "C" {
1212 fn may_panic();
1313
1414 #[rustc_nounwind]
......@@ -19,7 +19,9 @@ struct LogOnDrop;
1919
2020impl Drop for LogOnDrop {
2121 fn drop(&mut self) {
22 unsafe { log_number(0); }
22 unsafe {
23 log_number(0);
24 }
2325 }
2426}
2527
......@@ -27,7 +29,9 @@ impl Drop for LogOnDrop {
2729#[no_mangle]
2830pub fn test_cleanup() {
2931 let _log_on_drop = LogOnDrop;
30 unsafe { may_panic(); }
32 unsafe {
33 may_panic();
34 }
3135
3236 // CHECK-NOT: call
3337 // CHECK: try
......@@ -41,12 +45,16 @@ pub fn test_cleanup() {
4145#[no_mangle]
4246pub fn test_rtry() {
4347 unsafe {
44 core::intrinsics::catch_unwind(|_| {
45 may_panic();
46 }, core::ptr::null_mut(), |data, exception| {
47 log_number(data as usize);
48 log_number(exception as usize);
49 });
48 core::intrinsics::catch_unwind(
49 |_| {
50 may_panic();
51 },
52 core::ptr::null_mut(),
53 |data, exception| {
54 log_number(data as usize);
55 log_number(exception as usize);
56 },
57 );
5058 }
5159
5260 // CHECK-NOT: call
tests/assembly/x86_64-fortanix-unknown-sgx-lvi-generic-load.rs+1-1
......@@ -5,7 +5,7 @@
55//@ only-x86_64-fortanix-unknown-sgx
66
77#[no_mangle]
8pub extern fn plus_one(r: &mut u64) {
8pub extern "C" fn plus_one(r: &mut u64) {
99 *r = *r + 1;
1010}
1111
tests/assembly/x86_64-fortanix-unknown-sgx-lvi-generic-ret.rs+1-1
......@@ -5,7 +5,7 @@
55//@ only-x86_64-fortanix-unknown-sgx
66
77#[no_mangle]
8pub extern fn myret() {}
8pub extern "C" fn myret() {}
99// CHECK: myret:
1010// CHECK: popq [[REGISTER:%[a-z]+]]
1111// CHECK-NEXT: lfence
tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs+28-10
......@@ -2,25 +2,43 @@
22
33#![crate_type = "lib"]
44
5pub trait Trait : Sized {
5pub trait Trait: Sized {
66 fn without_self() -> u32;
7 fn without_self_default() -> u32 { 0 }
7 fn without_self_default() -> u32 {
8 0
9 }
810
9 fn with_default_impl(self) -> Self { self }
10 fn with_default_impl_generic<T>(self, x: T) -> (Self, T) { (self, x) }
11 fn with_default_impl(self) -> Self {
12 self
13 }
14 fn with_default_impl_generic<T>(self, x: T) -> (Self, T) {
15 (self, x)
16 }
1117
1218 fn without_default_impl(x: u32) -> (Self, u32);
1319 fn without_default_impl_generic<T>(x: T) -> (Self, T);
1420}
1521
1622impl Trait for char {
17 fn without_self() -> u32 { 2 }
18 fn without_default_impl(x: u32) -> (Self, u32) { ('c', x) }
19 fn without_default_impl_generic<T>(x: T) -> (Self, T) { ('c', x) }
23 fn without_self() -> u32 {
24 2
25 }
26 fn without_default_impl(x: u32) -> (Self, u32) {
27 ('c', x)
28 }
29 fn without_default_impl_generic<T>(x: T) -> (Self, T) {
30 ('c', x)
31 }
2032}
2133
2234impl Trait for u32 {
23 fn without_self() -> u32 { 1 }
24 fn without_default_impl(x: u32) -> (Self, u32) { (0, x) }
25 fn without_default_impl_generic<T>(x: T) -> (Self, T) { (0, x) }
35 fn without_self() -> u32 {
36 1
37 }
38 fn without_default_impl(x: u32) -> (Self, u32) {
39 (0, x)
40 }
41 fn without_default_impl_generic<T>(x: T) -> (Self, T) {
42 (0, x)
43 }
2644}
tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs+3-6
......@@ -2,22 +2,19 @@
22
33#[inline]
44pub fn inlined_fn(x: i32, y: i32) -> i32 {
5
6 let closure = |a, b| { a + b };
5 let closure = |a, b| a + b;
76
87 closure(x, y)
98}
109
1110pub fn inlined_fn_generic<T>(x: i32, y: i32, z: T) -> (i32, T) {
12
13 let closure = |a, b| { a + b };
11 let closure = |a, b| a + b;
1412
1513 (closure(x, y), z)
1614}
1715
1816pub fn non_inlined_fn(x: i32, y: i32) -> i32 {
19
20 let closure = |a, b| { a + b };
17 let closure = |a, b| a + b;
2118
2219 closure(x, y)
2320}
tests/codegen-units/item-collection/cross-crate-closures.rs-1
......@@ -14,7 +14,6 @@ extern crate cgu_extern_closures;
1414//~ MONO_ITEM fn cross_crate_closures::start[0]
1515#[start]
1616fn start(_: isize, _: *const *const u8) -> isize {
17
1817 //~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]
1918 //~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]::{{closure}}[0]
2019 let _ = cgu_extern_closures::inlined_fn(1, 2);
tests/codegen-units/item-collection/cross-crate-trait-method.rs-2
......@@ -24,8 +24,6 @@ fn start(_: isize, _: *const *const u8) -> isize {
2424 //~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl
2525 let _ = Trait::with_default_impl('c');
2626
27
28
2927 //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<&str>
3028 let _ = Trait::with_default_impl_generic(0u32, "abc");
3129 //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<bool>
tests/codegen-units/item-collection/drop_in_place_intrinsic.rs-1
......@@ -15,7 +15,6 @@ impl Drop for StructWithDtor {
1515//~ MONO_ITEM fn start
1616#[start]
1717fn start(_: isize, _: *const *const u8) -> isize {
18
1918 //~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor; 2]> - shim(Some([StructWithDtor; 2])) @@ drop_in_place_intrinsic-cgu.0[Internal]
2019 let x = [StructWithDtor(0), StructWithDtor(1)];
2120
tests/codegen-units/item-collection/function-as-argument.rs-1
......@@ -16,7 +16,6 @@ fn take_fn_pointer<T1, T2>(f: fn(T1, T2), x: T1, y: T2) {
1616//~ MONO_ITEM fn start
1717#[start]
1818fn start(_: isize, _: *const *const u8) -> isize {
19
2019 //~ MONO_ITEM fn take_fn_once::<u32, &str, fn(u32, &str) {function::<u32, &str>}>
2120 //~ MONO_ITEM fn function::<u32, &str>
2221 //~ MONO_ITEM fn <fn(u32, &str) {function::<u32, &str>} as std::ops::FnOnce<(u32, &str)>>::call_once - shim(fn(u32, &str) {function::<u32, &str>})
tests/codegen-units/item-collection/generic-drop-glue.rs+6-7
......@@ -21,7 +21,7 @@ struct StructNoDrop<T1, T2> {
2121
2222enum EnumWithDrop<T1, T2> {
2323 A(T1),
24 B(T2)
24 B(T2),
2525}
2626
2727impl<T1, T2> Drop for EnumWithDrop<T1, T2> {
......@@ -30,10 +30,9 @@ impl<T1, T2> Drop for EnumWithDrop<T1, T2> {
3030
3131enum EnumNoDrop<T1, T2> {
3232 A(T1),
33 B(T2)
33 B(T2),
3434}
3535
36
3736struct NonGenericNoDrop(#[allow(dead_code)] i32);
3837
3938struct NonGenericWithDrop(#[allow(dead_code)] i32);
......@@ -67,24 +66,24 @@ fn start(_: isize, _: *const *const u8) -> isize {
6766 //~ MONO_ITEM fn <EnumWithDrop<i32, i64> as std::ops::Drop>::drop
6867 let _ = match EnumWithDrop::A::<i32, i64>(0) {
6968 EnumWithDrop::A(x) => x,
70 EnumWithDrop::B(x) => x as i32
69 EnumWithDrop::B(x) => x as i32,
7170 };
7271
7372 //~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop<f64, f32>> - shim(Some(EnumWithDrop<f64, f32>)) @@ generic_drop_glue-cgu.0[Internal]
7473 //~ MONO_ITEM fn <EnumWithDrop<f64, f32> as std::ops::Drop>::drop
7574 let _ = match EnumWithDrop::B::<f64, f32>(1.0) {
7675 EnumWithDrop::A(x) => x,
77 EnumWithDrop::B(x) => x as f64
76 EnumWithDrop::B(x) => x as f64,
7877 };
7978
8079 let _ = match EnumNoDrop::A::<i32, i64>(0) {
8180 EnumNoDrop::A(x) => x,
82 EnumNoDrop::B(x) => x as i32
81 EnumNoDrop::B(x) => x as i32,
8382 };
8483
8584 let _ = match EnumNoDrop::B::<f64, f32>(1.0) {
8685 EnumNoDrop::A(x) => x,
87 EnumNoDrop::B(x) => x as f64
86 EnumNoDrop::B(x) => x as f64,
8887 };
8988
9089 0
tests/codegen-units/item-collection/generic-impl.rs+5-8
......@@ -8,15 +8,13 @@ struct Struct<T> {
88 f: fn(x: T) -> T,
99}
1010
11fn id<T>(x: T) -> T { x }
11fn id<T>(x: T) -> T {
12 x
13}
1214
1315impl<T> Struct<T> {
14
1516 fn new(x: T) -> Struct<T> {
16 Struct {
17 x: x,
18 f: id
19 }
17 Struct { x: x, f: id }
2018 }
2119
2220 fn get<T2>(self, x: T2) -> (T, T2) {
......@@ -25,11 +23,10 @@ impl<T> Struct<T> {
2523}
2624
2725pub struct LifeTimeOnly<'a> {
28 _a: &'a u32
26 _a: &'a u32,
2927}
3028
3129impl<'a> LifeTimeOnly<'a> {
32
3330 //~ MONO_ITEM fn LifeTimeOnly::<'_>::foo
3431 pub fn foo(&self) {}
3532 //~ MONO_ITEM fn LifeTimeOnly::<'_>::bar
tests/codegen-units/item-collection/instantiation-through-vtable.rs+4-2
......@@ -10,11 +10,13 @@ trait Trait {
1010}
1111
1212struct Struct<T> {
13 _a: T
13 _a: T,
1414}
1515
1616impl<T> Trait for Struct<T> {
17 fn foo(&self) -> u32 { 0 }
17 fn foo(&self) -> u32 {
18 0
19 }
1820 fn bar(&self) {}
1921}
2022
tests/codegen-units/item-collection/non-generic-drop-glue.rs+6-6
......@@ -7,7 +7,7 @@
77
88//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal]
99struct StructWithDrop {
10 x: i32
10 x: i32,
1111}
1212
1313impl Drop for StructWithDrop {
......@@ -16,12 +16,12 @@ impl Drop for StructWithDrop {
1616}
1717
1818struct StructNoDrop {
19 x: i32
19 x: i32,
2020}
2121
2222//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal]
2323enum EnumWithDrop {
24 A(i32)
24 A(i32),
2525}
2626
2727impl Drop for EnumWithDrop {
......@@ -30,7 +30,7 @@ impl Drop for EnumWithDrop {
3030}
3131
3232enum EnumNoDrop {
33 A(i32)
33 A(i32),
3434}
3535
3636//~ MONO_ITEM fn start
......@@ -39,10 +39,10 @@ fn start(_: isize, _: *const *const u8) -> isize {
3939 let _ = StructWithDrop { x: 0 }.x;
4040 let _ = StructNoDrop { x: 0 }.x;
4141 let _ = match EnumWithDrop::A(0) {
42 EnumWithDrop::A(x) => x
42 EnumWithDrop::A(x) => x,
4343 };
4444 let _ = match EnumNoDrop::A(0) {
45 EnumNoDrop::A(x) => x
45 EnumNoDrop::A(x) => x,
4646 };
4747
4848 0
tests/codegen-units/item-collection/non-generic-functions.rs+3-1
......@@ -25,7 +25,9 @@ fn bar() {
2525 baz();
2626}
2727
28struct Struct { _x: i32 }
28struct Struct {
29 _x: i32,
30}
2931
3032impl Struct {
3133 //~ MONO_ITEM fn Struct::foo
tests/codegen-units/item-collection/overloaded-operators.rs+5-15
......@@ -1,12 +1,12 @@
11//@ compile-flags:-Zprint-mono-items=eager
22
33#![deny(dead_code)]
4#![crate_type="lib"]
4#![crate_type = "lib"]
55
6use std::ops::{Index, IndexMut, Add, Deref};
6use std::ops::{Add, Deref, Index, IndexMut};
77
88pub struct Indexable {
9 data: [u8; 3]
9 data: [u8; 3],
1010}
1111
1212impl Index<usize> for Indexable {
......@@ -14,32 +14,22 @@ impl Index<usize> for Indexable {
1414
1515 //~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index
1616 fn index(&self, index: usize) -> &Self::Output {
17 if index >= 3 {
18 &self.data[0]
19 } else {
20 &self.data[index]
21 }
17 if index >= 3 { &self.data[0] } else { &self.data[index] }
2218 }
2319}
2420
2521impl IndexMut<usize> for Indexable {
2622 //~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut
2723 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
28 if index >= 3 {
29 &mut self.data[0]
30 } else {
31 &mut self.data[index]
32 }
24 if index >= 3 { &mut self.data[0] } else { &mut self.data[index] }
3325 }
3426}
3527
36
3728//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq
3829//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne
3930#[derive(PartialEq)]
4031pub struct Equatable(u32);
4132
42
4333impl Add<u32> for Equatable {
4434 type Output = u32;
4535
tests/codegen-units/item-collection/static-init.rs+2-2
......@@ -2,9 +2,9 @@
22
33#![feature(start)]
44
5pub static FN : fn() = foo::<i32>;
5pub static FN: fn() = foo::<i32>;
66
7pub fn foo<T>() { }
7pub fn foo<T>() {}
88
99//~ MONO_ITEM fn foo::<T>
1010//~ MONO_ITEM static FN
tests/codegen-units/item-collection/trait-implementations.rs+15-19
......@@ -9,7 +9,6 @@ pub trait SomeTrait {
99}
1010
1111impl SomeTrait for i64 {
12
1312 //~ MONO_ITEM fn <i64 as SomeTrait>::foo
1413 fn foo(&self) {}
1514
......@@ -17,7 +16,6 @@ impl SomeTrait for i64 {
1716}
1817
1918impl SomeTrait for i32 {
20
2119 //~ MONO_ITEM fn <i32 as SomeTrait>::foo
2220 fn foo(&self) {}
2321
......@@ -31,7 +29,6 @@ pub trait SomeGenericTrait<T> {
3129
3230// Concrete impl of generic trait
3331impl SomeGenericTrait<u32> for f64 {
34
3532 //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::foo
3633 fn foo(&self, _: u32) {}
3734
......@@ -40,7 +37,6 @@ impl SomeGenericTrait<u32> for f64 {
4037
4138// Generic impl of generic trait
4239impl<T> SomeGenericTrait<T> for f32 {
43
4440 fn foo(&self, _: T) {}
4541 fn bar<T2>(&self, _: T, _: T2) {}
4642}
......@@ -48,26 +44,26 @@ impl<T> SomeGenericTrait<T> for f32 {
4844//~ MONO_ITEM fn start
4945#[start]
5046fn start(_: isize, _: *const *const u8) -> isize {
51 //~ MONO_ITEM fn <i32 as SomeTrait>::bar::<char>
52 0i32.bar('x');
47 //~ MONO_ITEM fn <i32 as SomeTrait>::bar::<char>
48 0i32.bar('x');
5349
54 //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<&str>
55 0f64.bar(0u32, "&str");
50 //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<&str>
51 0f64.bar(0u32, "&str");
5652
57 //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<()>
58 0f64.bar(0u32, ());
53 //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<()>
54 0f64.bar(0u32, ());
5955
60 //~ MONO_ITEM fn <f32 as SomeGenericTrait<char>>::foo
61 0f32.foo('x');
56 //~ MONO_ITEM fn <f32 as SomeGenericTrait<char>>::foo
57 0f32.foo('x');
6258
63 //~ MONO_ITEM fn <f32 as SomeGenericTrait<i64>>::foo
64 0f32.foo(-1i64);
59 //~ MONO_ITEM fn <f32 as SomeGenericTrait<i64>>::foo
60 0f32.foo(-1i64);
6561
66 //~ MONO_ITEM fn <f32 as SomeGenericTrait<u32>>::bar::<()>
67 0f32.bar(0u32, ());
62 //~ MONO_ITEM fn <f32 as SomeGenericTrait<u32>>::bar::<()>
63 0f32.bar(0u32, ());
6864
69 //~ MONO_ITEM fn <f32 as SomeGenericTrait<&str>>::bar::<&str>
70 0f32.bar("&str", "&str");
65 //~ MONO_ITEM fn <f32 as SomeGenericTrait<&str>>::bar::<&str>
66 0f32.bar("&str", "&str");
7167
72 0
68 0
7369}
tests/codegen-units/item-collection/trait-method-as-argument.rs+8-5
......@@ -3,16 +3,19 @@
33#![deny(dead_code)]
44#![feature(start)]
55
6trait Trait : Sized {
7 fn foo(self) -> Self { self }
6trait Trait: Sized {
7 fn foo(self) -> Self {
8 self
9 }
810}
911
1012impl Trait for u32 {
11 fn foo(self) -> u32 { self }
13 fn foo(self) -> u32 {
14 self
15 }
1216}
1317
14impl Trait for char {
15}
18impl Trait for char {}
1619
1720fn take_foo_once<T, F: FnOnce(T) -> T>(f: F, arg: T) -> T {
1821 (f)(arg)
tests/codegen-units/item-collection/trait-method-default-impl.rs+5-3
......@@ -4,8 +4,10 @@
44#![feature(start)]
55
66trait SomeTrait {
7 fn foo(&self) { }
8 fn bar<T>(&self, x: T) -> T { x }
7 fn foo(&self) {}
8 fn bar<T>(&self, x: T) -> T {
9 x
10 }
911}
1012
1113impl SomeTrait for i8 {
......@@ -17,7 +19,7 @@ impl SomeTrait for i8 {
1719}
1820
1921trait SomeGenericTrait<T1> {
20 fn foo(&self) { }
22 fn foo(&self) {}
2123 fn bar<T2>(&self, x: T1, y: T2) {}
2224}
2325
tests/codegen-units/item-collection/unsizing.rs+2-6
......@@ -27,7 +27,7 @@ impl Trait for char {
2727struct Struct<T: ?Sized> {
2828 _a: u32,
2929 _b: i32,
30 _c: T
30 _c: T,
3131}
3232
3333impl Trait for f64 {
......@@ -60,11 +60,7 @@ fn start(_: isize, _: *const *const u8) -> isize {
6060 let _char_unsized = char_sized as &Trait;
6161
6262 // struct field
63 let struct_sized = &Struct {
64 _a: 1,
65 _b: 2,
66 _c: 3.0f64
67 };
63 let struct_sized = &Struct { _a: 1, _b: 2, _c: 3.0f64 };
6864 //~ MONO_ITEM fn std::ptr::drop_in_place::<f64> - shim(None) @@ unsizing-cgu.0[Internal]
6965 //~ MONO_ITEM fn <f64 as Trait>::foo
7066 let _struct_unsized = struct_sized as &Struct<Trait>;
tests/codegen-units/item-collection/unused-traits-and-generics.rs+4-4
......@@ -1,6 +1,6 @@
11//@ compile-flags:-Zprint-mono-items=eager
22
3#![crate_type="lib"]
3#![crate_type = "lib"]
44#![deny(dead_code)]
55
66// This test asserts that no codegen items are generated for generic items that
......@@ -16,7 +16,7 @@ pub fn foo<T: Copy>(x: T) -> (T, T) {
1616}
1717
1818pub struct Struct<T> {
19 x: T
19 x: T,
2020}
2121
2222impl<T> Struct<T> {
......@@ -29,7 +29,7 @@ impl<T> Struct<T> {
2929
3030pub enum Enum<T> {
3131 A(T),
32 B { x: T }
32 B { x: T },
3333}
3434
3535impl<T> Enum<T> {
......@@ -56,7 +56,7 @@ impl<T> TupleStruct<T> {
5656pub type Pair<T> = (T, T);
5757
5858pub struct NonGeneric {
59 x: i32
59 x: i32,
6060}
6161
6262impl NonGeneric {
tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs+1-1
......@@ -3,7 +3,7 @@
33//@ compile-flags:-Zshare-generics=yes -Copt-level=0
44//@ no-prefer-dynamic
55
6#![crate_type="rlib"]
6#![crate_type = "rlib"]
77
88pub fn generic_fn<T>(x: T, y: T) -> (T, T) {
99 (x, y)
tests/codegen-units/partitioning/extern-generic.rs+1-1
......@@ -3,7 +3,7 @@
33//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=y
44
55#![allow(dead_code)]
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88//@ aux-build:cgu_generic_function.rs
99extern crate cgu_generic_function;
tests/codegen-units/partitioning/inlining-from-extern-crate.rs+4-7
......@@ -3,7 +3,7 @@
33//@ compile-flags:-Zprint-mono-items=lazy
44//@ compile-flags:-Zinline-in-all-cgus
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88//@ aux-build:cgu_explicit_inlining.rs
99extern crate cgu_explicit_inlining;
......@@ -15,8 +15,7 @@ extern crate cgu_explicit_inlining;
1515//~ MONO_ITEM fn cgu_explicit_inlining::always_inlined @@ inlining_from_extern_crate[Internal] inlining_from_extern_crate-mod2[Internal]
1616
1717//~ MONO_ITEM fn user @@ inlining_from_extern_crate[External]
18pub fn user()
19{
18pub fn user() {
2019 cgu_explicit_inlining::inlined();
2120 cgu_explicit_inlining::always_inlined();
2221
......@@ -28,8 +27,7 @@ pub mod mod1 {
2827 use cgu_explicit_inlining;
2928
3029 //~ MONO_ITEM fn mod1::user @@ inlining_from_extern_crate-mod1[External]
31 pub fn user()
32 {
30 pub fn user() {
3331 cgu_explicit_inlining::inlined();
3432
3533 // does not generate a monomorphization in this crate
......@@ -41,8 +39,7 @@ pub mod mod2 {
4139 use cgu_explicit_inlining;
4240
4341 //~ MONO_ITEM fn mod2::user @@ inlining_from_extern_crate-mod2[External]
44 pub fn user()
45 {
42 pub fn user() {
4643 cgu_explicit_inlining::always_inlined();
4744
4845 // does not generate a monomorphization in this crate
tests/codegen-units/partitioning/local-generic.rs+4-2
......@@ -3,13 +3,15 @@
33//@ compile-flags:-Zprint-mono-items=eager
44
55#![allow(dead_code)]
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88//~ MONO_ITEM fn generic::<u32> @@ local_generic.volatile[External]
99//~ MONO_ITEM fn generic::<u64> @@ local_generic.volatile[External]
1010//~ MONO_ITEM fn generic::<char> @@ local_generic.volatile[External]
1111//~ MONO_ITEM fn generic::<&str> @@ local_generic.volatile[External]
12pub fn generic<T>(x: T) -> T { x }
12pub fn generic<T>(x: T) -> T {
13 x
14}
1315
1416//~ MONO_ITEM fn user @@ local_generic[Internal]
1517fn user() {
tests/codegen-units/partitioning/local-inlining-but-not-all.rs+3-8
......@@ -4,16 +4,13 @@
44//@ compile-flags:-Zinline-in-all-cgus=no
55
66#![allow(dead_code)]
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
99mod inline {
1010
1111 //~ MONO_ITEM fn inline::inlined_function @@ local_inlining_but_not_all-inline[External]
1212 #[inline]
13 pub fn inlined_function()
14 {
15
16 }
13 pub fn inlined_function() {}
1714}
1815
1916pub mod user1 {
......@@ -37,7 +34,5 @@ pub mod user2 {
3734pub mod non_user {
3835
3936 //~ MONO_ITEM fn non_user::baz @@ local_inlining_but_not_all-non_user[External]
40 pub fn baz() {
41
42 }
37 pub fn baz() {}
4338}
tests/codegen-units/partitioning/local-inlining.rs+3-8
......@@ -4,17 +4,14 @@
44//@ compile-flags:-Zinline-in-all-cgus
55
66#![allow(dead_code)]
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
99mod inline {
1010
1111 // Important: This function should show up in all codegen units where it is inlined
1212 //~ MONO_ITEM fn inline::inlined_function @@ local_inlining-user1[Internal] local_inlining-user2[Internal]
1313 #[inline(always)]
14 pub fn inlined_function()
15 {
16
17 }
14 pub fn inlined_function() {}
1815}
1916
2017pub mod user1 {
......@@ -38,7 +35,5 @@ pub mod user2 {
3835pub mod non_user {
3936
4037 //~ MONO_ITEM fn non_user::baz @@ local_inlining-non_user[External]
41 pub fn baz() {
42
43 }
38 pub fn baz() {}
4439}
tests/codegen-units/partitioning/local-transitive-inlining.rs+3-8
......@@ -4,16 +4,13 @@
44//@ compile-flags:-Zinline-in-all-cgus
55
66#![allow(dead_code)]
7#![crate_type="rlib"]
7#![crate_type = "rlib"]
88
99mod inline {
1010
1111 //~ MONO_ITEM fn inline::inlined_function @@ local_transitive_inlining-indirect_user[Internal]
1212 #[inline(always)]
13 pub fn inlined_function()
14 {
15
16 }
13 pub fn inlined_function() {}
1714}
1815
1916mod direct_user {
......@@ -38,7 +35,5 @@ pub mod indirect_user {
3835pub mod non_user {
3936
4037 //~ MONO_ITEM fn non_user::baz @@ local_transitive_inlining-non_user[External]
41 pub fn baz() {
42
43 }
38 pub fn baz() {}
4439}
tests/codegen-units/partitioning/methods-are-with-self-type.rs+2-3
......@@ -15,7 +15,7 @@ struct SomeType;
1515struct SomeGenericType<T1, T2>(T1, T2);
1616
1717mod mod1 {
18 use super::{SomeType, SomeGenericType};
18 use super::{SomeGenericType, SomeType};
1919
2020 // Even though the impl is in `mod1`, the methods should end up in the
2121 // parent module, since that is where their self-type is.
......@@ -40,8 +40,7 @@ trait Trait {
4040
4141// We provide an implementation of `Trait` for all types. The corresponding
4242// monomorphizations should end up in whichever module the concrete `T` is.
43impl<T> Trait for T
44{
43impl<T> Trait for T {
4544 fn foo(&self) {}
4645}
4746
tests/codegen-units/partitioning/regular-modules.rs+1-1
......@@ -3,7 +3,7 @@
33//@ compile-flags:-Zprint-mono-items=eager
44
55#![allow(dead_code)]
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88//~ MONO_ITEM fn foo @@ regular_modules[Internal]
99fn foo() {}
tests/codegen-units/partitioning/shared-generics.rs+1-2
......@@ -4,14 +4,13 @@
44//@ incremental
55//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0
66
7#![crate_type="rlib"]
7#![crate_type = "rlib"]
88
99//@ aux-build:shared_generics_aux.rs
1010extern crate shared_generics_aux;
1111
1212//~ MONO_ITEM fn foo
1313pub fn foo() {
14
1514 //~ MONO_ITEM fn shared_generics_aux::generic_fn::<u16> @@ shared_generics_aux-in-shared_generics.volatile[External]
1615 let _ = shared_generics_aux::generic_fn(0u16, 1u16);
1716
tests/codegen-units/partitioning/statics.rs+1-1
......@@ -2,7 +2,7 @@
22//@ incremental
33//@ compile-flags:-Zprint-mono-items=lazy
44
5#![crate_type="rlib"]
5#![crate_type = "rlib"]
66
77//~ MONO_ITEM static FOO @@ statics[Internal]
88static FOO: u32 = 0;
tests/codegen-units/partitioning/vtable-through-const.rs+15-7
......@@ -28,20 +28,24 @@ mod mod1 {
2828 }
2929
3030 impl<T> Trait1Gen<T> for NeedsDrop {
31 fn do_something(&self, x: T) -> T { x }
32 fn do_something_else(&self, x: T) -> T { x }
31 fn do_something(&self, x: T) -> T {
32 x
33 }
34 fn do_something_else(&self, x: T) -> T {
35 x
36 }
3337 }
3438
3539 //~ MONO_ITEM fn mod1::id::<i64> @@ vtable_through_const-mod1.volatile[Internal]
36 fn id<T>(x: T) -> T { x }
40 fn id<T>(x: T) -> T {
41 x
42 }
3743
3844 // These are referenced, so they produce mono-items (see start())
3945 pub const TRAIT1_REF: &'static Trait1 = &NeedsDrop as &Trait1;
4046 pub const TRAIT1_GEN_REF: &'static Trait1Gen<u8> = &NeedsDrop as &Trait1Gen<u8>;
4147 pub const ID_CHAR: fn(char) -> char = id::<char>;
4248
43
44
4549 pub trait Trait2 {
4650 fn do_something(&self) {}
4751 fn do_something_else(&self) {}
......@@ -57,8 +61,12 @@ mod mod1 {
5761 }
5862
5963 impl<T> Trait2Gen<T> for NeedsDrop {
60 fn do_something(&self, x: T) -> T { x }
61 fn do_something_else(&self, x: T) -> T { x }
64 fn do_something(&self, x: T) -> T {
65 x
66 }
67 fn do_something_else(&self, x: T) -> T {
68 x
69 }
6270 }
6371
6472 // These are not referenced, so they do not produce mono-items
tests/codegen-units/polymorphization/unused_type_parameters.rs+73-80
......@@ -9,54 +9,51 @@ mod functions {
99 // Function doesn't have any type parameters to be unused.
1010 pub fn no_parameters() {}
1111
12//~ MONO_ITEM fn functions::no_parameters
12 //~ MONO_ITEM fn functions::no_parameters
1313
1414 // Function has an unused type parameter.
15 pub fn unused<T>() {
16 }
15 pub fn unused<T>() {}
1716
18//~ MONO_ITEM fn functions::unused::<T>
17 //~ MONO_ITEM fn functions::unused::<T>
1918
2019 // Function uses type parameter in value of a binding.
2120 pub fn used_binding_value<T: Default>() {
2221 let _: T = Default::default();
2322 }
2423
25//~ MONO_ITEM fn functions::used_binding_value::<u32>
26//~ MONO_ITEM fn functions::used_binding_value::<u64>
24 //~ MONO_ITEM fn functions::used_binding_value::<u32>
25 //~ MONO_ITEM fn functions::used_binding_value::<u64>
2726
2827 // Function uses type parameter in type of a binding.
2928 pub fn used_binding_type<T>() {
3029 let _: Option<T> = None;
3130 }
3231
33//~ MONO_ITEM fn functions::used_binding_type::<u32>
34//~ MONO_ITEM fn functions::used_binding_type::<u64>
32 //~ MONO_ITEM fn functions::used_binding_type::<u32>
33 //~ MONO_ITEM fn functions::used_binding_type::<u64>
3534
3635 // Function uses type parameter in argument.
37 pub fn used_argument<T>(_: T) {
38 }
36 pub fn used_argument<T>(_: T) {}
3937
40//~ MONO_ITEM fn functions::used_argument::<u32>
41//~ MONO_ITEM fn functions::used_argument::<u64>
42//
38 //~ MONO_ITEM fn functions::used_argument::<u32>
39 //~ MONO_ITEM fn functions::used_argument::<u64>
40 //
4341 // Function uses type parameter in substitutions to another function.
4442 pub fn used_substs<T>() {
4543 unused::<T>()
4644 }
4745
48//~ MONO_ITEM fn functions::used_substs::<u32>
49//~ MONO_ITEM fn functions::used_substs::<u64>
46 //~ MONO_ITEM fn functions::used_substs::<u32>
47 //~ MONO_ITEM fn functions::used_substs::<u64>
5048}
5149
52
5350mod closures {
5451 // Function doesn't have any type parameters to be unused.
5552 pub fn no_parameters() {
5653 let _ = || {};
5754 }
5855
59//~ MONO_ITEM fn closures::no_parameters
56 //~ MONO_ITEM fn closures::no_parameters
6057
6158 // Function has an unused type parameter in parent and closure.
6259 pub fn unused<T>() -> u32 {
......@@ -64,8 +61,8 @@ mod closures {
6461 add_one(3)
6562 }
6663
67//~ MONO_ITEM fn closures::unused::<T>::{closure#0}
68//~ MONO_ITEM fn closures::unused::<T>
64 //~ MONO_ITEM fn closures::unused::<T>::{closure#0}
65 //~ MONO_ITEM fn closures::unused::<T>
6966
7067 // Function has an unused type parameter in closure, but not in parent.
7168 pub fn used_parent<T: Default>() -> u32 {
......@@ -74,9 +71,9 @@ mod closures {
7471 add_one(3)
7572 }
7673
77//~ MONO_ITEM fn closures::used_parent::<T>::{closure#0}
78//~ MONO_ITEM fn closures::used_parent::<u32>
79//~ MONO_ITEM fn closures::used_parent::<u64>
74 //~ MONO_ITEM fn closures::used_parent::<T>::{closure#0}
75 //~ MONO_ITEM fn closures::used_parent::<u32>
76 //~ MONO_ITEM fn closures::used_parent::<u64>
8077
8178 // Function uses type parameter in value of a binding in closure.
8279 pub fn used_binding_value<T: Default>() -> T {
......@@ -88,10 +85,10 @@ mod closures {
8885 x()
8986 }
9087
91//~ MONO_ITEM fn closures::used_binding_value::<u32>::{closure#0}
92//~ MONO_ITEM fn closures::used_binding_value::<u64>::{closure#0}
93//~ MONO_ITEM fn closures::used_binding_value::<u32>
94//~ MONO_ITEM fn closures::used_binding_value::<u64>
88 //~ MONO_ITEM fn closures::used_binding_value::<u32>::{closure#0}
89 //~ MONO_ITEM fn closures::used_binding_value::<u64>::{closure#0}
90 //~ MONO_ITEM fn closures::used_binding_value::<u32>
91 //~ MONO_ITEM fn closures::used_binding_value::<u64>
9592
9693 // Function uses type parameter in type of a binding in closure.
9794 pub fn used_binding_type<T>() -> Option<T> {
......@@ -103,10 +100,10 @@ mod closures {
103100 x()
104101 }
105102
106//~ MONO_ITEM fn closures::used_binding_type::<u32>::{closure#0}
107//~ MONO_ITEM fn closures::used_binding_type::<u64>::{closure#0}
108//~ MONO_ITEM fn closures::used_binding_type::<u32>
109//~ MONO_ITEM fn closures::used_binding_type::<u64>
103 //~ MONO_ITEM fn closures::used_binding_type::<u32>::{closure#0}
104 //~ MONO_ITEM fn closures::used_binding_type::<u64>::{closure#0}
105 //~ MONO_ITEM fn closures::used_binding_type::<u32>
106 //~ MONO_ITEM fn closures::used_binding_type::<u64>
110107
111108 // Function and closure uses type parameter in argument.
112109 pub fn used_argument<T>(t: T) -> u32 {
......@@ -114,10 +111,10 @@ mod closures {
114111 x(t)
115112 }
116113
117//~ MONO_ITEM fn closures::used_argument::<u32>::{closure#0}
118//~ MONO_ITEM fn closures::used_argument::<u64>::{closure#0}
119//~ MONO_ITEM fn closures::used_argument::<u32>
120//~ MONO_ITEM fn closures::used_argument::<u64>
114 //~ MONO_ITEM fn closures::used_argument::<u32>::{closure#0}
115 //~ MONO_ITEM fn closures::used_argument::<u64>::{closure#0}
116 //~ MONO_ITEM fn closures::used_argument::<u32>
117 //~ MONO_ITEM fn closures::used_argument::<u64>
121118
122119 // Closure uses type parameter in argument.
123120 pub fn used_argument_closure<T: Default>() -> u32 {
......@@ -126,10 +123,10 @@ mod closures {
126123 x(t)
127124 }
128125
129//~ MONO_ITEM fn closures::used_argument_closure::<u32>::{closure#0}
130//~ MONO_ITEM fn closures::used_argument_closure::<u64>::{closure#0}
131//~ MONO_ITEM fn closures::used_argument_closure::<u32>
132//~ MONO_ITEM fn closures::used_argument_closure::<u64>
126 //~ MONO_ITEM fn closures::used_argument_closure::<u32>::{closure#0}
127 //~ MONO_ITEM fn closures::used_argument_closure::<u64>::{closure#0}
128 //~ MONO_ITEM fn closures::used_argument_closure::<u32>
129 //~ MONO_ITEM fn closures::used_argument_closure::<u64>
133130
134131 // Closure uses type parameter as upvar.
135132 pub fn used_upvar<T: Default>() -> T {
......@@ -138,10 +135,10 @@ mod closures {
138135 y()
139136 }
140137
141//~ MONO_ITEM fn closures::used_upvar::<u32>::{closure#0}
142//~ MONO_ITEM fn closures::used_upvar::<u64>::{closure#0}
143//~ MONO_ITEM fn closures::used_upvar::<u32>
144//~ MONO_ITEM fn closures::used_upvar::<u64>
138 //~ MONO_ITEM fn closures::used_upvar::<u32>::{closure#0}
139 //~ MONO_ITEM fn closures::used_upvar::<u64>::{closure#0}
140 //~ MONO_ITEM fn closures::used_upvar::<u32>
141 //~ MONO_ITEM fn closures::used_upvar::<u64>
145142
146143 // Closure uses type parameter in substitutions to another function.
147144 pub fn used_substs<T>() {
......@@ -149,10 +146,10 @@ mod closures {
149146 x()
150147 }
151148
152//~ MONO_ITEM fn closures::used_substs::<u32>::{closure#0}
153//~ MONO_ITEM fn closures::used_substs::<u64>::{closure#0}
154//~ MONO_ITEM fn closures::used_substs::<u32>
155//~ MONO_ITEM fn closures::used_substs::<u64>
149 //~ MONO_ITEM fn closures::used_substs::<u32>::{closure#0}
150 //~ MONO_ITEM fn closures::used_substs::<u64>::{closure#0}
151 //~ MONO_ITEM fn closures::used_substs::<u32>
152 //~ MONO_ITEM fn closures::used_substs::<u64>
156153}
157154
158155mod methods {
......@@ -160,32 +157,30 @@ mod methods {
160157
161158 impl<F: Default> Foo<F> {
162159 // Function has an unused type parameter from impl.
163 pub fn unused_impl() {
164 }
160 pub fn unused_impl() {}
165161
166//~ MONO_ITEM fn methods::Foo::<F>::unused_impl
162 //~ MONO_ITEM fn methods::Foo::<F>::unused_impl
167163
168164 // Function has an unused type parameter from impl and fn.
169 pub fn unused_both<G: Default>() {
170 }
165 pub fn unused_both<G: Default>() {}
171166
172//~ MONO_ITEM fn methods::Foo::<F>::unused_both::<G>
167 //~ MONO_ITEM fn methods::Foo::<F>::unused_both::<G>
173168
174169 // Function uses type parameter from impl.
175170 pub fn used_impl() {
176171 let _: F = Default::default();
177172 }
178173
179//~ MONO_ITEM fn methods::Foo::<u32>::used_impl
180//~ MONO_ITEM fn methods::Foo::<u64>::used_impl
174 //~ MONO_ITEM fn methods::Foo::<u32>::used_impl
175 //~ MONO_ITEM fn methods::Foo::<u64>::used_impl
181176
182177 // Function uses type parameter from impl.
183178 pub fn used_fn<G: Default>() {
184179 let _: G = Default::default();
185180 }
186181
187//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u32>
188//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u64>
182 //~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u32>
183 //~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u64>
189184
190185 // Function uses type parameter from impl.
191186 pub fn used_both<G: Default>() {
......@@ -193,16 +188,16 @@ mod methods {
193188 let _: G = Default::default();
194189 }
195190
196//~ MONO_ITEM fn methods::Foo::<u32>::used_both::<u32>
197//~ MONO_ITEM fn methods::Foo::<u64>::used_both::<u64>
191 //~ MONO_ITEM fn methods::Foo::<u32>::used_both::<u32>
192 //~ MONO_ITEM fn methods::Foo::<u64>::used_both::<u64>
198193
199194 // Function uses type parameter in substitutions to another function.
200195 pub fn used_substs() {
201196 super::functions::unused::<F>()
202197 }
203198
204//~ MONO_ITEM fn methods::Foo::<u32>::used_substs
205//~ MONO_ITEM fn methods::Foo::<u64>::used_substs
199 //~ MONO_ITEM fn methods::Foo::<u32>::used_substs
200 //~ MONO_ITEM fn methods::Foo::<u64>::used_substs
206201
207202 // Function has an unused type parameter from impl and fn.
208203 pub fn closure_unused_all<G: Default>() -> u32 {
......@@ -210,8 +205,8 @@ mod methods {
210205 add_one(3)
211206 }
212207
213//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>::{closure#0}
214//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>
208 //~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>::{closure#0}
209 //~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>
215210
216211 // Function uses type parameter from impl and fn in closure.
217212 pub fn closure_used_both<G: Default>() -> u32 {
......@@ -224,10 +219,10 @@ mod methods {
224219 add_one(3)
225220 }
226221
227//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>::{closure#0}
228//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>::{closure#0}
229//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>
230//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>
222 //~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>::{closure#0}
223 //~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>::{closure#0}
224 //~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>
225 //~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>
231226
232227 // Function uses type parameter from fn in closure.
233228 pub fn closure_used_fn<G: Default>() -> u32 {
......@@ -239,10 +234,10 @@ mod methods {
239234 add_one(3)
240235 }
241236
242//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>::{closure#0}
243//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>::{closure#0}
244//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>
245//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>
237 //~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>::{closure#0}
238 //~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>::{closure#0}
239 //~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>
240 //~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>
246241
247242 // Function uses type parameter from impl in closure.
248243 pub fn closure_used_impl<G: Default>() -> u32 {
......@@ -254,10 +249,10 @@ mod methods {
254249 add_one(3)
255250 }
256251
257//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>::{closure#0}
258//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>::{closure#0}
259//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>
260//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>
252 //~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>::{closure#0}
253 //~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>::{closure#0}
254 //~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>
255 //~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>
261256
262257 // Closure uses type parameter in substitutions to another function.
263258 pub fn closure_used_substs() {
......@@ -265,15 +260,13 @@ mod methods {
265260 x()
266261 }
267262
268//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs::{closure#0}
269//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs::{closure#0}
270//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs
271//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs
263 //~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs::{closure#0}
264 //~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs::{closure#0}
265 //~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs
266 //~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs
272267 }
273268}
274269
275
276
277270fn dispatch<T: Default>() {
278271 functions::no_parameters();
279272 functions::unused::<T>();
tests/codegen/aarch64-struct-align-128.rs+24-26
......@@ -12,14 +12,12 @@
1212#![crate_type = "lib"]
1313#![no_core]
1414
15#[lang="sized"]
16trait Sized { }
17#[lang="freeze"]
18trait Freeze { }
19#[lang="copy"]
20trait Copy { }
21
22
15#[lang = "sized"]
16trait Sized {}
17#[lang = "freeze"]
18trait Freeze {}
19#[lang = "copy"]
20trait Copy {}
2321
2422// Passed as `[i64 x 2]`, since it's an aggregate with size <= 128 bits, align < 128 bits.
2523#[repr(C)]
......@@ -31,7 +29,7 @@ pub struct Align8 {
3129// repr(transparent), so same as above.
3230#[repr(transparent)]
3331pub struct Transparent8 {
34 a: Align8
32 a: Align8,
3533}
3634
3735// Passed as `[i64 x 2]`, since it's an aggregate with size <= 128 bits, align < 128 bits.
......@@ -47,8 +45,6 @@ extern "C" {
4745 fn test_8(a: Align8, b: Transparent8, c: Wrapped8);
4846}
4947
50
51
5248// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits.
5349// EXCEPT on Linux, where there's a special case to use its unadjusted alignment,
5450// making it the same as `Align8`, so it's be passed as `[i64 x 2]`.
......@@ -62,7 +58,7 @@ pub struct Align16 {
6258// repr(transparent), so same as above.
6359#[repr(transparent)]
6460pub struct Transparent16 {
65 a: Align16
61 a: Align16,
6662}
6763
6864// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits.
......@@ -79,8 +75,6 @@ extern "C" {
7975 fn test_16(a: Align16, b: Transparent16, c: Wrapped16);
8076}
8177
82
83
8478// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits.
8579#[repr(C)]
8680pub struct I128 {
......@@ -90,13 +84,13 @@ pub struct I128 {
9084// repr(transparent), so same as above.
9185#[repr(transparent)]
9286pub struct TransparentI128 {
93 a: I128
87 a: I128,
9488}
9589
9690// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits.
9791#[repr(C)]
9892pub struct WrappedI128 {
99 pub a: I128
93 pub a: I128,
10094}
10195
10296extern "C" {
......@@ -106,8 +100,6 @@ extern "C" {
106100 fn test_i128(a: I128, b: TransparentI128, c: WrappedI128);
107101}
108102
109
110
111103// Passed as `[2 x i64]`, since it's an aggregate with size <= 128 bits, align < 128 bits.
112104// Note that the Linux special case does not apply, because packing is not considered "adjustment".
113105#[repr(C)]
......@@ -119,13 +111,13 @@ pub struct Packed {
119111// repr(transparent), so same as above.
120112#[repr(transparent)]
121113pub struct TransparentPacked {
122 a: Packed
114 a: Packed,
123115}
124116
125117// Passed as `[2 x i64]`, since it's an aggregate with size <= 128 bits, align < 128 bits.
126118#[repr(C)]
127119pub struct WrappedPacked {
128 pub a: Packed
120 pub a: Packed,
129121}
130122
131123extern "C" {
......@@ -135,13 +127,19 @@ extern "C" {
135127 fn test_packed(a: Packed, b: TransparentPacked, c: WrappedPacked);
136128}
137129
138
139
140130pub unsafe fn main(
141 a1: Align8, a2: Transparent8, a3: Wrapped8,
142 b1: Align16, b2: Transparent16, b3: Wrapped16,
143 c1: I128, c2: TransparentI128, c3: WrappedI128,
144 d1: Packed, d2: TransparentPacked, d3: WrappedPacked,
131 a1: Align8,
132 a2: Transparent8,
133 a3: Wrapped8,
134 b1: Align16,
135 b2: Transparent16,
136 b3: Wrapped16,
137 c1: I128,
138 c2: TransparentI128,
139 c3: WrappedI128,
140 d1: Packed,
141 d2: TransparentPacked,
142 d3: WrappedPacked,
145143) {
146144 test_8(a1, a2, a3);
147145 test_16(b1, b2, b3);
tests/codegen/abi-efiapi.rs+6-6
......@@ -17,12 +17,12 @@
1717#![feature(no_core, lang_items)]
1818#![no_core]
1919
20#[lang="sized"]
21trait Sized { }
22#[lang="freeze"]
23trait Freeze { }
24#[lang="copy"]
25trait Copy { }
20#[lang = "sized"]
21trait Sized {}
22#[lang = "freeze"]
23trait Freeze {}
24#[lang = "copy"]
25trait Copy {}
2626
2727//x86_64: define win64cc void @has_efiapi
2828//i686: define void @has_efiapi
tests/codegen/abi-main-signature-16bit-c-int.rs+1-3
......@@ -6,8 +6,6 @@
66//@[avr] only-avr
77//@[msp] only-msp430
88
9
10fn main() {
11}
9fn main() {}
1210
1311// CHECK: define i16 @main(i16, i8**)
tests/codegen/abi-main-signature-32bit-c-int.rs+1-2
......@@ -6,7 +6,6 @@
66//@ ignore-avr
77//@ ignore-wasi wasi codegens the main symbol differently
88
9fn main() {
10}
9fn main() {}
1110
1211// CHECK: define{{( hidden| noundef)*}} i32 @main(i32{{( %0)?}}, ptr{{( %1)?}})
tests/codegen/abi-repr-ext.rs+7-5
......@@ -24,14 +24,17 @@
2424#![no_std]
2525#![no_core]
2626
27#[lang="sized"] trait Sized { }
28#[lang="freeze"] trait Freeze { }
29#[lang="copy"] trait Copy { }
27#[lang = "sized"]
28trait Sized {}
29#[lang = "freeze"]
30trait Freeze {}
31#[lang = "copy"]
32trait Copy {}
3033
3134#[repr(i8)]
3235pub enum Type {
3336 Type1 = 0,
34 Type2 = 1
37 Type2 = 1,
3538}
3639
3740// To accommodate rust#97800, one might consider writing the below as:
......@@ -50,7 +53,6 @@ pub enum Type {
5053// riscv-SAME: signext
5154// CHECK-SAME: i8 @test()
5255
53
5456#[no_mangle]
5557pub extern "C" fn test() -> Type {
5658 Type::Type1
tests/codegen/abi-x86_64_sysv.rs+8-8
......@@ -5,25 +5,25 @@
55#![crate_type = "lib"]
66
77pub struct S24 {
8 a: i8,
9 b: i8,
10 c: i8,
8 a: i8,
9 b: i8,
10 c: i8,
1111}
1212
1313pub struct S48 {
14 a: i16,
15 b: i16,
16 c: i8,
14 a: i16,
15 b: i16,
16 c: i8,
1717}
1818
1919// CHECK: i24 @struct_24_bits(i24
2020#[no_mangle]
2121pub extern "sysv64" fn struct_24_bits(a: S24) -> S24 {
22 a
22 a
2323}
2424
2525// CHECK: i48 @struct_48_bits(i48
2626#[no_mangle]
2727pub extern "sysv64" fn struct_48_bits(a: S48) -> S48 {
28 a
28 a
2929}
tests/codegen/adjustments.rs+5-6
......@@ -5,17 +5,16 @@
55// Hack to get the correct size for the length part in slices
66// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
77#[no_mangle]
8pub fn helper(_: usize) {
9}
8pub fn helper(_: usize) {}
109
1110// CHECK-LABEL: @no_op_slice_adjustment
1211#[no_mangle]
1312pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
1413 // We used to generate an extra alloca and memcpy for the block's trailing expression value, so
1514 // check that we copy directly to the return value slot
16// CHECK: %0 = insertvalue { ptr, [[USIZE]] } poison, ptr %x.0, 0
17// CHECK: %1 = insertvalue { ptr, [[USIZE]] } %0, [[USIZE]] %x.1, 1
18// CHECK: ret { ptr, [[USIZE]] } %1
15 // CHECK: %0 = insertvalue { ptr, [[USIZE]] } poison, ptr %x.0, 0
16 // CHECK: %1 = insertvalue { ptr, [[USIZE]] } %0, [[USIZE]] %x.1, 1
17 // CHECK: ret { ptr, [[USIZE]] } %1
1918 { x }
2019}
2120
......@@ -24,6 +23,6 @@ pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
2423pub fn no_op_slice_adjustment2(x: &[u8]) -> &[u8] {
2524 // We used to generate an extra alloca and memcpy for the function's return value, so check
2625 // that there's no memcpy (the slice is written to sret_slot element-wise)
27// CHECK-NOT: call void @llvm.memcpy.
26 // CHECK-NOT: call void @llvm.memcpy.
2827 no_op_slice_adjustment(x)
2928}
tests/codegen/align-byval.rs+12-9
......@@ -23,9 +23,12 @@
2323#![no_std]
2424#![no_core]
2525
26#[lang="sized"] trait Sized { }
27#[lang="freeze"] trait Freeze { }
28#[lang="copy"] trait Copy { }
26#[lang = "sized"]
27trait Sized {}
28#[lang = "freeze"]
29trait Freeze {}
30#[lang = "copy"]
31trait Copy {}
2932
3033impl Copy for i32 {}
3134impl Copy for i64 {}
......@@ -58,7 +61,7 @@ pub struct ForceAlign4 {
5861pub struct NaturalAlign8 {
5962 a: i64,
6063 b: i64,
61 c: i64
64 c: i64,
6265}
6366
6467// On i686-windows, this is passed by reference (because alignment is >4 and requested/forced),
......@@ -68,7 +71,7 @@ pub struct NaturalAlign8 {
6871pub struct ForceAlign8 {
6972 a: i64,
7073 b: i64,
71 c: i64
74 c: i64,
7275}
7376
7477// On i686-windows, this is passed on stack, because requested alignment is <=4.
......@@ -77,28 +80,28 @@ pub struct ForceAlign8 {
7780pub struct LowerFA8 {
7881 a: i64,
7982 b: i64,
80 c: i64
83 c: i64,
8184}
8285
8386// On i686-windows, this is passed by reference, because it contains a field with
8487// requested/forced alignment.
8588#[repr(C)]
8689pub struct WrappedFA8 {
87 a: ForceAlign8
90 a: ForceAlign8,
8891}
8992
9093// On i686-windows, this has the same ABI as ForceAlign8, i.e. passed by reference.
9194#[repr(transparent)]
9295pub struct TransparentFA8 {
9396 _0: (),
94 a: ForceAlign8
97 a: ForceAlign8,
9598}
9699
97100#[repr(C)]
98101#[repr(align(16))]
99102pub struct ForceAlign16 {
100103 a: [i32; 16],
101 b: i8
104 b: i8,
102105}
103106
104107// CHECK-LABEL: @call_na1
tests/codegen/align-enum.rs+3-3
......@@ -18,8 +18,8 @@ pub struct Nested64 {
1818// CHECK-LABEL: @align64
1919#[no_mangle]
2020pub fn align64(a: u32) -> Align64 {
21// CHECK: %a64 = alloca [64 x i8], align 64
22// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
21 // CHECK: %a64 = alloca [64 x i8], align 64
22 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
2323 let a64 = Align64::A(a);
2424 a64
2525}
......@@ -27,7 +27,7 @@ pub fn align64(a: u32) -> Align64 {
2727// CHECK-LABEL: @nested64
2828#[no_mangle]
2929pub fn nested64(a: u8, b: u32, c: u16) -> Nested64 {
30// CHECK: %n64 = alloca [128 x i8], align 64
30 // CHECK: %n64 = alloca [128 x i8], align 64
3131 let n64 = Nested64 { a, b: Align64::B(b), c };
3232 n64
3333}
tests/codegen/align-offset.rs-1
......@@ -53,7 +53,6 @@ pub fn align_offset_word_slice(slice: &[Align4]) -> usize {
5353 slice.as_ptr().align_offset(32)
5454}
5555
56
5756// CHECK-LABEL: @align_offset_word_ptr(ptr{{.+}}%ptr
5857#[no_mangle]
5958pub fn align_offset_word_ptr(ptr: *const Align4) -> usize {
tests/codegen/align-struct.rs+7-7
......@@ -25,9 +25,9 @@ pub enum Enum64 {
2525
2626// CHECK-LABEL: @align64
2727#[no_mangle]
28pub fn align64(i : i32) -> Align64 {
29// CHECK: %a64 = alloca [64 x i8], align 64
30// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
28pub fn align64(i: i32) -> Align64 {
29 // CHECK: %a64 = alloca [64 x i8], align 64
30 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
3131 let a64 = Align64(i);
3232 a64
3333}
......@@ -37,14 +37,14 @@ pub fn align64(i : i32) -> Align64 {
3737// CHECK-LABEL: @align64_load
3838#[no_mangle]
3939pub fn align64_load(a: Align64) -> i32 {
40// CHECK: {{%.*}} = load i32, ptr {{%.*}}, align 64
40 // CHECK: {{%.*}} = load i32, ptr {{%.*}}, align 64
4141 a.0
4242}
4343
4444// CHECK-LABEL: @nested64
4545#[no_mangle]
4646pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 {
47// CHECK: %n64 = alloca [128 x i8], align 64
47 // CHECK: %n64 = alloca [128 x i8], align 64
4848 let n64 = Nested64 { a, b, c, d };
4949 n64
5050}
......@@ -52,7 +52,7 @@ pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 {
5252// CHECK-LABEL: @enum4
5353#[no_mangle]
5454pub fn enum4(a: i32) -> Enum4 {
55// CHECK: %e4 = alloca [8 x i8], align 4
55 // CHECK: %e4 = alloca [8 x i8], align 4
5656 let e4 = Enum4::A(a);
5757 e4
5858}
......@@ -60,7 +60,7 @@ pub fn enum4(a: i32) -> Enum4 {
6060// CHECK-LABEL: @enum64
6161#[no_mangle]
6262pub fn enum64(a: Align64) -> Enum64 {
63// CHECK: %e64 = alloca [128 x i8], align 64
63 // CHECK: %e64 = alloca [128 x i8], align 64
6464 let e64 = Enum64::A(a);
6565 e64
6666}
tests/codegen/array-cmp.rs+6-5
......@@ -10,9 +10,10 @@
1010#[no_mangle]
1111pub fn compare() -> bool {
1212 let bytes = 12.5f32.to_ne_bytes();
13 bytes == if cfg!(target_endian = "big") {
14 [0x41, 0x48, 0x00, 0x00]
15 } else {
16 [0x00, 0x00, 0x48, 0x41]
17 }
13 bytes
14 == if cfg!(target_endian = "big") {
15 [0x41, 0x48, 0x00, 0x00]
16 } else {
17 [0x00, 0x00, 0x48, 0x41]
18 }
1819}
tests/codegen/asm-maybe-uninit.rs+1-1
......@@ -4,8 +4,8 @@
44#![crate_type = "rlib"]
55#![allow(asm_sub_register)]
66
7use std::mem::MaybeUninit;
87use std::arch::asm;
8use std::mem::MaybeUninit;
99
1010// CHECK-LABEL: @int
1111#[no_mangle]
tests/codegen/asm-sanitize-llvm.rs+2-6
......@@ -21,14 +21,10 @@ trait Copy {}
2121
2222pub unsafe fn we_escape_dollar_signs() {
2323 // CHECK: call void asm sideeffect alignstack inteldialect "banana$$:"
24 asm!(
25 r"banana$:",
26 )
24 asm!(r"banana$:",)
2725}
2826
2927pub unsafe fn we_escape_escapes_too() {
3028 // CHECK: call void asm sideeffect alignstack inteldialect "banana\{{(\\|5C)}}36:"
31 asm!(
32 r"banana\36:",
33 )
29 asm!(r"banana\36:",)
3430}
tests/codegen/atomicptr.rs+1-2
......@@ -6,13 +6,12 @@
66
77//@ compile-flags: -O -Cno-prepopulate-passes
88#![crate_type = "lib"]
9
109#![feature(strict_provenance)]
1110#![feature(strict_provenance_atomic_ptr)]
1211
12use std::ptr::without_provenance_mut;
1313use std::sync::atomic::AtomicPtr;
1414use std::sync::atomic::Ordering::Relaxed;
15use std::ptr::without_provenance_mut;
1615
1716// Portability hack so that we can say [[USIZE]] instead of i64/i32/i16 for usize.
1817// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1)
tests/codegen/autovectorize-f32x4.rs+13-18
......@@ -5,25 +5,20 @@
55// CHECK-LABEL: @auto_vectorize_direct
66#[no_mangle]
77pub fn auto_vectorize_direct(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
8// CHECK: load <4 x float>
9// CHECK: load <4 x float>
10// CHECK: fadd <4 x float>
11// CHECK: store <4 x float>
12 [
13 a[0] + b[0],
14 a[1] + b[1],
15 a[2] + b[2],
16 a[3] + b[3],
17 ]
8 // CHECK: load <4 x float>
9 // CHECK: load <4 x float>
10 // CHECK: fadd <4 x float>
11 // CHECK: store <4 x float>
12 [a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]]
1813}
1914
2015// CHECK-LABEL: @auto_vectorize_loop
2116#[no_mangle]
2217pub fn auto_vectorize_loop(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
23// CHECK: load <4 x float>
24// CHECK: load <4 x float>
25// CHECK: fadd <4 x float>
26// CHECK: store <4 x float>
18 // CHECK: load <4 x float>
19 // CHECK: load <4 x float>
20 // CHECK: fadd <4 x float>
21 // CHECK: store <4 x float>
2722 let mut c = [0.0; 4];
2823 for i in 0..4 {
2924 c[i] = a[i] + b[i];
......@@ -34,9 +29,9 @@ pub fn auto_vectorize_loop(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
3429// CHECK-LABEL: @auto_vectorize_array_from_fn
3530#[no_mangle]
3631pub fn auto_vectorize_array_from_fn(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
37// CHECK: load <4 x float>
38// CHECK: load <4 x float>
39// CHECK: fadd <4 x float>
40// CHECK: store <4 x float>
32 // CHECK: load <4 x float>
33 // CHECK: load <4 x float>
34 // CHECK: fadd <4 x float>
35 // CHECK: store <4 x float>
4136 std::array::from_fn(|i| a[i] + b[i])
4237}
tests/codegen/auxiliary/extern_decl.rs+3-1
......@@ -5,7 +5,9 @@
55#![crate_type = "lib"]
66
77#[no_mangle]
8pub fn extern_fn() -> u8 { unsafe { extern_static } }
8pub fn extern_fn() -> u8 {
9 unsafe { extern_static }
10}
911
1012#[no_mangle]
1113pub static mut extern_static: u8 = 71;
tests/codegen/auxiliary/nounwind.rs+1-2
......@@ -1,3 +1,2 @@
11#[no_mangle]
2pub fn bar() {
3}
2pub fn bar() {}
tests/codegen/avr/avr-func-addrspace.rs+14-8
......@@ -14,15 +14,18 @@
1414#![no_core]
1515
1616#[lang = "sized"]
17pub trait Sized { }
17pub trait Sized {}
1818#[lang = "copy"]
19pub trait Copy { }
19pub trait Copy {}
2020#[lang = "receiver"]
21pub trait Receiver { }
21pub trait Receiver {}
2222#[lang = "tuple_trait"]
23pub trait Tuple { }
23pub trait Tuple {}
2424
25pub struct Result<T, E> { _a: T, _b: E }
25pub struct Result<T, E> {
26 _a: T,
27 _b: E,
28}
2629
2730impl Copy for usize {}
2831impl Copy for &usize {}
......@@ -39,7 +42,7 @@ pub trait FnOnce<Args: Tuple> {
3942}
4043
4144#[lang = "fn_mut"]
42pub trait FnMut<Args: Tuple> : FnOnce<Args> {
45pub trait FnMut<Args: Tuple>: FnOnce<Args> {
4346 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
4447}
4548
......@@ -64,7 +67,7 @@ fn arbitrary_black_box(ptr: &usize, _: &mut u32) -> Result<(), ()> {
6467
6568#[inline(never)]
6669#[no_mangle]
67fn call_through_fn_trait(a: &mut impl Fn<(), Output=()>) {
70fn call_through_fn_trait(a: &mut impl Fn<(), Output = ()>) {
6871 (*a)()
6972}
7073
......@@ -110,7 +113,10 @@ pub unsafe fn transmute_fn_ptr_to_data(x: fn()) -> *const () {
110113 transmute(x)
111114}
112115
113pub enum Either<T, U> { A(T), B(U) }
116pub enum Either<T, U> {
117 A(T),
118 B(U),
119}
114120
115121// Previously, we would codegen this as passing/returning a scalar pair of `{ i8, ptr }`,
116122// with the `ptr` field representing both `&i32` and `fn()` depending on the variant.
tests/codegen/binary-search-index-no-bound-check.rs+1-5
......@@ -11,11 +11,7 @@ pub fn binary_search_index_no_bounds_check(s: &[u8]) -> u8 {
1111 // CHECK-NOT: slice_start_index_len_fail
1212 // CHECK-NOT: slice_end_index_len_fail
1313 // CHECK-NOT: panic_bounds_check
14 if let Ok(idx) = s.binary_search(&b'\\') {
15 s[idx]
16 } else {
17 42
18 }
14 if let Ok(idx) = s.binary_search(&b'\\') { s[idx] } else { 42 }
1915}
2016
2117// Similarly, check that `partition_point` is known to return a valid fencepost.
tests/codegen/bool-cmp.rs+4-4
......@@ -10,9 +10,9 @@ use std::cmp::Ordering;
1010// CHECK-LABEL: @cmp_bool
1111#[no_mangle]
1212pub fn cmp_bool(a: bool, b: bool) -> Ordering {
13// LLVM 10 produces (zext a) + (sext b), but the final lowering is (zext a) - (zext b).
14// CHECK: zext i1
15// CHECK: {{z|s}}ext i1
16// CHECK: {{sub|add}} nsw
13 // LLVM 10 produces (zext a) + (sext b), but the final lowering is (zext a) - (zext b).
14 // CHECK: zext i1
15 // CHECK: {{z|s}}ext i1
16 // CHECK: {{sub|add}} nsw
1717 a.cmp(&b)
1818}
tests/codegen/branch-protection.rs+3-4
......@@ -12,12 +12,11 @@
1212#![feature(no_core, lang_items)]
1313#![no_core]
1414
15#[lang="sized"]
16trait Sized { }
15#[lang = "sized"]
16trait Sized {}
1717
1818// A basic test function.
19pub fn test() {
20}
19pub fn test() {}
2120
2221// BTI: !"branch-target-enforcement", i32 1
2322// BTI: !"sign-return-address", i32 0
tests/codegen/cast-target-abi.rs+6-7
......@@ -18,9 +18,12 @@
1818#![no_std]
1919#![no_core]
2020
21#[lang="sized"] trait Sized { }
22#[lang="freeze"] trait Freeze { }
23#[lang="copy"] trait Copy { }
21#[lang = "sized"]
22trait Sized {}
23#[lang = "freeze"]
24trait Freeze {}
25#[lang = "copy"]
26trait Copy {}
2427
2528// This struct will be passed as a single `i64` or `i32`.
2629// This may be (if `i64)) larger than the Rust layout, which is just `{ i16, i16 }`.
......@@ -104,7 +107,6 @@ pub unsafe fn return_twou16s() -> TwoU16s {
104107 // powerpc64: [[RETVAL:%.+]] = alloca [4 x i8], align 2
105108 // powerpc64: call void @returns_twou16s(ptr {{.+}} [[RETVAL]])
106109
107
108110 // The other targets copy the cast ABI type to an alloca.
109111
110112 // aarch64: [[ABI_ALLOCA:%.+]] = alloca [8 x i8], align [[ABI_ALIGN:8]]
......@@ -151,7 +153,6 @@ pub unsafe fn return_fiveu16s() -> FiveU16s {
151153
152154 // powerpc64: call void @returns_fiveu16s(ptr {{.+}} [[RET_PTR]])
153155
154
155156 // The other targets copy the cast ABI type to the sret pointer.
156157
157158 // aarch64: [[ABI_ALLOCA:%.+]] = alloca [16 x i8], align [[ABI_ALIGN:8]]
......@@ -199,7 +200,6 @@ pub unsafe fn return_doubledouble() -> DoubleDouble {
199200 // powerpc64: [[RETVAL:%.+]] = alloca [16 x i8], align 8
200201 // powerpc64: call void @returns_doubledouble(ptr {{.+}} [[RETVAL]])
201202
202
203203 // The other targets copy the cast ABI type to an alloca.
204204
205205 // aarch64: [[ABI_ALLOCA:%.+]] = alloca [16 x i8], align [[ABI_ALIGN:8]]
......@@ -266,7 +266,6 @@ pub unsafe fn return_doublefloat() -> DoubleFloat {
266266 // powerpc64: [[RETVAL:%.+]] = alloca [16 x i8], align 8
267267 // powerpc64: call void @returns_doublefloat(ptr {{.+}} [[RETVAL]])
268268
269
270269 // The other targets copy the cast ABI type to an alloca.
271270
272271 // aarch64: [[ABI_ALLOCA:%.+]] = alloca [16 x i8], align [[ABI_ALIGN:8]]
tests/codegen/cf-protection.rs+3-4
......@@ -13,12 +13,11 @@
1313#![feature(no_core, lang_items)]
1414#![no_core]
1515
16#[lang="sized"]
17trait Sized { }
16#[lang = "sized"]
17trait Sized {}
1818
1919// A basic test function.
20pub fn test() {
21}
20pub fn test() {}
2221
2322// undefined-NOT: !"cf-protection-branch"
2423// undefined-NOT: !"cf-protection-return"
tests/codegen/cffi/ffi-const.rs+5-2
......@@ -2,12 +2,15 @@
22#![crate_type = "lib"]
33#![feature(ffi_const)]
44
5pub fn bar() { unsafe { foo() } }
5pub fn bar() {
6 unsafe { foo() }
7}
68
79extern "C" {
810 // CHECK-LABEL: declare{{.*}}void @foo()
911 // CHECK-SAME: [[ATTRS:#[0-9]+]]
1012 // The attribute changed from `readnone` to `memory(none)` with LLVM 16.0.
1113 // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readnone|memory\(none\)}}{{.*}} }
12 #[ffi_const] pub fn foo();
14 #[ffi_const]
15 pub fn foo();
1316}
tests/codegen/cffi/ffi-out-of-bounds-loads.rs+6-3
......@@ -13,9 +13,12 @@
1313#![no_std]
1414#![no_core]
1515
16#[lang="sized"] trait Sized { }
17#[lang="freeze"] trait Freeze { }
18#[lang="copy"] trait Copy { }
16#[lang = "sized"]
17trait Sized {}
18#[lang = "freeze"]
19trait Freeze {}
20#[lang = "copy"]
21trait Copy {}
1922
2023#[repr(C)]
2124struct S {
tests/codegen/cffi/ffi-pure.rs+5-2
......@@ -2,12 +2,15 @@
22#![crate_type = "lib"]
33#![feature(ffi_pure)]
44
5pub fn bar() { unsafe { foo() } }
5pub fn bar() {
6 unsafe { foo() }
7}
68
79extern "C" {
810 // CHECK-LABEL: declare{{.*}}void @foo()
911 // CHECK-SAME: [[ATTRS:#[0-9]+]]
1012 // The attribute changed from `readonly` to `memory(read)` with LLVM 16.0.
1113 // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readonly|memory\(read\)}}{{.*}} }
12 #[ffi_pure] pub fn foo();
14 #[ffi_pure]
15 pub fn foo();
1316}
tests/codegen/cfguard-checks.rs+1-2
......@@ -4,8 +4,7 @@
44#![crate_type = "lib"]
55
66// A basic test function.
7pub fn test() {
8}
7pub fn test() {}
98
109// Ensure the module flag cfguard=2 is present
1110// CHECK: !"cfguard", i32 2
tests/codegen/cfguard-disabled.rs+1-2
......@@ -4,8 +4,7 @@
44#![crate_type = "lib"]
55
66// A basic test function.
7pub fn test() {
8}
7pub fn test() {}
98
109// Ensure the module flag cfguard is not present
1110// CHECK-NOT: !"cfguard"
tests/codegen/cfguard-nochecks.rs+1-2
......@@ -4,8 +4,7 @@
44#![crate_type = "lib"]
55
66// A basic test function.
7pub fn test() {
8}
7pub fn test() {}
98
109// Ensure the module flag cfguard=1 is present
1110// CHECK: !"cfguard", i32 1
tests/codegen/cfguard-non-msvc.rs+1-2
......@@ -4,8 +4,7 @@
44#![crate_type = "lib"]
55
66// A basic test function.
7pub fn test() {
8}
7pub fn test() {}
98
109// Ensure the cfguard module flag is not added for non-MSVC targets.
1110// CHECK-NOT: !"cfguard"
tests/codegen/coercions.rs+1-1
......@@ -7,7 +7,7 @@ static X: i32 = 5;
77// CHECK-LABEL: @raw_ptr_to_raw_ptr_noop
88// CHECK-NOT: alloca
99#[no_mangle]
10pub fn raw_ptr_to_raw_ptr_noop() -> *const i32{
10pub fn raw_ptr_to_raw_ptr_noop() -> *const i32 {
1111 &X as *const i32
1212}
1313
tests/codegen/constant-branch.rs+8-24
......@@ -8,18 +8,10 @@
88#[no_mangle]
99pub fn if_bool() {
1010 // CHECK: br label %{{.+}}
11 _ = if true {
12 0
13 } else {
14 1
15 };
11 _ = if true { 0 } else { 1 };
1612
1713 // CHECK: br label %{{.+}}
18 _ = if false {
19 0
20 } else {
21 1
22 };
14 _ = if false { 0 } else { 1 };
2315}
2416
2517// CHECK-LABEL: @if_constant_int_eq
......@@ -27,18 +19,10 @@ pub fn if_bool() {
2719pub fn if_constant_int_eq() {
2820 let val = 0;
2921 // CHECK: br label %{{.+}}
30 _ = if val == 0 {
31 0
32 } else {
33 1
34 };
22 _ = if val == 0 { 0 } else { 1 };
3523
3624 // CHECK: br label %{{.+}}
37 _ = if val == 1 {
38 0
39 } else {
40 1
41 };
25 _ = if val == 1 { 0 } else { 1 };
4226}
4327
4428// CHECK-LABEL: @if_constant_match
......@@ -48,19 +32,19 @@ pub fn if_constant_match() {
4832 _ = match 1 {
4933 1 => 2,
5034 2 => 3,
51 _ => 4
35 _ => 4,
5236 };
5337
5438 // CHECK: br label %{{.+}}
5539 _ = match 1 {
5640 2 => 3,
57 _ => 4
41 _ => 4,
5842 };
5943
6044 // CHECK: br label %[[MINUS1:.+]]
6145 _ = match -1 {
62 // CHECK: [[MINUS1]]:
63 // CHECK: store i32 1
46 // CHECK: [[MINUS1]]:
47 // CHECK: store i32 1
6448 -1 => 1,
6549 _ => 0,
6650 }
tests/codegen/coroutine-debug-msvc.rs+7-6
......@@ -11,7 +11,8 @@
1111use std::ops::Coroutine;
1212
1313fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
14 #[coroutine] || {
14 #[coroutine]
15 || {
1516 yield 0;
1617 let s = String::from("foo");
1718 yield 1;
......@@ -23,23 +24,23 @@ fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
2324// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<coroutine_debug_msvc::coroutine_test::coroutine_env$0>"
2425// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant0", scope: [[GEN]],
2526// For brevity, we only check the struct name and members of the last variant.
26// CHECK-SAME: file: [[FILE:![0-9]*]], line: 14,
27// CHECK-SAME: file: [[FILE:![0-9]*]], line: 15,
2728// CHECK-NOT: flags: DIFlagArtificial
2829// CHECK-SAME: )
2930// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant1", scope: [[GEN]],
30// CHECK-SAME: file: [[FILE]], line: 18,
31// CHECK-SAME: file: [[FILE]], line: 19,
3132// CHECK-NOT: flags: DIFlagArtificial
3233// CHECK-SAME: )
3334// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant2", scope: [[GEN]],
34// CHECK-SAME: file: [[FILE]], line: 18,
35// CHECK-SAME: file: [[FILE]], line: 19,
3536// CHECK-NOT: flags: DIFlagArtificial
3637// CHECK-SAME: )
3738// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant3", scope: [[GEN]],
38// CHECK-SAME: file: [[FILE]], line: 15,
39// CHECK-SAME: file: [[FILE]], line: 16,
3940// CHECK-NOT: flags: DIFlagArtificial
4041// CHECK-SAME: )
4142// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant4", scope: [[GEN]],
42// CHECK-SAME: file: [[FILE]], line: 17,
43// CHECK-SAME: file: [[FILE]], line: 18,
4344// CHECK-SAME: baseType: [[VARIANT_WRAPPER:![0-9]*]]
4445// CHECK-NOT: flags: DIFlagArtificial
4546// CHECK-SAME: )
tests/codegen/coroutine-debug.rs+7-6
......@@ -11,7 +11,8 @@
1111use std::ops::Coroutine;
1212
1313fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
14 #[coroutine] || {
14 #[coroutine]
15 || {
1516 yield 0;
1617 let s = String::from("foo");
1718 yield 1;
......@@ -26,26 +27,26 @@ fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
2627// CHECK-NOT: flags: DIFlagArtificial
2728// CHECK-SAME: discriminator: [[DISC:![0-9]*]]
2829// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "0", scope: [[VARIANT]],
29// CHECK-SAME: file: [[FILE:![0-9]*]], line: 14,
30// CHECK-SAME: file: [[FILE:![0-9]*]], line: 15,
3031// CHECK-NOT: flags: DIFlagArtificial
3132// CHECK-SAME: )
3233// CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "Unresumed", scope: [[GEN]],
3334// CHECK-NOT: flags: DIFlagArtificial
3435// CHECK-SAME: )
3536// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "1", scope: [[VARIANT]],
36// CHECK-SAME: file: [[FILE]], line: 18,
37// CHECK-SAME: file: [[FILE]], line: 19,
3738// CHECK-NOT: flags: DIFlagArtificial
3839// CHECK-SAME: )
3940// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "2", scope: [[VARIANT]],
40// CHECK-SAME: file: [[FILE]], line: 18,
41// CHECK-SAME: file: [[FILE]], line: 19,
4142// CHECK-NOT: flags: DIFlagArtificial
4243// CHECK-SAME: )
4344// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "3", scope: [[VARIANT]],
44// CHECK-SAME: file: [[FILE]], line: 15,
45// CHECK-SAME: file: [[FILE]], line: 16,
4546// CHECK-NOT: flags: DIFlagArtificial
4647// CHECK-SAME: )
4748// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "4", scope: [[VARIANT]],
48// CHECK-SAME: file: [[FILE]], line: 17,
49// CHECK-SAME: file: [[FILE]], line: 18,
4950// CHECK-NOT: flags: DIFlagArtificial
5051// CHECK-SAME: )
5152// CHECK: [[S1:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend1", scope: [[GEN]],
tests/codegen/dealloc-no-unwind.rs+7-3
......@@ -1,13 +1,17 @@
11//@ compile-flags: -O
22
3#![crate_type="lib"]
3#![crate_type = "lib"]
44
55struct A;
66
77impl Drop for A {
88 fn drop(&mut self) {
9 extern "C" { fn foo(); }
10 unsafe { foo(); }
9 extern "C" {
10 fn foo();
11 }
12 unsafe {
13 foo();
14 }
1115 }
1216}
1317
tests/codegen/debug-column.rs+3-2
......@@ -3,6 +3,7 @@
33//@ ignore-windows
44//@ compile-flags: -C debuginfo=2
55
6#[rustfmt::skip]
67fn main() {
78 unsafe {
89 // Column numbers are 1-based. Regression test for #65437.
......@@ -13,8 +14,8 @@ fn main() {
1314 // CHECK: call void @turtle(){{( #[0-9]+)?}}, !dbg [[B:!.*]]
1415/* ż */ turtle();
1516
16 // CHECK: [[A]] = !DILocation(line: 10, column: 9,
17 // CHECK: [[B]] = !DILocation(line: 14, column: 10,
17 // CHECK: [[A]] = !DILocation(line: 11, column: 9,
18 // CHECK: [[B]] = !DILocation(line: 15, column: 10,
1819 }
1920}
2021
tests/codegen/debug-compile-unit-path.rs+1-1
......@@ -3,7 +3,7 @@
33//
44// Ensure that we remap the compile unit directory and that we set it to the compilers current
55// working directory and not something else.
6#![crate_type="rlib"]
6#![crate_type = "rlib"]
77
88// CHECK-DAG: [[FILE:![0-9]*]] = !DIFile(filename: "/base/debug-compile-unit-path.rs{{.*}}", directory: "/cwd/")
99// CHECK-DAG: {{![0-9]*}} = distinct !DICompileUnit({{.*}}file: [[FILE]]
tests/codegen/debuginfo-generic-closure-env-names.rs+2-5
......@@ -46,7 +46,6 @@
4646// NONMSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "{closure_env#0}<debuginfo_generic_closure_env_names::Foo>", scope: ![[function_containing_closure_NAMESPACE]]
4747// MSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "closure_env$0<debuginfo_generic_closure_env_names::Foo>", scope: ![[function_containing_closure_NAMESPACE]]
4848
49
5049#![crate_type = "lib"]
5150use std::future::Future;
5251
......@@ -70,11 +69,9 @@ async fn generic_async_function<T: 'static>(x: T) -> T {
7069 x
7170}
7271
73fn generic_async_block<T: 'static>(x: T) -> impl Future<Output=T> {
72fn generic_async_block<T: 'static>(x: T) -> impl Future<Output = T> {
7473 static _X: u8 = 0; // Same as above
75 async move {
76 x
77 }
74 async move { x }
7875}
7976
8077pub fn instantiate_generics() {
tests/codegen/dllimports/auxiliary/wrapper.rs+2-2
......@@ -1,13 +1,13 @@
11//@ no-prefer-dynamic
22#![crate_type = "rlib"]
33
4#[link(name = "dummy", kind="dylib")]
4#[link(name = "dummy", kind = "dylib")]
55extern "C" {
66 pub fn dylib_func2(x: i32) -> i32;
77 pub static dylib_global2: i32;
88}
99
10#[link(name = "dummy", kind="static")]
10#[link(name = "dummy", kind = "static")]
1111extern "C" {
1212 pub fn static_func2(x: i32) -> i32;
1313 pub static static_global2: i32;
tests/codegen/dllimports/main.rs+3-3
......@@ -1,4 +1,4 @@
1 // This test is for *-windows-msvc only.
1// This test is for *-windows-msvc only.
22//@ only-windows
33//@ ignore-gnu
44
......@@ -20,13 +20,13 @@ extern crate wrapper;
2020// CHECK: declare noundef i32 @static_func1(i32 noundef)
2121// CHECK: declare noundef i32 @static_func2(i32 noundef)
2222
23#[link(name = "dummy", kind="dylib")]
23#[link(name = "dummy", kind = "dylib")]
2424extern "C" {
2525 pub fn dylib_func1(x: i32) -> i32;
2626 pub static dylib_global1: i32;
2727}
2828
29#[link(name = "dummy", kind="static")]
29#[link(name = "dummy", kind = "static")]
3030extern "C" {
3131 pub fn static_func1(x: i32) -> i32;
3232 pub static static_global1: i32;
tests/codegen/drop-in-place-noalias.rs+1-1
......@@ -3,7 +3,7 @@
33// Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`.
44// Note that non-Unpin types should not get `noalias`, matching &mut behavior.
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88use std::marker::PhantomPinned;
99
tests/codegen/drop.rs+13-15
......@@ -7,28 +7,26 @@ struct SomeUniqueName;
77
88impl Drop for SomeUniqueName {
99 #[inline(never)]
10 fn drop(&mut self) {
11 }
10 fn drop(&mut self) {}
1211}
1312
1413#[inline(never)]
15pub fn possibly_unwinding() {
16}
14pub fn possibly_unwinding() {}
1715
1816// CHECK-LABEL: @droppy
1917#[no_mangle]
2018pub fn droppy() {
21// Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
22// that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
23// regular function exit. We used to have problems with quadratic growths of drop calls in such
24// functions.
25// FIXME(eddyb) the `void @` forces a match on the instruction, instead of the
26// comment, that's `; call core::ptr::drop_in_place::<drop::SomeUniqueName>`
27// for the `v0` mangling, should switch to matching on that once `legacy` is gone.
28// CHECK-COUNT-6: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
29// CHECK-NOT: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
30// The next line checks for the } that ends the function definition
31// CHECK-LABEL: {{^[}]}}
19 // Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused,
20 // so that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for
21 // the regular function exit. We used to have problems with quadratic growths of drop calls in
22 // such functions.
23 // FIXME(eddyb) the `void @` forces a match on the instruction, instead of the
24 // comment, that's `; call core::ptr::drop_in_place::<drop::SomeUniqueName>`
25 // for the `v0` mangling, should switch to matching on that once `legacy` is gone.
26 // CHECK-COUNT-6: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
27 // CHECK-NOT: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
28 // The next line checks for the } that ends the function definition
29 // CHECK-LABEL: {{^[}]}}
3230 let _s = SomeUniqueName;
3331 possibly_unwinding();
3432 let _s = SomeUniqueName;
tests/codegen/dst-offset.rs+28-29
......@@ -3,7 +3,6 @@
33//@ compile-flags: -C no-prepopulate-passes -Copt-level=0
44
55#![crate_type = "lib"]
6
76#![feature(extern_types)]
87
98use std::ptr::addr_of;
......@@ -11,8 +10,7 @@ use std::ptr::addr_of;
1110// Hack to get the correct type for usize
1211// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
1312#[no_mangle]
14pub fn helper(_: usize) {
15}
13pub fn helper(_: usize) {}
1614
1715struct Dst<T: ?Sized> {
1816 x: u32,
......@@ -23,30 +21,31 @@ struct Dst<T: ?Sized> {
2321// CHECK: @dst_dyn_trait_offset(ptr align {{[0-9]+}} [[DATA_PTR:%.+]], ptr align {{[0-9]+}} [[VTABLE_PTR:%.+]])
2422#[no_mangle]
2523pub fn dst_dyn_trait_offset(s: &Dst<dyn Drop>) -> &dyn Drop {
26// The alignment of dyn trait is unknown, so we compute the offset based on align from the vtable.
27
28// CHECK: [[SIZE_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]]
29// CHECK: load [[USIZE]], ptr [[SIZE_PTR]]
30// CHECK: [[ALIGN_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]]
31// CHECK: load [[USIZE]], ptr [[ALIGN_PTR]]
32
33// CHECK: getelementptr inbounds i8, ptr [[DATA_PTR]]
34// CHECK-NEXT: insertvalue
35// CHECK-NEXT: insertvalue
36// CHECK-NEXT: ret
24 // The alignment of dyn trait is unknown, so we compute the offset based on align from the
25 // vtable.
26
27 // CHECK: [[SIZE_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]]
28 // CHECK: load [[USIZE]], ptr [[SIZE_PTR]]
29 // CHECK: [[ALIGN_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]]
30 // CHECK: load [[USIZE]], ptr [[ALIGN_PTR]]
31
32 // CHECK: getelementptr inbounds i8, ptr [[DATA_PTR]]
33 // CHECK-NEXT: insertvalue
34 // CHECK-NEXT: insertvalue
35 // CHECK-NEXT: ret
3736 &s.z
3837}
3938
4039// CHECK-LABEL: @dst_slice_offset
4140#[no_mangle]
4241pub fn dst_slice_offset(s: &Dst<[u16]>) -> &[u16] {
43// The alignment of [u16] is known, so we generate a GEP directly.
42 // The alignment of [u16] is known, so we generate a GEP directly.
4443
45// CHECK: start:
46// CHECK-NEXT: getelementptr inbounds i8, {{.+}}, [[USIZE]] 6
47// CHECK-NEXT: insertvalue
48// CHECK-NEXT: insertvalue
49// CHECK-NEXT: ret
44 // CHECK: start:
45 // CHECK-NEXT: getelementptr inbounds i8, {{.+}}, [[USIZE]] 6
46 // CHECK-NEXT: insertvalue
47 // CHECK-NEXT: insertvalue
48 // CHECK-NEXT: ret
5049 &s.z
5150}
5251
......@@ -60,25 +59,25 @@ struct PackedDstSlice {
6059// CHECK-LABEL: @packed_dst_slice_offset
6160#[no_mangle]
6261pub fn packed_dst_slice_offset(s: &PackedDstSlice) -> *const [u16] {
63// The alignment of [u16] is known, so we generate a GEP directly.
62 // The alignment of [u16] is known, so we generate a GEP directly.
6463
65// CHECK: start:
66// CHECK-NEXT: getelementptr inbounds i8, {{.+}}, [[USIZE]] 5
67// CHECK-NEXT: insertvalue
68// CHECK-NEXT: insertvalue
69// CHECK-NEXT: ret
64 // CHECK: start:
65 // CHECK-NEXT: getelementptr inbounds i8, {{.+}}, [[USIZE]] 5
66 // CHECK-NEXT: insertvalue
67 // CHECK-NEXT: insertvalue
68 // CHECK-NEXT: ret
7069 addr_of!(s.z)
7170}
7271
73extern {
72extern "C" {
7473 pub type Extern;
7574}
7675
7776// CHECK-LABEL: @dst_extern
7877#[no_mangle]
7978pub fn dst_extern(s: &Dst<Extern>) -> &Extern {
80// Computing the alignment of an extern type is currently unsupported and just panics.
79 // Computing the alignment of an extern type is currently unsupported and just panics.
8180
82// CHECK: call void @{{.+}}panic
81 // CHECK: call void @{{.+}}panic
8382 &s.z
8483}
tests/codegen/dst-vtable-align-nonzero.rs+10-4
......@@ -10,9 +10,15 @@ pub trait Trait {
1010 fn f(&self);
1111}
1212
13pub struct WrapperWithAlign1<T: ?Sized> { x: u8, y: T }
13pub struct WrapperWithAlign1<T: ?Sized> {
14 x: u8,
15 y: T,
16}
1417
15pub struct WrapperWithAlign2<T: ?Sized> { x: u16, y: T }
18pub struct WrapperWithAlign2<T: ?Sized> {
19 x: u16,
20 y: T,
21}
1622
1723pub struct Struct<W: ?Sized> {
1824 _field: i8,
......@@ -22,7 +28,7 @@ pub struct Struct<W: ?Sized> {
2228// CHECK-LABEL: @eliminates_runtime_check_when_align_1
2329#[no_mangle]
2430pub fn eliminates_runtime_check_when_align_1(
25 x: &Struct<WrapperWithAlign1<dyn Trait>>
31 x: &Struct<WrapperWithAlign1<dyn Trait>>,
2632) -> &WrapperWithAlign1<dyn Trait> {
2733 // CHECK: load [[USIZE:i[0-9]+]], {{.+}} !range [[RANGE_META:![0-9]+]]
2834 // CHECK-NOT: llvm.umax
......@@ -35,7 +41,7 @@ pub fn eliminates_runtime_check_when_align_1(
3541// CHECK-LABEL: @does_not_eliminate_runtime_check_when_align_2
3642#[no_mangle]
3743pub fn does_not_eliminate_runtime_check_when_align_2(
38 x: &Struct<WrapperWithAlign2<dyn Trait>>
44 x: &Struct<WrapperWithAlign2<dyn Trait>>,
3945) -> &WrapperWithAlign2<dyn Trait> {
4046 // CHECK: [[X0:%[0-9]+]] = load [[USIZE]], {{.+}} !range [[RANGE_META]]
4147 // CHECK: {{icmp|llvm.umax}}
tests/codegen/ehcontguard_disabled.rs+1-2
......@@ -3,8 +3,7 @@
33#![crate_type = "lib"]
44
55// A basic test function.
6pub fn test() {
7}
6pub fn test() {}
87
98// Ensure the module flag ehcontguard is not present
109// CHECK-NOT: !"ehcontguard"
tests/codegen/ehcontguard_enabled.rs+1-2
......@@ -3,8 +3,7 @@
33#![crate_type = "lib"]
44
55// A basic test function.
6pub fn test() {
7}
6pub fn test() {}
87
98// Ensure the module flag ehcontguard=1 is present
109// CHECK: !"ehcontguard", i32 1
tests/codegen/emcripten-catch-unwind.rs+11-6
......@@ -9,18 +9,23 @@
99#![no_std]
1010#![no_core]
1111
12#[lang="sized"] trait Sized { }
13#[lang="freeze"] trait Freeze { }
14#[lang="copy"] trait Copy { }
12#[lang = "sized"]
13trait Sized {}
14#[lang = "freeze"]
15trait Freeze {}
16#[lang = "copy"]
17trait Copy {}
1518
1619#[rustc_intrinsic]
17fn size_of<T>() -> usize { loop {} }
20fn size_of<T>() -> usize {
21 loop {}
22}
1823
1924extern "rust-intrinsic" {
2025 fn catch_unwind(
2126 try_fn: fn(_: *mut u8),
2227 data: *mut u8,
23 catch_fn: fn(_: *mut u8, _: *mut u8)
28 catch_fn: fn(_: *mut u8, _: *mut u8),
2429 ) -> i32;
2530}
2631
......@@ -36,7 +41,7 @@ pub fn ptr_size() -> usize {
3641pub unsafe fn test_catch_unwind(
3742 try_fn: fn(_: *mut u8),
3843 data: *mut u8,
39 catch_fn: fn(_: *mut u8, _: *mut u8)
44 catch_fn: fn(_: *mut u8, _: *mut u8),
4045) -> i32 {
4146 // CHECK: start:
4247 // CHECK: [[ALLOCA:%.*]] = alloca
tests/codegen/enable-lto-unit-splitting.rs+2-3
......@@ -2,9 +2,8 @@
22//
33//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsplit-lto-unit
44
5#![crate_type="lib"]
5#![crate_type = "lib"]
66
7pub fn foo() {
8}
7pub fn foo() {}
98
109// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1}
tests/codegen/enum/enum-bounds-check.rs+3-2
......@@ -3,7 +3,8 @@
33#![crate_type = "lib"]
44
55pub enum Foo {
6 A, B
6 A,
7 B,
78}
89
910// CHECK-LABEL: @lookup
......@@ -15,7 +16,7 @@ pub fn lookup(buf: &[u8; 2], f: Foo) -> u8 {
1516
1617pub enum Bar {
1718 A = 2,
18 B = 3
19 B = 3,
1920}
2021
2122// CHECK-LABEL: @lookup_unmodified
tests/codegen/enum/enum-debug-clike.rs+5-1
......@@ -17,7 +17,11 @@
1717#![allow(unused_variables)]
1818#![allow(unused_assignments)]
1919
20enum E { A, B, C }
20enum E {
21 A,
22 B,
23 C,
24}
2125
2226pub fn main() {
2327 let e = E::C;
tests/codegen/enum/enum-debug-niche.rs+6-1
......@@ -23,7 +23,12 @@
2323#![allow(unused_variables)]
2424#![allow(unused_assignments)]
2525
26enum E { A, B, C, D(bool) }
26enum E {
27 A,
28 B,
29 C,
30 D(bool),
31}
2732
2833pub fn main() {
2934 let e = E::D(true);
tests/codegen/enum/enum-debug-tagged.rs+4-1
......@@ -21,7 +21,10 @@
2121#![allow(unused_variables)]
2222#![allow(unused_assignments)]
2323
24enum E { A(u32), B(u32) }
24enum E {
25 A(u32),
26 B(u32),
27}
2528
2629pub fn main() {
2730 let e = E::A(23);
tests/codegen/enum/enum-match.rs+1
......@@ -50,6 +50,7 @@ pub fn match1(e: Enum1) -> u8 {
5050}
5151
5252// Case 2: Special cases don't apply.
53#[rustfmt::skip]
5354pub enum X {
5455 _2=2, _3, _4, _5, _6, _7, _8, _9, _10, _11,
5556 _12, _13, _14, _15, _16, _17, _18, _19, _20,
tests/codegen/enum/unreachable_enum_default_branch.rs+2-7
......@@ -22,8 +22,7 @@ const C: Int = Int(153);
2222// CHECK-NEXT: ret i1 [[SPEC_SELECT]]
2323#[no_mangle]
2424pub fn implicit_match(x: Int) -> bool {
25 (x >= A && x <= B)
26 || x == C
25 (x >= A && x <= B) || x == C
2726}
2827
2928// The code is from https://github.com/rust-lang/rust/issues/110097.
......@@ -35,9 +34,5 @@ pub fn implicit_match(x: Int) -> bool {
3534// CHECK-NEXT: ret
3635#[no_mangle]
3736pub fn if_let(val: Result<i32, ()>) -> Result<i32, ()> {
38 if let Ok(x) = val {
39 Ok(x)
40 } else {
41 Err(())
42 }
37 if let Ok(x) = val { Ok(x) } else { Err(()) }
4338}
tests/codegen/fatptr.rs+1-1
......@@ -7,6 +7,6 @@ pub trait T {}
77// CHECK-LABEL: @copy_fat_ptr
88#[no_mangle]
99pub fn copy_fat_ptr(x: &T) {
10// CHECK-NOT: extractvalue
10 // CHECK-NOT: extractvalue
1111 let x2 = x;
1212}
tests/codegen/float_math.rs+11-19
......@@ -3,48 +3,40 @@
33#![crate_type = "lib"]
44#![feature(core_intrinsics)]
55
6use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
6use std::intrinsics::{fadd_fast, fdiv_fast, fmul_fast, frem_fast, fsub_fast};
77
88// CHECK-LABEL: @add
99#[no_mangle]
1010pub fn add(x: f32, y: f32) -> f32 {
11// CHECK: fadd float
12// CHECK-NOT: fast
11 // CHECK: fadd float
12 // CHECK-NOT: fast
1313 x + y
1414}
1515
1616// CHECK-LABEL: @addition
1717#[no_mangle]
1818pub fn addition(x: f32, y: f32) -> f32 {
19// CHECK: fadd fast float
20 unsafe {
21 fadd_fast(x, y)
22 }
19 // CHECK: fadd fast float
20 unsafe { fadd_fast(x, y) }
2321}
2422
2523// CHECK-LABEL: @subtraction
2624#[no_mangle]
2725pub fn subtraction(x: f32, y: f32) -> f32 {
28// CHECK: fsub fast float
29 unsafe {
30 fsub_fast(x, y)
31 }
26 // CHECK: fsub fast float
27 unsafe { fsub_fast(x, y) }
3228}
3329
3430// CHECK-LABEL: @multiplication
3531#[no_mangle]
3632pub fn multiplication(x: f32, y: f32) -> f32 {
37// CHECK: fmul fast float
38 unsafe {
39 fmul_fast(x, y)
40 }
33 // CHECK: fmul fast float
34 unsafe { fmul_fast(x, y) }
4135}
4236
4337// CHECK-LABEL: @division
4438#[no_mangle]
4539pub fn division(x: f32, y: f32) -> f32 {
46// CHECK: fdiv fast float
47 unsafe {
48 fdiv_fast(x, y)
49 }
40 // CHECK: fdiv fast float
41 unsafe { fdiv_fast(x, y) }
5042}
tests/codegen/force-frame-pointers.rs+1-1
......@@ -1,6 +1,6 @@
11//@ compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y -Copt-level=0
22
3#![crate_type="lib"]
3#![crate_type = "lib"]
44
55// CHECK: attributes #{{.*}} "frame-pointer"="all"
66pub fn foo() {}
tests/codegen/force-no-unwind-tables.rs+1-1
......@@ -1,7 +1,7 @@
11//@ compile-flags: -C no-prepopulate-passes -C panic=abort -C force-unwind-tables=n
22//@ ignore-windows
33
4#![crate_type="lib"]
4#![crate_type = "lib"]
55
66// CHECK-LABEL: define{{.*}}void @foo
77// CHECK-NOT: attributes #{{.*}} uwtable
tests/codegen/force-unwind-tables.rs+1-1
......@@ -1,6 +1,6 @@
11//@ compile-flags: -C no-prepopulate-passes -C force-unwind-tables=y -Copt-level=0
22
3#![crate_type="lib"]
3#![crate_type = "lib"]
44
55// CHECK: attributes #{{.*}} uwtable
66pub fn foo() {}
tests/codegen/frame-pointer.rs+4-5
......@@ -13,13 +13,12 @@
1313
1414#![feature(no_core, lang_items)]
1515#![no_core]
16#[lang="sized"]
17trait Sized { }
18#[lang="copy"]
19trait Copy { }
16#[lang = "sized"]
17trait Sized {}
18#[lang = "copy"]
19trait Copy {}
2020impl Copy for u32 {}
2121
22
2322// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {
2423#[no_mangle]
2524pub fn peach(x: u32) -> u32 {
tests/codegen/function-arguments-noopt.rs+14-14
......@@ -7,63 +7,63 @@
77#![feature(rustc_attrs)]
88
99pub struct S {
10 _field: [i32; 8],
10 _field: [i32; 8],
1111}
1212
1313// CHECK: zeroext i1 @boolean(i1 zeroext %x)
1414#[no_mangle]
1515pub fn boolean(x: bool) -> bool {
16 x
16 x
1717}
1818
1919// CHECK-LABEL: @boolean_call
2020#[no_mangle]
2121pub fn boolean_call(x: bool, f: fn(bool) -> bool) -> bool {
22// CHECK: call zeroext i1 %f(i1 zeroext %x)
23 f(x)
22 // CHECK: call zeroext i1 %f(i1 zeroext %x)
23 f(x)
2424}
2525
2626// CHECK: align 4 ptr @borrow(ptr align 4 %x)
2727#[no_mangle]
2828pub fn borrow(x: &i32) -> &i32 {
29 x
29 x
3030}
3131
3232// CHECK: align 4 ptr @borrow_mut(ptr align 4 %x)
3333#[no_mangle]
3434pub fn borrow_mut(x: &mut i32) -> &mut i32 {
35 x
35 x
3636}
3737
3838// CHECK-LABEL: @borrow_call
3939#[no_mangle]
4040pub fn borrow_call(x: &i32, f: fn(&i32) -> &i32) -> &i32 {
41 // CHECK: call align 4 ptr %f(ptr align 4 %x)
42 f(x)
41 // CHECK: call align 4 ptr %f(ptr align 4 %x)
42 f(x)
4343}
4444
4545// CHECK: void @struct_(ptr sret([32 x i8]) align 4{{( %_0)?}}, ptr align 4 %x)
4646#[no_mangle]
4747pub fn struct_(x: S) -> S {
48 x
48 x
4949}
5050
5151// CHECK-LABEL: @struct_call
5252#[no_mangle]
5353pub fn struct_call(x: S, f: fn(S) -> S) -> S {
54 // CHECK: call void %f(ptr sret([32 x i8]) align 4{{( %_0)?}}, ptr align 4 %{{.+}})
55 f(x)
54 // CHECK: call void %f(ptr sret([32 x i8]) align 4{{( %_0)?}}, ptr align 4 %{{.+}})
55 f(x)
5656}
5757
5858// CHECK: { i1, i8 } @enum_(i1 zeroext %x.0, i8 %x.1)
5959#[no_mangle]
6060pub fn enum_(x: Option<u8>) -> Option<u8> {
61 x
61 x
6262}
6363
6464// CHECK-LABEL: @enum_call
6565#[no_mangle]
6666pub fn enum_call(x: Option<u8>, f: fn(Option<u8>) -> Option<u8>) -> Option<u8> {
67 // CHECK: call { i1, i8 } %f(i1 zeroext %x.0, i8 %x.1)
68 f(x)
67 // CHECK: call { i1, i8 } %f(i1 zeroext %x.0, i8 %x.1)
68 f(x)
6969}
tests/codegen/function-arguments.rs+52-80
......@@ -3,129 +3,123 @@
33#![feature(dyn_star)]
44#![feature(allocator_api)]
55
6use std::marker::PhantomPinned;
67use std::mem::MaybeUninit;
78use std::num::NonZero;
8use std::marker::PhantomPinned;
99use std::ptr::NonNull;
1010
1111pub struct S {
12 _field: [i32; 8],
12 _field: [i32; 8],
1313}
1414
1515pub struct UnsafeInner {
16 _field: std::cell::UnsafeCell<i16>,
16 _field: std::cell::UnsafeCell<i16>,
1717}
1818
1919pub struct NotUnpin {
20 _field: i32,
21 _marker: PhantomPinned,
20 _field: i32,
21 _marker: PhantomPinned,
2222}
2323
2424pub enum MyBool {
25 True,
26 False,
25 True,
26 False,
2727}
2828
2929// CHECK: noundef zeroext i1 @boolean(i1 noundef zeroext %x)
3030#[no_mangle]
3131pub fn boolean(x: bool) -> bool {
32 x
32 x
3333}
3434
3535// CHECK: i8 @maybeuninit_boolean(i8 %x)
3636#[no_mangle]
3737pub fn maybeuninit_boolean(x: MaybeUninit<bool>) -> MaybeUninit<bool> {
38 x
38 x
3939}
4040
4141// CHECK: noundef zeroext i1 @enum_bool(i1 noundef zeroext %x)
4242#[no_mangle]
4343pub fn enum_bool(x: MyBool) -> MyBool {
44 x
44 x
4545}
4646
4747// CHECK: i8 @maybeuninit_enum_bool(i8 %x)
4848#[no_mangle]
4949pub fn maybeuninit_enum_bool(x: MaybeUninit<MyBool>) -> MaybeUninit<MyBool> {
50 x
50 x
5151}
5252
5353// CHECK: noundef i32 @char(i32 noundef %x)
5454#[no_mangle]
5555pub fn char(x: char) -> char {
56 x
56 x
5757}
5858
5959// CHECK: i32 @maybeuninit_char(i32 %x)
6060#[no_mangle]
6161pub fn maybeuninit_char(x: MaybeUninit<char>) -> MaybeUninit<char> {
62 x
62 x
6363}
6464
6565// CHECK: noundef i64 @int(i64 noundef %x)
6666#[no_mangle]
6767pub fn int(x: u64) -> u64 {
68 x
68 x
6969}
7070
7171// CHECK: noundef i64 @nonzero_int(i64 noundef %x)
7272#[no_mangle]
7373pub fn nonzero_int(x: NonZero<u64>) -> NonZero<u64> {
74 x
74 x
7575}
7676
7777// CHECK: noundef i64 @option_nonzero_int(i64 noundef %x)
7878#[no_mangle]
7979pub fn option_nonzero_int(x: Option<NonZero<u64>>) -> Option<NonZero<u64>> {
80 x
80 x
8181}
8282
8383// CHECK: @readonly_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1)
8484// FIXME #25759 This should also have `nocapture`
8585#[no_mangle]
86pub fn readonly_borrow(_: &i32) {
87}
86pub fn readonly_borrow(_: &i32) {}
8887
8988// CHECK: noundef align 4 dereferenceable(4) ptr @readonly_borrow_ret()
9089#[no_mangle]
9190pub fn readonly_borrow_ret() -> &'static i32 {
92 loop {}
91 loop {}
9392}
9493
9594// CHECK: @static_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1)
9695// static borrow may be captured
9796#[no_mangle]
98pub fn static_borrow(_: &'static i32) {
99}
97pub fn static_borrow(_: &'static i32) {}
10098
10199// CHECK: @named_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1)
102100// borrow with named lifetime may be captured
103101#[no_mangle]
104pub fn named_borrow<'r>(_: &'r i32) {
105}
102pub fn named_borrow<'r>(_: &'r i32) {}
106103
107104// CHECK: @unsafe_borrow(ptr noundef nonnull align 2 %_1)
108105// unsafe interior means this isn't actually readonly and there may be aliases ...
109106#[no_mangle]
110pub fn unsafe_borrow(_: &UnsafeInner) {
111}
107pub fn unsafe_borrow(_: &UnsafeInner) {}
112108
113109// CHECK: @mutable_unsafe_borrow(ptr noalias noundef align 2 dereferenceable(2) %_1)
114110// ... unless this is a mutable borrow, those never alias
115111#[no_mangle]
116pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
117}
112pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {}
118113
119114// CHECK: @mutable_borrow(ptr noalias noundef align 4 dereferenceable(4) %_1)
120115// FIXME #25759 This should also have `nocapture`
121116#[no_mangle]
122pub fn mutable_borrow(_: &mut i32) {
123}
117pub fn mutable_borrow(_: &mut i32) {}
124118
125119// CHECK: noundef align 4 dereferenceable(4) ptr @mutable_borrow_ret()
126120#[no_mangle]
127121pub fn mutable_borrow_ret() -> &'static mut i32 {
128 loop {}
122 loop {}
129123}
130124
131125#[no_mangle]
......@@ -133,53 +127,44 @@ pub fn mutable_borrow_ret() -> &'static mut i32 {
133127// This one is *not* `noalias` because it might be self-referential.
134128// It is also not `dereferenceable` due to
135129// <https://github.com/rust-lang/unsafe-code-guidelines/issues/381>.
136pub fn mutable_notunpin_borrow(_: &mut NotUnpin) {
137}
130pub fn mutable_notunpin_borrow(_: &mut NotUnpin) {}
138131
139132// CHECK: @notunpin_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1)
140133// But `&NotUnpin` behaves perfectly normal.
141134#[no_mangle]
142pub fn notunpin_borrow(_: &NotUnpin) {
143}
135pub fn notunpin_borrow(_: &NotUnpin) {}
144136
145137// CHECK: @indirect_struct(ptr noalias nocapture noundef readonly align 4 dereferenceable(32) %_1)
146138#[no_mangle]
147pub fn indirect_struct(_: S) {
148}
139pub fn indirect_struct(_: S) {}
149140
150141// CHECK: @borrowed_struct(ptr noalias noundef readonly align 4 dereferenceable(32) %_1)
151142// FIXME #25759 This should also have `nocapture`
152143#[no_mangle]
153pub fn borrowed_struct(_: &S) {
154}
144pub fn borrowed_struct(_: &S) {}
155145
156146// CHECK: @option_borrow(ptr noalias noundef readonly align 4 dereferenceable_or_null(4) %x)
157147#[no_mangle]
158pub fn option_borrow(x: Option<&i32>) {
159}
148pub fn option_borrow(x: Option<&i32>) {}
160149
161150// CHECK: @option_borrow_mut(ptr noalias noundef align 4 dereferenceable_or_null(4) %x)
162151#[no_mangle]
163pub fn option_borrow_mut(x: Option<&mut i32>) {
164}
152pub fn option_borrow_mut(x: Option<&mut i32>) {}
165153
166154// CHECK: @raw_struct(ptr noundef %_1)
167155#[no_mangle]
168pub fn raw_struct(_: *const S) {
169}
156pub fn raw_struct(_: *const S) {}
170157
171158// CHECK: @raw_option_nonnull_struct(ptr noundef %_1)
172159#[no_mangle]
173pub fn raw_option_nonnull_struct(_: Option<NonNull<S>>) {
174}
175
160pub fn raw_option_nonnull_struct(_: Option<NonNull<S>>) {}
176161
177162// `Box` can get deallocated during execution of the function, so it should
178163// not get `dereferenceable`.
179164// CHECK: noundef nonnull align 4 ptr @_box(ptr noalias noundef nonnull align 4 %x)
180165#[no_mangle]
181166pub fn _box(x: Box<i32>) -> Box<i32> {
182 x
167 x
183168}
184169
185170// With a custom allocator, it should *not* have `noalias`. (See
......@@ -188,106 +173,93 @@ pub fn _box(x: Box<i32>) -> Box<i32> {
188173// CHECK: @_box_custom(ptr noundef nonnull align 4 %x.0, ptr noalias noundef nonnull readonly align 1 %x.1)
189174#[no_mangle]
190175pub fn _box_custom(x: Box<i32, &std::alloc::Global>) {
191 drop(x)
176 drop(x)
192177}
193178
194179// CHECK: noundef nonnull align 4 ptr @notunpin_box(ptr noundef nonnull align 4 %x)
195180#[no_mangle]
196181pub fn notunpin_box(x: Box<NotUnpin>) -> Box<NotUnpin> {
197 x
182 x
198183}
199184
200185// CHECK: @struct_return(ptr{{( dead_on_unwind)?}} noalias nocapture noundef{{( writable)?}} sret([32 x i8]) align 4 dereferenceable(32){{( %_0)?}})
201186#[no_mangle]
202187pub fn struct_return() -> S {
203 S {
204 _field: [0, 0, 0, 0, 0, 0, 0, 0]
205 }
188 S { _field: [0, 0, 0, 0, 0, 0, 0, 0] }
206189}
207190
208191// Hack to get the correct size for the length part in slices
209192// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1)
210193#[no_mangle]
211pub fn helper(_: usize) {
212}
194pub fn helper(_: usize) {}
213195
214196// CHECK: @slice(ptr noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1)
215197// FIXME #25759 This should also have `nocapture`
216198#[no_mangle]
217pub fn slice(_: &[u8]) {
218}
199pub fn slice(_: &[u8]) {}
219200
220201// CHECK: @mutable_slice(ptr noalias noundef nonnull align 1 %_1.0, [[USIZE]] noundef %_1.1)
221202// FIXME #25759 This should also have `nocapture`
222203#[no_mangle]
223pub fn mutable_slice(_: &mut [u8]) {
224}
204pub fn mutable_slice(_: &mut [u8]) {}
225205
226206// CHECK: @unsafe_slice(ptr noundef nonnull align 2 %_1.0, [[USIZE]] noundef %_1.1)
227207// unsafe interior means this isn't actually readonly and there may be aliases ...
228208#[no_mangle]
229pub fn unsafe_slice(_: &[UnsafeInner]) {
230}
209pub fn unsafe_slice(_: &[UnsafeInner]) {}
231210
232211// CHECK: @raw_slice(ptr noundef %_1.0, [[USIZE]] noundef %_1.1)
233212#[no_mangle]
234pub fn raw_slice(_: *const [u8]) {
235}
213pub fn raw_slice(_: *const [u8]) {}
236214
237215// CHECK: @str(ptr noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1)
238216// FIXME #25759 This should also have `nocapture`
239217#[no_mangle]
240pub fn str(_: &[u8]) {
241}
218pub fn str(_: &[u8]) {}
242219
243220// CHECK: @trait_borrow(ptr noundef nonnull align 1 %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
244221// FIXME #25759 This should also have `nocapture`
245222#[no_mangle]
246pub fn trait_borrow(_: &dyn Drop) {
247}
223pub fn trait_borrow(_: &dyn Drop) {}
248224
249225// CHECK: @option_trait_borrow(ptr noundef align 1 %x.0, ptr %x.1)
250226#[no_mangle]
251pub fn option_trait_borrow(x: Option<&dyn Drop>) {
252}
227pub fn option_trait_borrow(x: Option<&dyn Drop>) {}
253228
254229// CHECK: @option_trait_borrow_mut(ptr noundef align 1 %x.0, ptr %x.1)
255230#[no_mangle]
256pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) {
257}
231pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) {}
258232
259233// CHECK: @trait_raw(ptr noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
260234#[no_mangle]
261pub fn trait_raw(_: *const dyn Drop) {
262}
235pub fn trait_raw(_: *const dyn Drop) {}
263236
264237// CHECK: @trait_box(ptr noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
265238#[no_mangle]
266pub fn trait_box(_: Box<dyn Drop + Unpin>) {
267}
239pub fn trait_box(_: Box<dyn Drop + Unpin>) {}
268240
269241// CHECK: { ptr, ptr } @trait_option(ptr noalias noundef align 1 %x.0, ptr %x.1)
270242#[no_mangle]
271243pub fn trait_option(x: Option<Box<dyn Drop + Unpin>>) -> Option<Box<dyn Drop + Unpin>> {
272 x
244 x
273245}
274246
275247// CHECK: { ptr, [[USIZE]] } @return_slice(ptr noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] noundef %x.1)
276248#[no_mangle]
277249pub fn return_slice(x: &[u16]) -> &[u16] {
278 x
250 x
279251}
280252
281253// CHECK: { i16, i16 } @enum_id_1(i16 noundef %x.0, i16 %x.1)
282254#[no_mangle]
283255pub fn enum_id_1(x: Option<Result<u16, u16>>) -> Option<Result<u16, u16>> {
284 x
256 x
285257}
286258
287259// CHECK: { i1, i8 } @enum_id_2(i1 noundef zeroext %x.0, i8 %x.1)
288260#[no_mangle]
289261pub fn enum_id_2(x: Option<u8>) -> Option<u8> {
290 x
262 x
291263}
292264
293265// CHECK: { ptr, {{.+}} } @dyn_star(ptr noundef %x.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1)
......@@ -295,5 +267,5 @@ pub fn enum_id_2(x: Option<u8>) -> Option<u8> {
295267// so do like the `trait_box` test and just match on `{{.+}}` for the vtable.
296268#[no_mangle]
297269pub fn dyn_star(x: dyn* Drop) -> dyn* Drop {
298 x
270 x
299271}
tests/codegen/generic-debug.rs+1-1
......@@ -13,6 +13,6 @@
1313
1414pub struct Generic<Type>(Type);
1515
16fn main () {
16fn main() {
1717 let generic = Generic(10);
1818}
tests/codegen/inline-always-works-always.rs+1-1
......@@ -3,7 +3,7 @@
33//@[SIZE-OPT] compile-flags: -Copt-level=s
44//@[SPEED-OPT] compile-flags: -Copt-level=3
55
6#![crate_type="rlib"]
6#![crate_type = "rlib"]
77
88#[no_mangle]
99#[inline(always)]
tests/codegen/inline-debuginfo.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="rlib"]
1#![crate_type = "rlib"]
22//@ compile-flags: -Copt-level=3 -g
33//
44
tests/codegen/instrument-coverage/instrument-coverage.rs+2-4
......@@ -12,12 +12,10 @@
1212// CHECK: @__llvm_profile_filename = {{.*}}"default_%m_%p.profraw\00"{{.*}}
1313// CHECK: @__llvm_coverage_mapping
1414
15#![crate_type="lib"]
15#![crate_type = "lib"]
1616
1717#[inline(never)]
18fn some_function() {
19
20}
18fn some_function() {}
2119
2220pub fn some_other_function() {
2321 some_function();
tests/codegen/integer-cmp.rs+8-8
......@@ -10,19 +10,19 @@ use std::cmp::Ordering;
1010// CHECK-LABEL: @cmp_signed
1111#[no_mangle]
1212pub fn cmp_signed(a: i64, b: i64) -> Ordering {
13// CHECK: icmp slt
14// CHECK: icmp ne
15// CHECK: zext i1
16// CHECK: select i1
13 // CHECK: icmp slt
14 // CHECK: icmp ne
15 // CHECK: zext i1
16 // CHECK: select i1
1717 a.cmp(&b)
1818}
1919
2020// CHECK-LABEL: @cmp_unsigned
2121#[no_mangle]
2222pub fn cmp_unsigned(a: u32, b: u32) -> Ordering {
23// CHECK: icmp ult
24// CHECK: icmp ne
25// CHECK: zext i1
26// CHECK: select i1
23 // CHECK: icmp ult
24 // CHECK: icmp ne
25 // CHECK: zext i1
26 // CHECK: select i1
2727 a.cmp(&b)
2828}
tests/codegen/integer-overflow.rs+1-2
......@@ -2,7 +2,6 @@
22
33#![crate_type = "lib"]
44
5
65pub struct S1<'a> {
76 data: &'a [u8],
87 position: usize,
......@@ -12,7 +11,7 @@ pub struct S1<'a> {
1211#[no_mangle]
1312pub fn slice_no_index_order<'a>(s: &'a mut S1, n: usize) -> &'a [u8] {
1413 // CHECK-NOT: slice_index_order_fail
15 let d = &s.data[s.position..s.position+n];
14 let d = &s.data[s.position..s.position + n];
1615 s.position += n;
1716 return d;
1817}
tests/codegen/internalize-closures.rs+1-2
......@@ -1,7 +1,6 @@
11//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0
22
33pub fn main() {
4
54 // We want to make sure that closures get 'internal' linkage instead of
65 // 'weak_odr' when they are not shared between codegen units
76 // FIXME(eddyb) `legacy` mangling uses `{{closure}}`, while `v0`
......@@ -9,6 +8,6 @@ pub fn main() {
98 // CHECK-LABEL: ; internalize_closures::main::{{.*}}closure
109 // CHECK-NEXT: ; Function Attrs:
1110 // CHECK-NEXT: define internal
12 let c = |x:i32| { x + 1 };
11 let c = |x: i32| x + 1;
1312 let _ = c(1);
1413}
tests/codegen/intrinsic-no-unnamed-attr.rs+3-1
......@@ -8,5 +8,7 @@ extern "rust-intrinsic" {
88// CHECK: @llvm.sqrt.f32(float) #{{[0-9]*}}
99
1010fn main() {
11 unsafe { sqrtf32(0.0f32); }
11 unsafe {
12 sqrtf32(0.0f32);
13 }
1214}
tests/codegen/intrinsics/const_eval_select.rs+6-2
......@@ -6,10 +6,14 @@
66
77use std::intrinsics::const_eval_select;
88
9const fn foo(_: i32) -> i32 { 1 }
9const fn foo(_: i32) -> i32 {
10 1
11}
1012
1113#[no_mangle]
12pub fn hi(n: i32) -> i32 { n }
14pub fn hi(n: i32) -> i32 {
15 n
16}
1317
1418#[no_mangle]
1519pub unsafe fn hey() {
tests/codegen/intrinsics/likely.rs+3-11
......@@ -3,17 +3,13 @@
33#![crate_type = "lib"]
44#![feature(core_intrinsics)]
55
6use std::intrinsics::{likely,unlikely};
6use std::intrinsics::{likely, unlikely};
77
88#[no_mangle]
99pub fn check_likely(x: i32, y: i32) -> Option<i32> {
1010 unsafe {
1111 // CHECK: call i1 @llvm.expect.i1(i1 %{{.*}}, i1 true)
12 if likely(x == y) {
13 None
14 } else {
15 Some(x + y)
16 }
12 if likely(x == y) { None } else { Some(x + y) }
1713 }
1814}
1915
......@@ -21,10 +17,6 @@ pub fn check_likely(x: i32, y: i32) -> Option<i32> {
2117pub fn check_unlikely(x: i32, y: i32) -> Option<i32> {
2218 unsafe {
2319 // CHECK: call i1 @llvm.expect.i1(i1 %{{.*}}, i1 false)
24 if unlikely(x == y) {
25 None
26 } else {
27 Some(x + y)
28 }
20 if unlikely(x == y) { None } else { Some(x + y) }
2921 }
3022}
tests/codegen/intrinsics/prefetch.rs+3-2
......@@ -3,8 +3,9 @@
33#![crate_type = "lib"]
44#![feature(core_intrinsics)]
55
6use std::intrinsics::{prefetch_read_data, prefetch_write_data,
7 prefetch_read_instruction, prefetch_write_instruction};
6use std::intrinsics::{
7 prefetch_read_data, prefetch_read_instruction, prefetch_write_data, prefetch_write_instruction,
8};
89
910#[no_mangle]
1011pub fn check_prefetch_read_data(data: &[i8]) {
tests/codegen/is_val_statically_known.rs+1-1
......@@ -75,7 +75,7 @@ pub fn _slice_ref(a: &[u8]) -> i32 {
7575#[no_mangle]
7676pub fn _slice_ref_borrow() -> i32 {
7777 // CHECK: ret i32 6
78 _slice_ref(&[0;3])
78 _slice_ref(&[0; 3])
7979}
8080
8181// CHECK-LABEL: @_slice_ref_arg(
tests/codegen/issue-97217.rs+1-1
......@@ -16,6 +16,6 @@ pub fn issue97217() -> i32 {
1616 let v1 = vec![5, 6, 7];
1717 let v1_iter = v1.iter();
1818 let total: i32 = v1_iter.sum();
19 println!("{}",total);
19 println!("{}", total);
2020 total
2121}
tests/codegen/issues/issue-103327.rs+1-5
......@@ -9,9 +9,5 @@ pub fn test(a: i32, b: i32) -> bool {
99 let c1 = (a >= 0) && (a <= 10);
1010 let c2 = (b >= 0) && (b <= 20);
1111
12 if c1 & c2 {
13 a + 100 != b
14 } else {
15 true
16 }
12 if c1 & c2 { a + 100 != b } else { true }
1713}
tests/codegen/issues/issue-105386-ub-in-debuginfo.rs+2-1
......@@ -6,7 +6,8 @@ pub struct S([usize; 8]);
66
77#[no_mangle]
88pub fn outer_function(x: S, y: S) -> usize {
9 (#[inline(always)]|| {
9 (#[inline(always)]
10 || {
1011 let _z = x;
1112 y.0[0]
1213 })()
tests/codegen/issues/issue-119422.rs+2-2
......@@ -5,8 +5,8 @@
55//@ only-64bit (because the LLVM type of i64 for usize shows up)
66#![crate_type = "lib"]
77
8use core::ptr::NonNull;
98use core::num::NonZero;
9use core::ptr::NonNull;
1010
1111// CHECK-LABEL: @check_non_null
1212#[no_mangle]
......@@ -73,7 +73,7 @@ pub fn isize_try_from_i32(x: NonZero<i32>) -> NonZero<isize> {
7373
7474// CHECK-LABEL: @u64_from_nonzero_is_not_zero
7575#[no_mangle]
76pub fn u64_from_nonzero_is_not_zero(x: NonZero<u64>)->bool {
76pub fn u64_from_nonzero_is_not_zero(x: NonZero<u64>) -> bool {
7777 // CHECK-NOT: br
7878 // CHECK: ret i1 false
7979 // CHECK-NOT: br
tests/codegen/issues/issue-13018.rs+1-1
......@@ -6,6 +6,6 @@
66use std::rc::Rc;
77
88pub fn foo(t: &Rc<Vec<usize>>) {
9// CHECK-NOT: __rust_dealloc
9 // CHECK-NOT: __rust_dealloc
1010 drop(t.clone());
1111}
tests/codegen/issues/issue-32364.rs+2-3
......@@ -7,10 +7,9 @@
77struct Foo;
88
99impl Foo {
10// CHECK: define internal x86_stdcallcc void @{{.*}}foo{{.*}}()
10 // CHECK: define internal x86_stdcallcc void @{{.*}}foo{{.*}}()
1111 #[inline(never)]
12 pub extern "stdcall" fn foo<T>() {
13 }
12 pub extern "stdcall" fn foo<T>() {}
1413}
1514
1615fn main() {
tests/codegen/issues/issue-37945.rs+17-17
......@@ -9,26 +9,26 @@ use std::slice::Iter;
99
1010#[no_mangle]
1111pub fn is_empty_1(xs: Iter<f32>) -> bool {
12// CHECK-LABEL: @is_empty_1(
13// CHECK-NEXT: start:
14// CHECK-NEXT: [[A:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null
15// CHECK-NEXT: tail call void @llvm.assume(i1 [[A]])
16// The order between %xs.0 and %xs.1 on the next line doesn't matter
17// and different LLVM versions produce different order.
18// CHECK-NEXT: [[B:%.*]] = icmp eq ptr {{%xs.0, %xs.1|%xs.1, %xs.0}}
19// CHECK-NEXT: ret i1 [[B:%.*]]
20 {xs}.next().is_none()
12 // CHECK-LABEL: @is_empty_1(
13 // CHECK-NEXT: start:
14 // CHECK-NEXT: [[A:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null
15 // CHECK-NEXT: tail call void @llvm.assume(i1 [[A]])
16 // The order between %xs.0 and %xs.1 on the next line doesn't matter
17 // and different LLVM versions produce different order.
18 // CHECK-NEXT: [[B:%.*]] = icmp eq ptr {{%xs.0, %xs.1|%xs.1, %xs.0}}
19 // CHECK-NEXT: ret i1 [[B:%.*]]
20 { xs }.next().is_none()
2121}
2222
2323#[no_mangle]
2424pub fn is_empty_2(xs: Iter<f32>) -> bool {
25// CHECK-LABEL: @is_empty_2
26// CHECK-NEXT: start:
27// CHECK-NEXT: [[C:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null
28// CHECK-NEXT: tail call void @llvm.assume(i1 [[C]])
29// The order between %xs.0 and %xs.1 on the next line doesn't matter
30// and different LLVM versions produce different order.
31// CHECK-NEXT: [[D:%.*]] = icmp eq ptr {{%xs.0, %xs.1|%xs.1, %xs.0}}
32// CHECK-NEXT: ret i1 [[D:%.*]]
25 // CHECK-LABEL: @is_empty_2
26 // CHECK-NEXT: start:
27 // CHECK-NEXT: [[C:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null
28 // CHECK-NEXT: tail call void @llvm.assume(i1 [[C]])
29 // The order between %xs.0 and %xs.1 on the next line doesn't matter
30 // and different LLVM versions produce different order.
31 // CHECK-NEXT: [[D:%.*]] = icmp eq ptr {{%xs.0, %xs.1|%xs.1, %xs.0}}
32 // CHECK-NEXT: ret i1 [[D:%.*]]
3333 xs.map(|&x| x).next().is_none()
3434}
tests/codegen/issues/issue-45466.rs+1-1
......@@ -1,6 +1,6 @@
11//@ compile-flags: -O
22
3#![crate_type="rlib"]
3#![crate_type = "rlib"]
44
55// CHECK-LABEL: @memzero
66// CHECK-NOT: store
tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs+1-1
......@@ -3,7 +3,7 @@
33
44//@ compile-flags: -O
55
6#![crate_type="rlib"]
6#![crate_type = "rlib"]
77
88// CHECK-LABEL: @test
99#[no_mangle]
tests/codegen/issues/issue-47278.rs+4-2
......@@ -1,9 +1,11 @@
11// -C no-prepopulate-passes
2#![crate_type="staticlib"]
2#![crate_type = "staticlib"]
33
44#[repr(C)]
55pub struct Foo(u64);
66
77// CHECK: define {{.*}} @foo(
88#[no_mangle]
9pub extern "C" fn foo(_: Foo) -> Foo { loop {} }
9pub extern "C" fn foo(_: Foo) -> Foo {
10 loop {}
11}
tests/codegen/issues/issue-47442.rs+1-1
......@@ -4,7 +4,7 @@
44// CHECK-NOT: Unwind
55
66#![feature(test)]
7#![crate_type="rlib"]
7#![crate_type = "rlib"]
88
99extern crate test;
1010
tests/codegen/issues/issue-56267-2.rs+1-1
......@@ -1,6 +1,6 @@
11//@ compile-flags: -C no-prepopulate-passes
22
3#![crate_type="rlib"]
3#![crate_type = "rlib"]
44
55#[allow(dead_code)]
66pub struct Foo<T> {
tests/codegen/issues/issue-56267.rs+1-1
......@@ -1,6 +1,6 @@
11//@ compile-flags: -C no-prepopulate-passes
22
3#![crate_type="rlib"]
3#![crate_type = "rlib"]
44
55#[allow(dead_code)]
66pub struct Foo<T> {
tests/codegen/issues/issue-56927.rs+1-1
......@@ -1,6 +1,6 @@
11//@ compile-flags: -C no-prepopulate-passes
22
3#![crate_type="rlib"]
3#![crate_type = "rlib"]
44
55#[repr(align(16))]
66pub struct S {
tests/codegen/issues/issue-73031.rs+1-5
......@@ -12,11 +12,7 @@ pub enum All {
1212// CHECK-LABEL: @issue_73031
1313#[no_mangle]
1414pub fn issue_73031(a: &mut All, q: i32) -> i32 {
15 *a = if q == 5 {
16 All::Foo
17 } else {
18 All::Bar
19 };
15 *a = if q == 5 { All::Foo } else { All::Bar };
2016 match *a {
2117 // CHECK-NOT: panic
2218 All::None => panic!(),
tests/codegen/issues/issue-73258.rs+4-1
......@@ -7,7 +7,10 @@
77#[derive(Clone, Copy)]
88#[repr(u8)]
99pub enum Foo {
10 A, B, C, D,
10 A,
11 B,
12 C,
13 D,
1114}
1215
1316// CHECK-LABEL: @issue_73258(
tests/codegen/issues/issue-73338-effecient-cmp.rs+5-5
......@@ -4,7 +4,7 @@
44
55//@ compile-flags: -Copt-level=3
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
99#[repr(u32)]
1010#[derive(Copy, Clone, Eq, PartialEq, PartialOrd)]
......@@ -15,25 +15,25 @@ pub enum Foo {
1515}
1616
1717#[no_mangle]
18pub fn compare_less(a: Foo, b: Foo)->bool{
18pub fn compare_less(a: Foo, b: Foo) -> bool {
1919 // CHECK-NOT: br {{.*}}
2020 a < b
2121}
2222
2323#[no_mangle]
24pub fn compare_le(a: Foo, b: Foo)->bool{
24pub fn compare_le(a: Foo, b: Foo) -> bool {
2525 // CHECK-NOT: br {{.*}}
2626 a <= b
2727}
2828
2929#[no_mangle]
30pub fn compare_ge(a: Foo, b: Foo)->bool{
30pub fn compare_ge(a: Foo, b: Foo) -> bool {
3131 // CHECK-NOT: br {{.*}}
3232 a >= b
3333}
3434
3535#[no_mangle]
36pub fn compare_greater(a: Foo, b: Foo)->bool{
36pub fn compare_greater(a: Foo, b: Foo) -> bool {
3737 // CHECK-NOT: br {{.*}}
3838 a > b
3939}
tests/codegen/issues/issue-73396-bounds-check-after-position.rs+6-30
......@@ -12,11 +12,7 @@ pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
1212 // CHECK-NOT: slice_end_index_len_fail
1313 // CHECK-NOT: panic_bounds_check
1414 // CHECK-NOT: unreachable
15 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
16 &s[..idx]
17 } else {
18 s
19 }
15 if let Some(idx) = s.iter().position(|b| *b == b'\\') { &s[..idx] } else { s }
2016}
2117
2218// CHECK-LABEL: @position_slice_from_no_bounds_check
......@@ -27,11 +23,7 @@ pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
2723 // CHECK-NOT: slice_end_index_len_fail
2824 // CHECK-NOT: panic_bounds_check
2925 // CHECK-NOT: unreachable
30 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
31 &s[idx..]
32 } else {
33 s
34 }
26 if let Some(idx) = s.iter().position(|b| *b == b'\\') { &s[idx..] } else { s }
3527}
3628
3729// CHECK-LABEL: @position_index_no_bounds_check
......@@ -42,11 +34,7 @@ pub fn position_index_no_bounds_check(s: &[u8]) -> u8 {
4234 // CHECK-NOT: slice_end_index_len_fail
4335 // CHECK-NOT: panic_bounds_check
4436 // CHECK-NOT: unreachable
45 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
46 s[idx]
47 } else {
48 42
49 }
37 if let Some(idx) = s.iter().position(|b| *b == b'\\') { s[idx] } else { 42 }
5038}
5139// CHECK-LABEL: @rposition_slice_to_no_bounds_check
5240#[no_mangle]
......@@ -56,11 +44,7 @@ pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
5644 // CHECK-NOT: slice_end_index_len_fail
5745 // CHECK-NOT: panic_bounds_check
5846 // CHECK-NOT: unreachable
59 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
60 &s[..idx]
61 } else {
62 s
63 }
47 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') { &s[..idx] } else { s }
6448}
6549
6650// CHECK-LABEL: @rposition_slice_from_no_bounds_check
......@@ -71,11 +55,7 @@ pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
7155 // CHECK-NOT: slice_end_index_len_fail
7256 // CHECK-NOT: panic_bounds_check
7357 // CHECK-NOT: unreachable
74 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
75 &s[idx..]
76 } else {
77 s
78 }
58 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') { &s[idx..] } else { s }
7959}
8060
8161// CHECK-LABEL: @rposition_index_no_bounds_check
......@@ -86,9 +66,5 @@ pub fn rposition_index_no_bounds_check(s: &[u8]) -> u8 {
8666 // CHECK-NOT: slice_end_index_len_fail
8767 // CHECK-NOT: panic_bounds_check
8868 // CHECK-NOT: unreachable
89 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
90 s[idx]
91 } else {
92 42
93 }
69 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') { s[idx] } else { 42 }
9470}
tests/codegen/issues/issue-75546.rs+3-1
......@@ -9,7 +9,9 @@ pub fn issue_75546() {
99 let mut i = 1u32;
1010 while i < u32::MAX {
1111 // CHECK-NOT: panic
12 if i == 0 { panic!(); }
12 if i == 0 {
13 panic!();
14 }
1315 i += 1;
1416 }
1517}
tests/codegen/issues/issue-77812.rs+1-1
......@@ -10,7 +10,7 @@ pub enum Variant {
1010 Two,
1111}
1212
13extern {
13extern "C" {
1414 fn exf1();
1515 fn exf2();
1616}
tests/codegen/issues/issue-84268.rs+1-3
......@@ -17,7 +17,5 @@ pub struct M([i32; 4]);
1717pub fn is_infinite(v: V) -> M {
1818 // CHECK: fabs
1919 // CHECK: cmp oeq
20 unsafe {
21 simd_eq(simd_fabs(v), V([f32::INFINITY; 4]))
22 }
20 unsafe { simd_eq(simd_fabs(v), V([f32::INFINITY; 4])) }
2321}
tests/codegen/issues/issue-96497-slice-size-nowrap.rs+1-1
......@@ -4,7 +4,7 @@
44
55//@ compile-flags: -O
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
99// CHECK-LABEL: @simple_size_of_nowrap
1010#[no_mangle]
tests/codegen/issues/issue-99960.rs+1-5
......@@ -6,9 +6,5 @@
66pub fn test(dividend: i64, divisor: i64) -> Option<i64> {
77 // CHECK-LABEL: @test(
88 // CHECK-NOT: panic
9 if dividend > i64::min_value() && divisor != 0 {
10 Some(dividend / divisor)
11 } else {
12 None
13 }
9 if dividend > i64::min_value() && divisor != 0 { Some(dividend / divisor) } else { None }
1410}
tests/codegen/lib-optimizations/iter-sum.rs-1
......@@ -2,7 +2,6 @@
22//@ only-x86_64 (vectorization varies between architectures)
33#![crate_type = "lib"]
44
5
65// Ensure that slice + take + sum gets vectorized.
76// Currently this relies on the slice::Iter::try_fold implementation
87// CHECK-LABEL: @slice_take_sum
tests/codegen/lifetime_start_end.rs+8-8
......@@ -8,27 +8,27 @@ pub fn test() {
88 let a = 0u8;
99 &a; // keep variable in an alloca
1010
11// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, ptr %a)
11 // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, ptr %a)
1212
1313 {
1414 let b = &Some(a);
1515 &b; // keep variable in an alloca
1616
17// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{.*}})
17 // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{.*}})
1818
19// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{.*}})
19 // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{.*}})
2020
21// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{.*}})
21 // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{.*}})
2222
23// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{.*}})
23 // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{.*}})
2424 }
2525
2626 let c = 1u8;
2727 &c; // keep variable in an alloca
2828
29// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, ptr %c)
29 // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, ptr %c)
3030
31// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, ptr %c)
31 // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, ptr %c)
3232
33// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, ptr %a)
33 // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, ptr %a)
3434}
tests/codegen/link-dead-code.rs+9-3
......@@ -8,15 +8,21 @@
88// CHECK-LABEL: ; link_dead_code::const_fn
99// CHECK-NEXT: ; Function Attrs:
1010// CHECK-NEXT: define hidden
11const fn const_fn() -> i32 { 1 }
11const fn const_fn() -> i32 {
12 1
13}
1214
1315// CHECK-LABEL: ; link_dead_code::inline_fn
1416// CHECK-NEXT: ; Function Attrs:
1517// CHECK-NEXT: define hidden
1618#[inline]
17fn inline_fn() -> i32 { 2 }
19fn inline_fn() -> i32 {
20 2
21}
1822
1923// CHECK-LABEL: ; link_dead_code::private_fn
2024// CHECK-NEXT: ; Function Attrs:
2125// CHECK-NEXT: define hidden
22fn private_fn() -> i32 { 3 }
26fn private_fn() -> i32 {
27 3
28}
tests/codegen/link_section.rs+1-1
......@@ -16,7 +16,7 @@ pub static VAR1: u32 = 0x01000000;
1616
1717pub enum E {
1818 A(u32),
19 B(f32)
19 B(f32),
2020}
2121
2222// CHECK: @VAR2 = {{(dso_local )?}}constant {{.*}}, section ".test_two"
tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs+6-3
......@@ -6,9 +6,12 @@
66#![no_std]
77#![no_core]
88
9#[lang="sized"] trait Sized { }
10#[lang="freeze"] trait Freeze { }
11#[lang="copy"] trait Copy { }
9#[lang = "sized"]
10trait Sized {}
11#[lang = "freeze"]
12trait Freeze {}
13#[lang = "copy"]
14trait Copy {}
1215
1316// CHECK: define void @f_fpr_tracking(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, i8 noundef zeroext %i)
1417#[no_mangle]
tests/codegen/lto-removes-invokes.rs+2-2
......@@ -10,8 +10,8 @@ fn main() {
1010fn foo() {
1111 let _a = Box::new(3);
1212 bar();
13// CHECK-LABEL: define dso_local void @foo
14// CHECK: call void @bar
13 // CHECK-LABEL: define dso_local void @foo
14 // CHECK: call void @bar
1515}
1616
1717#[inline(never)]
tests/codegen/macos/i686-macosx-deployment-target.rs+6-6
......@@ -8,12 +8,12 @@
88#![feature(no_core, lang_items)]
99#![no_core]
1010
11#[lang="sized"]
12trait Sized { }
13#[lang="freeze"]
14trait Freeze { }
15#[lang="copy"]
16trait Copy { }
11#[lang = "sized"]
12trait Sized {}
13#[lang = "freeze"]
14trait Freeze {}
15#[lang = "copy"]
16trait Copy {}
1717
1818#[repr(C)]
1919pub struct Bool {
tests/codegen/macos/i686-no-macosx-deployment-target.rs+6-6
......@@ -8,12 +8,12 @@
88#![feature(no_core, lang_items)]
99#![no_core]
1010
11#[lang="sized"]
12trait Sized { }
13#[lang="freeze"]
14trait Freeze { }
15#[lang="copy"]
16trait Copy { }
11#[lang = "sized"]
12trait Sized {}
13#[lang = "freeze"]
14trait Freeze {}
15#[lang = "copy"]
16trait Copy {}
1717
1818#[repr(C)]
1919pub struct Bool {
tests/codegen/macos/x86_64-macosx-deployment-target.rs+6-6
......@@ -8,12 +8,12 @@
88#![feature(no_core, lang_items)]
99#![no_core]
1010
11#[lang="sized"]
12trait Sized { }
13#[lang="freeze"]
14trait Freeze { }
15#[lang="copy"]
16trait Copy { }
11#[lang = "sized"]
12trait Sized {}
13#[lang = "freeze"]
14trait Freeze {}
15#[lang = "copy"]
16trait Copy {}
1717
1818#[repr(C)]
1919pub struct Bool {
tests/codegen/macos/x86_64-no-macosx-deployment-target.rs+6-6
......@@ -8,12 +8,12 @@
88#![feature(no_core, lang_items)]
99#![no_core]
1010
11#[lang="sized"]
12trait Sized { }
13#[lang="freeze"]
14trait Freeze { }
15#[lang="copy"]
16trait Copy { }
11#[lang = "sized"]
12trait Sized {}
13#[lang = "freeze"]
14trait Freeze {}
15#[lang = "copy"]
16trait Copy {}
1717
1818#[repr(C)]
1919pub struct Bool {
tests/codegen/match-optimized.rs+17-17
......@@ -11,23 +11,23 @@ pub enum E {
1111// CHECK-LABEL: @exhaustive_match
1212#[no_mangle]
1313pub fn exhaustive_match(e: E) -> u8 {
14// CHECK: switch{{.*}}, label %[[OTHERWISE:[a-zA-Z0-9_]+]] [
15// CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[A:[a-zA-Z0-9_]+]]
16// CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[B:[a-zA-Z0-9_]+]]
17// CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[C:[a-zA-Z0-9_]+]]
18// CHECK-NEXT: ]
19// CHECK: [[OTHERWISE]]:
20// CHECK-NEXT: unreachable
21//
22// CHECK: [[A]]:
23// CHECK-NEXT: store i8 0, ptr %_0, align 1
24// CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]]
25// CHECK: [[B]]:
26// CHECK-NEXT: store i8 1, ptr %_0, align 1
27// CHECK-NEXT: br label %[[EXIT]]
28// CHECK: [[C]]:
29// CHECK-NEXT: store i8 3, ptr %_0, align 1
30// CHECK-NEXT: br label %[[EXIT]]
14 // CHECK: switch{{.*}}, label %[[OTHERWISE:[a-zA-Z0-9_]+]] [
15 // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[A:[a-zA-Z0-9_]+]]
16 // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[B:[a-zA-Z0-9_]+]]
17 // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[C:[a-zA-Z0-9_]+]]
18 // CHECK-NEXT: ]
19 // CHECK: [[OTHERWISE]]:
20 // CHECK-NEXT: unreachable
21 //
22 // CHECK: [[A]]:
23 // CHECK-NEXT: store i8 0, ptr %_0, align 1
24 // CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]]
25 // CHECK: [[B]]:
26 // CHECK-NEXT: store i8 1, ptr %_0, align 1
27 // CHECK-NEXT: br label %[[EXIT]]
28 // CHECK: [[C]]:
29 // CHECK-NEXT: store i8 3, ptr %_0, align 1
30 // CHECK-NEXT: br label %[[EXIT]]
3131 match e {
3232 E::A => 0,
3333 E::B => 1,
tests/codegen/match-optimizes-away.rs+12-3
......@@ -1,11 +1,20 @@
11//
22//@ compile-flags: -O
3#![crate_type="lib"]
3#![crate_type = "lib"]
44
5pub enum Three { A, B, C }
5pub enum Three {
6 A,
7 B,
8 C,
9}
610
711#[repr(u16)]
8pub enum Four { A, B, C, D }
12pub enum Four {
13 A,
14 B,
15 C,
16 D,
17}
918
1019#[no_mangle]
1120pub fn three_valued(x: Three) -> Three {
tests/codegen/mir_zst_stores.rs+3-1
......@@ -4,7 +4,9 @@
44use std::marker::PhantomData;
55
66#[derive(Copy, Clone)]
7struct Zst { phantom: PhantomData<Zst> }
7struct Zst {
8 phantom: PhantomData<Zst>,
9}
810
911// CHECK-LABEL: @mir
1012// CHECK-NOT: store{{.*}}undef
tests/codegen/naked-fn/naked-functions.rs+2-5
......@@ -14,8 +14,7 @@ pub unsafe extern "C" fn naked_empty() {
1414 // CHECK-NEXT: {{.+}}:
1515 // CHECK-NEXT: call void asm
1616 // CHECK-NEXT: unreachable
17 asm!("ret",
18 options(noreturn));
17 asm!("ret", options(noreturn));
1918}
2019
2120// CHECK: Function Attrs: naked
......@@ -26,7 +25,5 @@ pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize
2625 // CHECK-NEXT: {{.+}}:
2726 // CHECK-NEXT: call void asm
2827 // CHECK-NEXT: unreachable
29 asm!("lea rax, [rdi + rsi]",
30 "ret",
31 options(noreturn));
28 asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
3229}
tests/codegen/no-assumes-on-casts.rs+4-4
......@@ -6,14 +6,14 @@
66#[no_mangle]
77pub fn fna(a: i16) -> i32 {
88 a as i32
9// CHECK-NOT: assume
10// CHECK: sext
9 // CHECK-NOT: assume
10 // CHECK: sext
1111}
1212
1313// CHECK-LABEL: fnb
1414#[no_mangle]
1515pub fn fnb(a: u16) -> u32 {
1616 a as u32
17// CHECK-NOT: assume
18// CHECK: zext
17 // CHECK-NOT: assume
18 // CHECK: zext
1919}
tests/codegen/noalias-freeze.rs+3-1
......@@ -8,7 +8,9 @@
88
99#![crate_type = "lib"]
1010
11fn project<T>(x: &(T,)) -> &T { &x.0 }
11fn project<T>(x: &(T,)) -> &T {
12 &x.0
13}
1214
1315fn dummy() {}
1416
tests/codegen/noalias-unpin.rs+1-1
......@@ -4,7 +4,7 @@
44
55pub struct SelfRef {
66 self_ref: *mut SelfRef,
7 _pin: std::marker::PhantomPinned
7 _pin: std::marker::PhantomPinned,
88}
99
1010// CHECK-LABEL: @test_self_ref(
tests/codegen/non-terminate/infinite-recursion.rs-1
......@@ -1,7 +1,6 @@
11//@ compile-flags: -C opt-level=3
22
33#![crate_type = "lib"]
4
54#![allow(unconditional_recursion)]
65
76// CHECK-LABEL: @infinite_recursion
tests/codegen/noreturnflag.rs+2-2
......@@ -4,7 +4,7 @@
44
55#[no_mangle]
66pub fn foo() -> ! {
7// CHECK: @foo() unnamed_addr #0
7 // CHECK: @foo() unnamed_addr #0
88 loop {}
99}
1010
......@@ -12,7 +12,7 @@ pub enum EmptyEnum {}
1212
1313#[no_mangle]
1414pub fn bar() -> EmptyEnum {
15// CHECK: @bar() unnamed_addr #0
15 // CHECK: @bar() unnamed_addr #0
1616 loop {}
1717}
1818
tests/codegen/nounwind.rs+3-3
......@@ -10,7 +10,7 @@ extern crate nounwind;
1010#[no_mangle]
1111pub fn foo() {
1212 nounwind::bar();
13// CHECK: @foo() unnamed_addr #0
14// CHECK: @bar() unnamed_addr #0
15// CHECK: attributes #0 = { {{.*}}nounwind{{.*}} }
13 // CHECK: @foo() unnamed_addr #0
14 // CHECK: @bar() unnamed_addr #0
15 // CHECK: attributes #0 = { {{.*}}nounwind{{.*}} }
1616}
tests/codegen/optimize-attr-1.rs+1-1
......@@ -4,7 +4,7 @@
44//@[SPEED-OPT] compile-flags: -Copt-level=3 -Ccodegen-units=1
55
66#![feature(optimize_attribute)]
7#![crate_type="rlib"]
7#![crate_type = "rlib"]
88
99// CHECK-LABEL: define{{.*}}i32 @nothing
1010// CHECK-SAME: [[NOTHING_ATTRS:#[0-9]+]]
tests/codegen/option-niche-eq.rs+1-1
......@@ -4,8 +4,8 @@
44
55extern crate core;
66use core::cmp::Ordering;
7use core::ptr::NonNull;
87use core::num::NonZero;
8use core::ptr::NonNull;
99
1010// CHECK-LABEL: @non_zero_eq
1111#[no_mangle]
tests/codegen/packed.rs+18-18
......@@ -6,20 +6,20 @@
66#[repr(packed)]
77pub struct Packed1 {
88 dealign: u8,
9 data: u32
9 data: u32,
1010}
1111
1212#[repr(packed(2))]
1313pub struct Packed2 {
1414 dealign: u8,
15 data: u32
15 data: u32,
1616}
1717
1818// CHECK-LABEL: @write_pkd1
1919#[no_mangle]
2020pub fn write_pkd1(pkd: &mut Packed1) -> u32 {
21// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 1
22// CHECK: store i32 42, ptr %{{.*}}, align 1
21 // CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 1
22 // CHECK: store i32 42, ptr %{{.*}}, align 1
2323 let result = pkd.data;
2424 pkd.data = 42;
2525 result
......@@ -28,8 +28,8 @@ pub fn write_pkd1(pkd: &mut Packed1) -> u32 {
2828// CHECK-LABEL: @write_pkd2
2929#[no_mangle]
3030pub fn write_pkd2(pkd: &mut Packed2) -> u32 {
31// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 2
32// CHECK: store i32 42, ptr %{{.*}}, align 2
31 // CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 2
32 // CHECK: store i32 42, ptr %{{.*}}, align 2
3333 let result = pkd.data;
3434 pkd.data = 42;
3535 result
......@@ -39,21 +39,21 @@ pub struct Array([i32; 8]);
3939#[repr(packed)]
4040pub struct BigPacked1 {
4141 dealign: u8,
42 data: Array
42 data: Array,
4343}
4444
4545#[repr(packed(2))]
4646pub struct BigPacked2 {
4747 dealign: u8,
48 data: Array
48 data: Array,
4949}
5050
5151// CHECK-LABEL: @call_pkd1
5252#[no_mangle]
5353pub fn call_pkd1(f: fn() -> Array) -> BigPacked1 {
54// CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca [32 x i8]
55// CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
56// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false)
54 // CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca [32 x i8]
55 // CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
56 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false)
5757 // check that calls whose destination is a field of a packed struct
5858 // go through an alloca rather than calling the function with an
5959 // unaligned destination.
......@@ -63,9 +63,9 @@ pub fn call_pkd1(f: fn() -> Array) -> BigPacked1 {
6363// CHECK-LABEL: @call_pkd2
6464#[no_mangle]
6565pub fn call_pkd2(f: fn() -> Array) -> BigPacked2 {
66// CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca [32 x i8]
67// CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
68// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false)
66 // CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca [32 x i8]
67 // CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
68 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false)
6969 // check that calls whose destination is a field of a packed struct
7070 // go through an alloca rather than calling the function with an
7171 // unaligned destination.
......@@ -119,14 +119,14 @@ pub struct Packed2Pair(u8, u32);
119119// CHECK-LABEL: @pkd1_pair
120120#[no_mangle]
121121pub fn pkd1_pair(pair1: &mut Packed1Pair, pair2: &mut Packed1Pair) {
122// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, i{{[0-9]+}} 5, i1 false)
122 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, i{{[0-9]+}} 5, i1 false)
123123 *pair2 = *pair1;
124124}
125125
126126// CHECK-LABEL: @pkd2_pair
127127#[no_mangle]
128128pub fn pkd2_pair(pair1: &mut Packed2Pair, pair2: &mut Packed2Pair) {
129// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 2 %{{.*}}, i{{[0-9]+}} 6, i1 false)
129 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 2 %{{.*}}, i{{[0-9]+}} 6, i1 false)
130130 *pair2 = *pair1;
131131}
132132
......@@ -141,13 +141,13 @@ pub struct Packed2NestedPair((u32, u32));
141141// CHECK-LABEL: @pkd1_nested_pair
142142#[no_mangle]
143143pub fn pkd1_nested_pair(pair1: &mut Packed1NestedPair, pair2: &mut Packed1NestedPair) {
144// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, i{{[0-9]+}} 8, i1 false)
144 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, i{{[0-9]+}} 8, i1 false)
145145 *pair2 = *pair1;
146146}
147147
148148// CHECK-LABEL: @pkd2_nested_pair
149149#[no_mangle]
150150pub fn pkd2_nested_pair(pair1: &mut Packed2NestedPair, pair2: &mut Packed2NestedPair) {
151// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 2 %{{.*}}, i{{[0-9]+}} 8, i1 false)
151 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 2 %{{.*}}, i{{[0-9]+}} 8, i1 false)
152152 *pair2 = *pair1;
153153}
tests/codegen/panic-abort-windows.rs+2-4
......@@ -8,11 +8,9 @@
88// CHECK: Function Attrs: nounwind uwtable
99// CHECK-NEXT: define void @normal_uwtable()
1010#[no_mangle]
11pub fn normal_uwtable() {
12}
11pub fn normal_uwtable() {}
1312
1413// CHECK: Function Attrs: nounwind uwtable
1514// CHECK-NEXT: define void @extern_uwtable()
1615#[no_mangle]
17pub extern fn extern_uwtable() {
18}
16pub extern "C" fn extern_uwtable() {}
tests/codegen/personality_lifetimes.rs+3-5
......@@ -3,19 +3,17 @@
33
44//@ compile-flags: -O -C no-prepopulate-passes
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88struct S;
99
1010impl Drop for S {
1111 #[inline(never)]
12 fn drop(&mut self) {
13 }
12 fn drop(&mut self) {}
1413}
1514
1615#[inline(never)]
17fn might_unwind() {
18}
16fn might_unwind() {}
1917
2018// CHECK-LABEL: @test
2119#[no_mangle]
tests/codegen/pgo-instrumentation.rs+2-4
......@@ -10,12 +10,10 @@
1010// CHECK-DAG: @__profd_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = {{.*}}global
1111// CHECK: @__llvm_profile_filename = {{.*}}"default_%m.profraw\00"{{.*}}
1212
13#![crate_type="lib"]
13#![crate_type = "lib"]
1414
1515#[inline(never)]
16fn some_function() {
17
18}
16fn some_function() {}
1917
2018pub fn some_other_function() {
2119 some_function();
tests/codegen/pic-relocation-model.rs+4-4
......@@ -5,15 +5,15 @@
55// CHECK: define i8 @call_foreign_fn()
66#[no_mangle]
77pub fn call_foreign_fn() -> u8 {
8 unsafe {
9 foreign_fn()
10 }
8 unsafe { foreign_fn() }
119}
1210
1311// (Allow but do not require `zeroext` here, because it is not worth effort to
1412// spell out which targets have it and which ones do not; see rust#97800.)
1513
1614// CHECK: declare{{( zeroext)?}} i8 @foreign_fn()
17extern "C" {fn foreign_fn() -> u8;}
15extern "C" {
16 fn foreign_fn() -> u8;
17}
1818
1919// CHECK: !{i32 {{[78]}}, !"PIC Level", i32 2}
tests/codegen/pie-relocation-model.rs+4-4
......@@ -8,15 +8,15 @@
88// CHECK: define dso_local i8 @call_foreign_fn()
99#[no_mangle]
1010pub fn call_foreign_fn() -> u8 {
11 unsafe {
12 foreign_fn()
13 }
11 unsafe { foreign_fn() }
1412}
1513
1614// External functions are still marked as non-dso_local, since we don't know if the symbol
1715// is defined in the binary or in the shared library.
1816// CHECK: declare zeroext i8 @foreign_fn()
19extern "C" {fn foreign_fn() -> u8;}
17extern "C" {
18 fn foreign_fn() -> u8;
19}
2020
2121// CHECK: !{i32 {{[78]}}, !"PIC Level", i32 2}
2222// CHECK: !{i32 7, !"PIE Level", i32 2}
tests/codegen/powerpc64le-struct-align-128.rs+18-12
......@@ -8,12 +8,12 @@
88#![crate_type = "lib"]
99#![no_core]
1010
11#[lang="sized"]
12trait Sized { }
13#[lang="freeze"]
14trait Freeze { }
15#[lang="copy"]
16trait Copy { }
11#[lang = "sized"]
12trait Sized {}
13#[lang = "freeze"]
14trait Freeze {}
15#[lang = "copy"]
16trait Copy {}
1717
1818#[repr(C)]
1919pub struct Align8 {
......@@ -23,7 +23,7 @@ pub struct Align8 {
2323
2424#[repr(transparent)]
2525pub struct Transparent8 {
26 a: Align8
26 a: Align8,
2727}
2828
2929#[repr(C)]
......@@ -45,7 +45,7 @@ pub struct Align16 {
4545
4646#[repr(transparent)]
4747pub struct Transparent16 {
48 a: Align16
48 a: Align16,
4949}
5050
5151#[repr(C)]
......@@ -69,7 +69,7 @@ pub struct Align32 {
6969
7070#[repr(transparent)]
7171pub struct Transparent32 {
72 a: Align32
72 a: Align32,
7373}
7474
7575#[repr(C)]
......@@ -83,9 +83,15 @@ extern "C" {
8383}
8484
8585pub unsafe fn main(
86 a1: Align8, a2: Transparent8, a3: Wrapped8,
87 b1: Align16, b2: Transparent16, b3: Wrapped16,
88 c1: Align32, c2: Transparent32, c3: Wrapped32,
86 a1: Align8,
87 a2: Transparent8,
88 a3: Wrapped8,
89 b1: Align16,
90 b2: Transparent16,
91 b3: Wrapped16,
92 c1: Align32,
93 c2: Transparent32,
94 c3: Wrapped32,
8995) {
9096 test_8(a1, a2, a3);
9197 test_16(b1, b2, b3);
tests/codegen/precondition-checks.rs+1-3
......@@ -21,7 +21,5 @@ use std::ptr::NonNull;
2121#[no_mangle]
2222pub unsafe fn nonnull_new(ptr: *mut u8) -> NonNull<u8> {
2323 // CHECK: ; call core::ptr::non_null::NonNull<T>::new_unchecked
24 unsafe {
25 NonNull::new_unchecked(ptr)
26 }
24 unsafe { NonNull::new_unchecked(ptr) }
2725}
tests/codegen/refs.rs+4-5
......@@ -5,17 +5,16 @@
55// Hack to get the correct size for the length part in slices
66// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
77#[no_mangle]
8pub fn helper(_: usize) {
9}
8pub fn helper(_: usize) {}
109
1110// CHECK-LABEL: @ref_dst
1211#[no_mangle]
1312pub fn ref_dst(s: &[u8]) {
1413 // We used to generate an extra alloca and memcpy to ref the dst, so check that we copy
1514 // directly to the alloca for "x"
16// CHECK: store ptr %s.0, {{.*}} %x
17// CHECK: [[X1:%[0-9]+]] = getelementptr inbounds i8, {{.*}} %x, {{i32 4|i64 8}}
18// CHECK: store [[USIZE]] %s.1, {{.*}} [[X1]]
15 // CHECK: store ptr %s.0, {{.*}} %x
16 // CHECK: [[X1:%[0-9]+]] = getelementptr inbounds i8, {{.*}} %x, {{i32 4|i64 8}}
17 // CHECK: store [[USIZE]] %s.1, {{.*}} [[X1]]
1918
2019 let x = &*s;
2120 &x; // keep variable in an alloca
tests/codegen/repr/transparent-imm-array.rs+30-13
......@@ -26,15 +26,17 @@
2626#![no_std]
2727#![no_core]
2828
29#[lang="sized"] trait Sized { }
30#[lang="freeze"] trait Freeze { }
31#[lang="copy"] trait Copy { }
29#[lang = "sized"]
30trait Sized {}
31#[lang = "freeze"]
32trait Freeze {}
33#[lang = "copy"]
34trait Copy {}
3235
3336impl Copy for [u32; 16] {}
3437impl Copy for BigS {}
3538impl Copy for BigU {}
3639
37
3840#[repr(C)]
3941pub struct BigS([u32; 16]);
4042
......@@ -53,20 +55,27 @@ pub enum TeBigS {
5355
5456// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], [16 x i32]
5557#[no_mangle]
56pub extern fn test_BigS(_: BigS) -> BigS { loop {} }
58pub extern "C" fn test_BigS(_: BigS) -> BigS {
59 loop {}
60}
5761
5862// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32]
5963#[no_mangle]
60pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
64pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS {
65 loop {}
66}
6167
6268// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32]
6369#[no_mangle]
64pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
70pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS {
71 loop {}
72}
6573
6674// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32]
6775#[no_mangle]
68pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
69
76pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS {
77 loop {}
78}
7079
7180#[repr(C)]
7281pub union BigU {
......@@ -88,16 +97,24 @@ pub enum TeBigU {
8897
8998// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], [16 x i32]
9099#[no_mangle]
91pub extern fn test_BigU(_: BigU) -> BigU { loop {} }
100pub extern "C" fn test_BigU(_: BigU) -> BigU {
101 loop {}
102}
92103
93104// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32]
94105#[no_mangle]
95pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
106pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU {
107 loop {}
108}
96109
97110// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32]
98111#[no_mangle]
99pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
112pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU {
113 loop {}
114}
100115
101116// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32]
102117#[no_mangle]
103pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }
118pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU {
119 loop {}
120}
tests/codegen/repr/transparent-mips64.rs+30-12
......@@ -13,9 +13,12 @@
1313#![no_std]
1414#![no_core]
1515
16#[lang="sized"] trait Sized { }
17#[lang="freeze"] trait Freeze { }
18#[lang="copy"] trait Copy { }
16#[lang = "sized"]
17trait Sized {}
18#[lang = "freeze"]
19trait Freeze {}
20#[lang = "copy"]
21trait Copy {}
1922
2023impl Copy for [u32; 16] {}
2124impl Copy for BigS {}
......@@ -39,20 +42,27 @@ pub enum TeBigS {
3942
4043// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], [8 x i64]
4144#[no_mangle]
42pub extern fn test_BigS(_: BigS) -> BigS { loop {} }
45pub extern "C" fn test_BigS(_: BigS) -> BigS {
46 loop {}
47}
4348
4449// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64]
4550#[no_mangle]
46pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
51pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS {
52 loop {}
53}
4754
4855// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64]
4956#[no_mangle]
50pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
57pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS {
58 loop {}
59}
5160
5261// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64]
5362#[no_mangle]
54pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
55
63pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS {
64 loop {}
65}
5666
5767#[repr(C)]
5868pub union BigU {
......@@ -74,16 +84,24 @@ pub enum TeBigU {
7484
7585// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], [8 x i64]
7686#[no_mangle]
77pub extern fn test_BigU(_: BigU) -> BigU { loop {} }
87pub extern "C" fn test_BigU(_: BigU) -> BigU {
88 loop {}
89}
7890
7991// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64]
8092#[no_mangle]
81pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
93pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU {
94 loop {}
95}
8296
8397// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64]
8498#[no_mangle]
85pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
99pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU {
100 loop {}
101}
86102
87103// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64]
88104#[no_mangle]
89pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }
105pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU {
106 loop {}
107}
tests/codegen/repr/transparent-sparc64.rs+30-13
......@@ -8,15 +8,17 @@
88#![no_std]
99#![no_core]
1010
11#[lang="sized"] trait Sized { }
12#[lang="freeze"] trait Freeze { }
13#[lang="copy"] trait Copy { }
11#[lang = "sized"]
12trait Sized {}
13#[lang = "freeze"]
14trait Freeze {}
15#[lang = "copy"]
16trait Copy {}
1417
1518impl Copy for [u32; 16] {}
1619impl Copy for BigS {}
1720impl Copy for BigU {}
1821
19
2022#[repr(C)]
2123pub struct BigS([u32; 16]);
2224
......@@ -37,26 +39,33 @@ pub enum TeBigS {
3739// CHECK-NOT: byval
3840// CHECK-SAME: %{{[0-9a-z_]+}})
3941#[no_mangle]
40pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} }
42pub extern "C" fn test_BigS(_: BigS) -> BigS {
43 loop {}
44}
4145
4246// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr
4347// CHECK-NOT: byval
4448// CHECK-SAME: %{{[0-9a-z_]+}})
4549#[no_mangle]
46pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
50pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS {
51 loop {}
52}
4753
4854// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr
4955// CHECK-NOT: byval
5056// CHECK-SAME: %{{[0-9a-z_]+}})
5157#[no_mangle]
52pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
58pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS {
59 loop {}
60}
5361
5462// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr
5563// CHECK-NOT: byval
5664// CHECK-SAME: %{{[0-9a-z_]+}})
5765#[no_mangle]
58pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
59
66pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS {
67 loop {}
68}
6069
6170#[repr(C)]
6271pub union BigU {
......@@ -80,22 +89,30 @@ pub enum TeBigU {
8089// CHECK-NOT: byval
8190// CHECK-SAME: %{{[0-9a-z_]+}})
8291#[no_mangle]
83pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} }
92pub extern "C" fn test_BigU(_: BigU) -> BigU {
93 loop {}
94}
8495
8596// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr
8697// CHECK-NOT: byval
8798// CHECK-SAME: %{{[0-9a-z_]+}})
8899#[no_mangle]
89pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
100pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU {
101 loop {}
102}
90103
91104// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr
92105// CHECK-NOT: byval
93106// CHECK-SAME: %{{[0-9a-z_]+}})
94107#[no_mangle]
95pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
108pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU {
109 loop {}
110}
96111
97112// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr
98113// CHECK-NOT: byval
99114// CHECK-SAME: %{{[0-9a-z_]+}})
100115#[no_mangle]
101pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }
116pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU {
117 loop {}
118}
tests/codegen/repr/transparent-struct-ptr.rs+30-13
......@@ -22,15 +22,17 @@
2222#![no_std]
2323#![no_core]
2424
25#[lang="sized"] trait Sized { }
26#[lang="freeze"] trait Freeze { }
27#[lang="copy"] trait Copy { }
25#[lang = "sized"]
26trait Sized {}
27#[lang = "freeze"]
28trait Freeze {}
29#[lang = "copy"]
30trait Copy {}
2831
2932impl Copy for [u32; 16] {}
3033impl Copy for BigS {}
3134impl Copy for BigU {}
3235
33
3436#[repr(C)]
3537pub struct BigS([u32; 16]);
3638
......@@ -49,20 +51,27 @@ pub enum TeBigS {
4951
5052// CHECK: define{{.*}}void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], ptr [[BIGS_ARG_ATTRS1:.*]] byval([64 x i8]) [[BIGS_ARG_ATTRS2:.*]])
5153#[no_mangle]
52pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} }
54pub extern "C" fn test_BigS(_: BigS) -> BigS {
55 loop {}
56}
5357
5458// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval([64 x i8]) [[BIGS_ARG_ATTRS2:.*]])
5559#[no_mangle]
56pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
60pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS {
61 loop {}
62}
5763
5864// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval([64 x i8]) [[BIGS_ARG_ATTRS2:.*]])
5965#[no_mangle]
60pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
66pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS {
67 loop {}
68}
6169
6270// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval([64 x i8]) [[BIGS_ARG_ATTRS2]])
6371#[no_mangle]
64pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
65
72pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS {
73 loop {}
74}
6675
6776#[repr(C)]
6877pub union BigU {
......@@ -84,16 +93,24 @@ pub enum TeBigU {
8493
8594// CHECK: define{{.*}}void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1:.*]] byval([64 x i8]) [[BIGU_ARG_ATTRS2:.*]])
8695#[no_mangle]
87pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} }
96pub extern "C" fn test_BigU(_: BigU) -> BigU {
97 loop {}
98}
8899
89100// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval([64 x i8]) [[BIGU_ARG_ATTRS2]])
90101#[no_mangle]
91pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
102pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU {
103 loop {}
104}
92105
93106// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval([64 x i8]) [[BIGU_ARG_ATTRS2]])
94107#[no_mangle]
95pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
108pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU {
109 loop {}
110}
96111
97112// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval([64 x i8]) [[BIGU_ARG_ATTRS2]])
98113#[no_mangle]
99pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }
114pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU {
115 loop {}
116}
tests/codegen/repr/transparent-sysv64.rs+17-6
......@@ -13,19 +13,28 @@
1313#![no_std]
1414#![no_core]
1515
16#[lang="sized"] trait Sized { }
17#[lang="freeze"] trait Freeze { }
18#[lang="copy"] trait Copy { }
16#[lang = "sized"]
17trait Sized {}
18#[lang = "freeze"]
19trait Freeze {}
20#[lang = "copy"]
21trait Copy {}
1922
2023#[repr(C)]
21pub struct Rgb8 { r: u8, g: u8, b: u8 }
24pub struct Rgb8 {
25 r: u8,
26 g: u8,
27 b: u8,
28}
2229
2330#[repr(transparent)]
2431pub struct Rgb8Wrap(Rgb8);
2532
2633// CHECK: i24 @test_Rgb8Wrap(i24{{( %0)?}})
2734#[no_mangle]
28pub extern "sysv64" fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} }
35pub extern "sysv64" fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap {
36 loop {}
37}
2938
3039#[repr(C)]
3140pub union FloatBits {
......@@ -38,4 +47,6 @@ pub struct SmallUnion(FloatBits);
3847
3948// CHECK: i32 @test_SmallUnion(i32{{( %0)?}})
4049#[no_mangle]
41pub extern "sysv64" fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} }
50pub extern "sysv64" fn test_SmallUnion(_: SmallUnion) -> SmallUnion {
51 loop {}
52}
tests/codegen/repr/transparent.rs+69-25
......@@ -8,7 +8,7 @@
88// For RISCV: see codegen/riscv-abi
99// For LoongArch: see codegen/loongarch-abi
1010
11#![crate_type="lib"]
11#![crate_type = "lib"]
1212#![feature(repr_simd, transparent_unions)]
1313
1414use std::marker::PhantomData;
......@@ -24,83 +24,112 @@ pub struct F32(f32);
2424
2525// CHECK: define{{.*}}float @test_F32(float noundef %_1)
2626#[no_mangle]
27pub extern "C" fn test_F32(_: F32) -> F32 { loop {} }
27pub extern "C" fn test_F32(_: F32) -> F32 {
28 loop {}
29}
2830
2931#[repr(transparent)]
3032pub struct Ptr(*mut u8);
3133
3234// CHECK: define{{.*}}ptr @test_Ptr(ptr noundef %_1)
3335#[no_mangle]
34pub extern "C" fn test_Ptr(_: Ptr) -> Ptr { loop {} }
36pub extern "C" fn test_Ptr(_: Ptr) -> Ptr {
37 loop {}
38}
3539
3640#[repr(transparent)]
3741pub struct WithZst(u64, Zst1);
3842
3943// CHECK: define{{.*}}i64 @test_WithZst(i64 noundef %_1)
4044#[no_mangle]
41pub extern "C" fn test_WithZst(_: WithZst) -> WithZst { loop {} }
45pub extern "C" fn test_WithZst(_: WithZst) -> WithZst {
46 loop {}
47}
4248
4349#[repr(transparent)]
4450pub struct WithZeroSizedArray(*const f32, [i8; 0]);
4551
4652// CHECK: define{{.*}}ptr @test_WithZeroSizedArray(ptr noundef %_1)
4753#[no_mangle]
48pub extern "C" fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray { loop {} }
54pub extern "C" fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray {
55 loop {}
56}
4957
5058#[repr(transparent)]
5159pub struct Generic<T>(T);
5260
5361// CHECK: define{{.*}}double @test_Generic(double noundef %_1)
5462#[no_mangle]
55pub extern "C" fn test_Generic(_: Generic<f64>) -> Generic<f64> { loop {} }
63pub extern "C" fn test_Generic(_: Generic<f64>) -> Generic<f64> {
64 loop {}
65}
5666
5767#[repr(transparent)]
5868pub struct GenericPlusZst<T>(T, Zst2);
5969
6070#[repr(u8)]
61pub enum Bool { True, False, FileNotFound }
71pub enum Bool {
72 True,
73 False,
74 FileNotFound,
75}
6276
6377// CHECK: define{{( dso_local)?}} noundef{{( zeroext)?}} i8 @test_Gpz(i8 noundef{{( zeroext)?}} %_1)
6478#[no_mangle]
65pub extern "C" fn test_Gpz(_: GenericPlusZst<Bool>) -> GenericPlusZst<Bool> { loop {} }
79pub extern "C" fn test_Gpz(_: GenericPlusZst<Bool>) -> GenericPlusZst<Bool> {
80 loop {}
81}
6682
6783#[repr(transparent)]
6884pub struct LifetimePhantom<'a, T: 'a>(*const T, PhantomData<&'a T>);
6985
7086// CHECK: define{{.*}}ptr @test_LifetimePhantom(ptr noundef %_1)
7187#[no_mangle]
72pub extern "C" fn test_LifetimePhantom(_: LifetimePhantom<i16>) -> LifetimePhantom<i16> { loop {} }
88pub extern "C" fn test_LifetimePhantom(_: LifetimePhantom<i16>) -> LifetimePhantom<i16> {
89 loop {}
90}
7391
7492// This works despite current alignment resrictions because PhantomData is always align(1)
7593#[repr(transparent)]
76pub struct UnitPhantom<T, U> { val: T, unit: PhantomData<U> }
94pub struct UnitPhantom<T, U> {
95 val: T,
96 unit: PhantomData<U>,
97}
7798
7899pub struct Px;
79100
80101// CHECK: define{{.*}}float @test_UnitPhantom(float noundef %_1)
81102#[no_mangle]
82pub extern "C" fn test_UnitPhantom(_: UnitPhantom<f32, Px>) -> UnitPhantom<f32, Px> { loop {} }
103pub extern "C" fn test_UnitPhantom(_: UnitPhantom<f32, Px>) -> UnitPhantom<f32, Px> {
104 loop {}
105}
83106
84107#[repr(transparent)]
85108pub struct TwoZsts(Zst1, i8, Zst2);
86109
87110// CHECK: define{{( dso_local)?}} noundef{{( signext)?}} i8 @test_TwoZsts(i8 noundef{{( signext)?}} %_1)
88111#[no_mangle]
89pub extern "C" fn test_TwoZsts(_: TwoZsts) -> TwoZsts { loop {} }
112pub extern "C" fn test_TwoZsts(_: TwoZsts) -> TwoZsts {
113 loop {}
114}
90115
91116#[repr(transparent)]
92117pub struct Nested1(Zst2, Generic<f64>);
93118
94119// CHECK: define{{.*}}double @test_Nested1(double noundef %_1)
95120#[no_mangle]
96pub extern "C" fn test_Nested1(_: Nested1) -> Nested1 { loop {} }
121pub extern "C" fn test_Nested1(_: Nested1) -> Nested1 {
122 loop {}
123}
97124
98125#[repr(transparent)]
99126pub struct Nested2(Nested1, Zst1);
100127
101128// CHECK: define{{.*}}double @test_Nested2(double noundef %_1)
102129#[no_mangle]
103pub extern "C" fn test_Nested2(_: Nested2) -> Nested2 { loop {} }
130pub extern "C" fn test_Nested2(_: Nested2) -> Nested2 {
131 loop {}
132}
104133
105134#[repr(simd)]
106135struct f32x4(f32, f32, f32, f32);
......@@ -110,35 +139,47 @@ pub struct Vector(f32x4);
110139
111140// CHECK: define{{.*}}<4 x float> @test_Vector(<4 x float> %_1)
112141#[no_mangle]
113pub extern "C" fn test_Vector(_: Vector) -> Vector { loop {} }
142pub extern "C" fn test_Vector(_: Vector) -> Vector {
143 loop {}
144}
114145
115trait Mirror { type It: ?Sized; }
116impl<T: ?Sized> Mirror for T { type It = Self; }
146trait Mirror {
147 type It: ?Sized;
148}
149impl<T: ?Sized> Mirror for T {
150 type It = Self;
151}
117152
118153#[repr(transparent)]
119154pub struct StructWithProjection(<f32 as Mirror>::It);
120155
121156// CHECK: define{{.*}}float @test_Projection(float noundef %_1)
122157#[no_mangle]
123pub extern "C" fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} }
158pub extern "C" fn test_Projection(_: StructWithProjection) -> StructWithProjection {
159 loop {}
160}
124161
125162#[repr(transparent)]
126163pub enum EnumF32 {
127 Variant(F32)
164 Variant(F32),
128165}
129166
130167// CHECK: define{{.*}}float @test_EnumF32(float noundef %_1)
131168#[no_mangle]
132pub extern "C" fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} }
169pub extern "C" fn test_EnumF32(_: EnumF32) -> EnumF32 {
170 loop {}
171}
133172
134173#[repr(transparent)]
135174pub enum EnumF32WithZsts {
136 Variant(Zst1, F32, Zst2)
175 Variant(Zst1, F32, Zst2),
137176}
138177
139178// CHECK: define{{.*}}float @test_EnumF32WithZsts(float noundef %_1)
140179#[no_mangle]
141pub extern "C" fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} }
180pub extern "C" fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts {
181 loop {}
182}
142183
143184#[repr(transparent)]
144185pub union UnionF32 {
......@@ -147,7 +188,9 @@ pub union UnionF32 {
147188
148189// CHECK: define{{.*}} float @test_UnionF32(float %_1)
149190#[no_mangle]
150pub extern "C" fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} }
191pub extern "C" fn test_UnionF32(_: UnionF32) -> UnionF32 {
192 loop {}
193}
151194
152195#[repr(transparent)]
153196pub union UnionF32WithZsts {
......@@ -158,8 +201,9 @@ pub union UnionF32WithZsts {
158201
159202// CHECK: define{{.*}}float @test_UnionF32WithZsts(float %_1)
160203#[no_mangle]
161pub extern "C" fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts { loop {} }
162
204pub extern "C" fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts {
205 loop {}
206}
163207
164208// All that remains to be tested are aggregates. They are tested in separate files called
165209// transparent-*.rs with `only-*` or `ignore-*` directives, because the expected LLVM IR
tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs+4-8
......@@ -83,8 +83,7 @@ pub struct Tiny {
8383
8484// CHECK: define void @f_agg_tiny(i64 %0)
8585#[no_mangle]
86pub extern "C" fn f_agg_tiny(mut e: Tiny) {
87}
86pub extern "C" fn f_agg_tiny(mut e: Tiny) {}
8887
8988// CHECK: define i64 @f_agg_tiny_ret()
9089#[no_mangle]
......@@ -100,8 +99,7 @@ pub struct Small {
10099
101100// CHECK: define void @f_agg_small([2 x i64] %0)
102101#[no_mangle]
103pub extern "C" fn f_agg_small(mut x: Small) {
104}
102pub extern "C" fn f_agg_small(mut x: Small) {}
105103
106104// CHECK: define [2 x i64] @f_agg_small_ret()
107105#[no_mangle]
......@@ -116,8 +114,7 @@ pub struct SmallAligned {
116114
117115// CHECK: define void @f_agg_small_aligned(i128 %0)
118116#[no_mangle]
119pub extern "C" fn f_agg_small_aligned(mut x: SmallAligned) {
120}
117pub extern "C" fn f_agg_small_aligned(mut x: SmallAligned) {}
121118
122119#[repr(C)]
123120pub struct Large {
......@@ -129,8 +126,7 @@ pub struct Large {
129126
130127// CHECK: define void @f_agg_large(ptr {{.*}}%x)
131128#[no_mangle]
132pub extern "C" fn f_agg_large(mut x: Large) {
133}
129pub extern "C" fn f_agg_large(mut x: Large) {}
134130
135131// CHECK: define void @f_agg_large_ret(ptr {{.*}}sret{{.*}}, i32 noundef signext %i, i8 noundef signext %j)
136132#[no_mangle]
tests/codegen/sanitizer/address-sanitizer-globals-tracking.rs+1-1
......@@ -23,7 +23,7 @@
2323//@[ASAN] compile-flags:
2424//@[ASAN-FAT-LTO] compile-flags: -Cprefer-dynamic=false -Clto=fat
2525
26#![crate_type="staticlib"]
26#![crate_type = "staticlib"]
2727
2828// The test below mimics `CACHED_POW10` from `library/core/src/num/flt2dec/strategy/grisu.rs` which
2929// (because of incorrect handling of `___asan_globals_registered` during LTO) was incorrectly
tests/codegen/sanitizer/cfi/add-canonical-jump-tables-flag.rs+2-3
......@@ -3,9 +3,8 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
8pub fn foo() {
9}
8pub fn foo() {}
109
1110// CHECK: !{{[0-9]+}} = !{i32 4, !"CFI Canonical Jump Tables", i32 1}
tests/codegen/sanitizer/cfi/add-enable-split-lto-unit-flag.rs+2-3
......@@ -3,9 +3,8 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
8pub fn foo() {
9}
8pub fn foo() {}
109
1110// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1}
tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs+1-1
......@@ -3,7 +3,7 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77#![feature(no_sanitize)]
88
99#[no_sanitize(cfi)]
tests/codegen/sanitizer/cfi/emit-type-checks.rs+1-1
......@@ -3,7 +3,7 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {
99 // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
tests/codegen/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs+17-17
......@@ -3,13 +3,13 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77#![feature(cfi_encoding, extern_types)]
88
99#[cfi_encoding = "3Foo"]
1010pub struct Type1(i32);
1111
12extern {
12extern "C" {
1313 #[cfi_encoding = "3Bar"]
1414 type Type2;
1515}
......@@ -25,35 +25,35 @@ pub struct Type4(i32);
2525#[repr(transparent)]
2626pub struct Type5(u32);
2727
28pub fn foo0(_: Type1) { }
28pub fn foo0(_: Type1) {}
2929// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
30pub fn foo1(_: Type1, _: Type1) { }
30pub fn foo1(_: Type1, _: Type1) {}
3131// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
32pub fn foo2(_: Type1, _: Type1, _: Type1) { }
32pub fn foo2(_: Type1, _: Type1, _: Type1) {}
3333// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
34pub fn foo3(_: *mut Type2) { }
34pub fn foo3(_: *mut Type2) {}
3535// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
36pub fn foo4(_: *mut Type2, _: *mut Type2) { }
36pub fn foo4(_: *mut Type2, _: *mut Type2) {}
3737// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
38pub fn foo5(_: *mut Type2, _: *mut Type2, _: *mut Type2) { }
38pub fn foo5(_: *mut Type2, _: *mut Type2, _: *mut Type2) {}
3939// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
40pub fn foo6(_: *mut Type3) { }
40pub fn foo6(_: *mut Type3) {}
4141// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
42pub fn foo7(_: *mut Type3, _: *mut Type3) { }
42pub fn foo7(_: *mut Type3, _: *mut Type3) {}
4343// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
44pub fn foo8(_: *mut Type3, _: *mut Type3, _: *mut Type3) { }
44pub fn foo8(_: *mut Type3, _: *mut Type3, _: *mut Type3) {}
4545// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
46pub fn foo9(_: Type4) { }
46pub fn foo9(_: Type4) {}
4747// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
48pub fn foo10(_: Type4, _: Type4) { }
48pub fn foo10(_: Type4, _: Type4) {}
4949// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
50pub fn foo11(_: Type4, _: Type4, _: Type4) { }
50pub fn foo11(_: Type4, _: Type4, _: Type4) {}
5151// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
52pub fn foo12(_: Type5) { }
52pub fn foo12(_: Type5) {}
5353// CHECK: define{{.*}}foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
54pub fn foo13(_: Type5, _: Type5) { }
54pub fn foo13(_: Type5, _: Type5) {}
5555// CHECK: define{{.*}}foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
56pub fn foo14(_: Type5, _: Type5, _: Type5) { }
56pub fn foo14(_: Type5, _: Type5, _: Type5) {}
5757// CHECK: define{{.*}}foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
5858
5959// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFv3FooE"}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs+6-5
......@@ -4,25 +4,26 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88#![feature(type_alias_impl_trait)]
99
1010extern crate core;
1111
1212pub type Type1 = impl Send;
1313
14pub fn foo() where
14pub fn foo()
15where
1516 Type1: 'static,
1617{
1718 pub struct Foo<T, const N: usize>([T; N]);
1819 let _: Type1 = Foo([0; 32]);
1920}
2021
21pub fn foo1(_: Type1) { }
22pub fn foo1(_: Type1) {}
2223// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
23pub fn foo2(_: Type1, _: Type1) { }
24pub fn foo2(_: Type1, _: Type1) {}
2425// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
25pub fn foo3(_: Type1, _: Type1, _: Type1) { }
26pub fn foo3(_: Type1, _: Type1, _: Type1) {}
2627// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
2728
2829// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo3FooIu3i32Lu5usize32EEE"}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs+1-1
......@@ -3,7 +3,7 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88// CHECK-LABEL: define{{.*}}4core3ptr47drop_in_place$LT$dyn$u20$core..marker..Send$GT$
99// CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs+12-12
......@@ -4,29 +4,29 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
9pub fn foo1(_: fn(i32) -> i32) { }
9pub fn foo1(_: fn(i32) -> i32) {}
1010// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
11pub fn foo2(_: fn(i32) -> i32, _: fn(i32) -> i32) { }
11pub fn foo2(_: fn(i32) -> i32, _: fn(i32) -> i32) {}
1212// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
13pub fn foo3(_: fn(i32) -> i32, _: fn(i32) -> i32, _: fn(i32) -> i32) { }
13pub fn foo3(_: fn(i32) -> i32, _: fn(i32) -> i32, _: fn(i32) -> i32) {}
1414// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
15pub fn foo4(_: &dyn Fn(i32) -> i32) { }
15pub fn foo4(_: &dyn Fn(i32) -> i32) {}
1616// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
17pub fn foo5(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) { }
17pub fn foo5(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) {}
1818// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
19pub fn foo6(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) { }
19pub fn foo6(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) {}
2020// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
21pub fn foo7(_: &dyn FnMut(i32) -> i32) { }
21pub fn foo7(_: &dyn FnMut(i32) -> i32) {}
2222// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
23pub fn foo8(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) { }
23pub fn foo8(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) {}
2424// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
25pub fn foo9(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) { }
25pub fn foo9(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) {}
2626// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
27pub fn foo10(_: &dyn FnOnce(i32) -> i32) { }
27pub fn foo10(_: &dyn FnOnce(i32) -> i32) {}
2828// CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
29pub fn foo11(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) { }
29pub fn foo11(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) {}
3030// CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
3131pub fn foo12(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) {}
3232// CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs+6-5
......@@ -4,14 +4,15 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88#![feature(type_alias_impl_trait)]
99
1010extern crate core;
1111
1212pub type Type1 = impl Send;
1313
14pub fn foo<'a>() where
14pub fn foo<'a>()
15where
1516 Type1: 'static,
1617{
1718 pub struct Foo<'a>(&'a i32);
......@@ -19,9 +20,9 @@ pub fn foo<'a>() where
1920 let _: Type1 = Bar;
2021}
2122
22pub fn foo1(_: Type1) { }
23pub fn foo1(_: Type1) {}
2324// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
24pub fn foo2(_: Type1, _: Type1) { }
25pub fn foo2(_: Type1, _: Type1) {}
2526// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
26pub fn foo3(_: Type1, _: Type1, _: Type1) { }
27pub fn foo3(_: Type1, _: Type1, _: Type1) {}
2728// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs+1-2
......@@ -4,7 +4,7 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
99trait Trait1 {
1010 fn foo(&self);
......@@ -17,6 +17,5 @@ impl Trait1 for Type1 {
1717 // CHECK: define{{.*}}3foo{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
1818}
1919
20
2120// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"}
2221// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs+16-16
......@@ -4,37 +4,37 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
9pub fn foo1(_: &mut i32) { }
9pub fn foo1(_: &mut i32) {}
1010// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
11pub fn foo2(_: &mut i32, _: &i32) { }
11pub fn foo2(_: &mut i32, _: &i32) {}
1212// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
13pub fn foo3(_: &mut i32, _: &i32, _: &i32) { }
13pub fn foo3(_: &mut i32, _: &i32, _: &i32) {}
1414// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
15pub fn foo4(_: &i32) { }
15pub fn foo4(_: &i32) {}
1616// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
17pub fn foo5(_: &i32, _: &mut i32) { }
17pub fn foo5(_: &i32, _: &mut i32) {}
1818// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
19pub fn foo6(_: &i32, _: &mut i32, _: &mut i32) { }
19pub fn foo6(_: &i32, _: &mut i32, _: &mut i32) {}
2020// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
21pub fn foo7(_: *mut i32) { }
21pub fn foo7(_: *mut i32) {}
2222// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
23pub fn foo8(_: *mut i32, _: *const i32) { }
23pub fn foo8(_: *mut i32, _: *const i32) {}
2424// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
25pub fn foo9(_: *mut i32, _: *const i32, _: *const i32) { }
25pub fn foo9(_: *mut i32, _: *const i32, _: *const i32) {}
2626// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
27pub fn foo10(_: *const i32) { }
27pub fn foo10(_: *const i32) {}
2828// CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
29pub fn foo11(_: *const i32, _: *mut i32) { }
29pub fn foo11(_: *const i32, _: *mut i32) {}
3030// CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
31pub fn foo12(_: *const i32, _: *mut i32, _: *mut i32) { }
31pub fn foo12(_: *const i32, _: *mut i32, _: *mut i32) {}
3232// CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
33pub fn foo13(_: fn(i32) -> i32) { }
33pub fn foo13(_: fn(i32) -> i32) {}
3434// CHECK: define{{.*}}5foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
35pub fn foo14(_: fn(i32) -> i32, _: fn(i32) -> i32) { }
35pub fn foo14(_: fn(i32) -> i32, _: fn(i32) -> i32) {}
3636// CHECK: define{{.*}}5foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
37pub fn foo15(_: fn(i32) -> i32, _: fn(i32) -> i32, _: fn(i32) -> i32) { }
37pub fn foo15(_: fn(i32) -> i32, _: fn(i32) -> i32, _: fn(i32) -> i32) {}
3838// CHECK: define{{.*}}5foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
3939
4040// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvU3mutu3refIu3i32EE"}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs+61-61
......@@ -4,130 +4,130 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
99extern crate core;
1010use core::ffi::*;
1111
12pub fn foo1(_: ()) { }
12pub fn foo1(_: ()) {}
1313// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
14pub fn foo2(_: (), _: c_void) { }
14pub fn foo2(_: (), _: c_void) {}
1515// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
16pub fn foo3(_: (), _: c_void, _: c_void) { }
16pub fn foo3(_: (), _: c_void, _: c_void) {}
1717// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
18pub fn foo4(_: *mut ()) { }
18pub fn foo4(_: *mut ()) {}
1919// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
20pub fn foo5(_: *mut (), _: *mut c_void) { }
20pub fn foo5(_: *mut (), _: *mut c_void) {}
2121// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
22pub fn foo6(_: *mut (), _: *mut c_void, _: *mut c_void) { }
22pub fn foo6(_: *mut (), _: *mut c_void, _: *mut c_void) {}
2323// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
24pub fn foo7(_: *const ()) { }
24pub fn foo7(_: *const ()) {}
2525// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
26pub fn foo8(_: *const (), _: *const c_void) { }
26pub fn foo8(_: *const (), _: *const c_void) {}
2727// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
28pub fn foo9(_: *const (), _: *const c_void, _: *const c_void) { }
28pub fn foo9(_: *const (), _: *const c_void, _: *const c_void) {}
2929// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
30pub fn foo10(_: bool) { }
30pub fn foo10(_: bool) {}
3131// CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
32pub fn foo11(_: bool, _: bool) { }
32pub fn foo11(_: bool, _: bool) {}
3333// CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
34pub fn foo12(_: bool, _: bool, _: bool) { }
34pub fn foo12(_: bool, _: bool, _: bool) {}
3535// CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
36pub fn foo13(_: i8) { }
36pub fn foo13(_: i8) {}
3737// CHECK: define{{.*}}5foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
38pub fn foo14(_: i8, _: i8) { }
38pub fn foo14(_: i8, _: i8) {}
3939// CHECK: define{{.*}}5foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
40pub fn foo15(_: i8, _: i8, _: i8) { }
40pub fn foo15(_: i8, _: i8, _: i8) {}
4141// CHECK: define{{.*}}5foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
42pub fn foo16(_: i16) { }
42pub fn foo16(_: i16) {}
4343// CHECK: define{{.*}}5foo16{{.*}}!type ![[TYPE16:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
44pub fn foo17(_: i16, _: i16) { }
44pub fn foo17(_: i16, _: i16) {}
4545// CHECK: define{{.*}}5foo17{{.*}}!type ![[TYPE17:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
46pub fn foo18(_: i16, _: i16, _: i16) { }
46pub fn foo18(_: i16, _: i16, _: i16) {}
4747// CHECK: define{{.*}}5foo18{{.*}}!type ![[TYPE18:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
48pub fn foo19(_: i32) { }
48pub fn foo19(_: i32) {}
4949// CHECK: define{{.*}}5foo19{{.*}}!type ![[TYPE19:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
50pub fn foo20(_: i32, _: i32) { }
50pub fn foo20(_: i32, _: i32) {}
5151// CHECK: define{{.*}}5foo20{{.*}}!type ![[TYPE20:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
52pub fn foo21(_: i32, _: i32, _: i32) { }
52pub fn foo21(_: i32, _: i32, _: i32) {}
5353// CHECK: define{{.*}}5foo21{{.*}}!type ![[TYPE21:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
54pub fn foo22(_: i64) { }
54pub fn foo22(_: i64) {}
5555// CHECK: define{{.*}}5foo22{{.*}}!type ![[TYPE22:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
56pub fn foo23(_: i64, _: i64) { }
56pub fn foo23(_: i64, _: i64) {}
5757// CHECK: define{{.*}}5foo23{{.*}}!type ![[TYPE23:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
58pub fn foo24(_: i64, _: i64, _: i64) { }
58pub fn foo24(_: i64, _: i64, _: i64) {}
5959// CHECK: define{{.*}}5foo24{{.*}}!type ![[TYPE24:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
60pub fn foo25(_: i128) { }
60pub fn foo25(_: i128) {}
6161// CHECK: define{{.*}}5foo25{{.*}}!type ![[TYPE25:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
62pub fn foo26(_: i128, _: i128) { }
62pub fn foo26(_: i128, _: i128) {}
6363// CHECK: define{{.*}}5foo26{{.*}}!type ![[TYPE26:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
64pub fn foo27(_: i128, _: i128, _: i128) { }
64pub fn foo27(_: i128, _: i128, _: i128) {}
6565// CHECK: define{{.*}}5foo27{{.*}}!type ![[TYPE27:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
66pub fn foo28(_: isize) { }
66pub fn foo28(_: isize) {}
6767// CHECK: define{{.*}}5foo28{{.*}}!type ![[TYPE28:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
68pub fn foo29(_: isize, _: isize) { }
68pub fn foo29(_: isize, _: isize) {}
6969// CHECK: define{{.*}}5foo29{{.*}}!type ![[TYPE29:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
70pub fn foo30(_: isize, _: isize, _: isize) { }
70pub fn foo30(_: isize, _: isize, _: isize) {}
7171// CHECK: define{{.*}}5foo30{{.*}}!type ![[TYPE30:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
72pub fn foo31(_: u8) { }
72pub fn foo31(_: u8) {}
7373// CHECK: define{{.*}}5foo31{{.*}}!type ![[TYPE31:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
74pub fn foo32(_: u8, _: u8) { }
74pub fn foo32(_: u8, _: u8) {}
7575// CHECK: define{{.*}}5foo32{{.*}}!type ![[TYPE32:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
76pub fn foo33(_: u8, _: u8, _: u8) { }
76pub fn foo33(_: u8, _: u8, _: u8) {}
7777// CHECK: define{{.*}}5foo33{{.*}}!type ![[TYPE33:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
78pub fn foo34(_: u16) { }
78pub fn foo34(_: u16) {}
7979// CHECK: define{{.*}}5foo34{{.*}}!type ![[TYPE34:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
80pub fn foo35(_: u16, _: u16) { }
80pub fn foo35(_: u16, _: u16) {}
8181// CHECK: define{{.*}}5foo35{{.*}}!type ![[TYPE35:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
82pub fn foo36(_: u16, _: u16, _: u16) { }
82pub fn foo36(_: u16, _: u16, _: u16) {}
8383// CHECK: define{{.*}}5foo36{{.*}}!type ![[TYPE36:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
84pub fn foo37(_: u32) { }
84pub fn foo37(_: u32) {}
8585// CHECK: define{{.*}}5foo37{{.*}}!type ![[TYPE37:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
86pub fn foo38(_: u32, _: u32) { }
86pub fn foo38(_: u32, _: u32) {}
8787// CHECK: define{{.*}}5foo38{{.*}}!type ![[TYPE38:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
88pub fn foo39(_: u32, _: u32, _: u32) { }
88pub fn foo39(_: u32, _: u32, _: u32) {}
8989// CHECK: define{{.*}}5foo39{{.*}}!type ![[TYPE39:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
90pub fn foo40(_: u64) { }
90pub fn foo40(_: u64) {}
9191// CHECK: define{{.*}}5foo40{{.*}}!type ![[TYPE40:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
92pub fn foo41(_: u64, _: u64) { }
92pub fn foo41(_: u64, _: u64) {}
9393// CHECK: define{{.*}}5foo41{{.*}}!type ![[TYPE41:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
94pub fn foo42(_: u64, _: u64, _: u64) { }
94pub fn foo42(_: u64, _: u64, _: u64) {}
9595// CHECK: define{{.*}}5foo42{{.*}}!type ![[TYPE42:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
96pub fn foo43(_: u128) { }
96pub fn foo43(_: u128) {}
9797// CHECK: define{{.*}}5foo43{{.*}}!type ![[TYPE43:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
98pub fn foo44(_: u128, _: u128) { }
98pub fn foo44(_: u128, _: u128) {}
9999// CHECK: define{{.*}}5foo44{{.*}}!type ![[TYPE44:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
100pub fn foo45(_: u128, _: u128, _: u128) { }
100pub fn foo45(_: u128, _: u128, _: u128) {}
101101// CHECK: define{{.*}}5foo45{{.*}}!type ![[TYPE45:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
102pub fn foo46(_: usize) { }
102pub fn foo46(_: usize) {}
103103// CHECK: define{{.*}}5foo46{{.*}}!type ![[TYPE46:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
104pub fn foo47(_: usize, _: usize) { }
104pub fn foo47(_: usize, _: usize) {}
105105// CHECK: define{{.*}}5foo47{{.*}}!type ![[TYPE47:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
106pub fn foo48(_: usize, _: usize, _: usize) { }
106pub fn foo48(_: usize, _: usize, _: usize) {}
107107// CHECK: define{{.*}}5foo48{{.*}}!type ![[TYPE48:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
108pub fn foo49(_: f32) { }
108pub fn foo49(_: f32) {}
109109// CHECK: define{{.*}}5foo49{{.*}}!type ![[TYPE49:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
110pub fn foo50(_: f32, _: f32) { }
110pub fn foo50(_: f32, _: f32) {}
111111// CHECK: define{{.*}}5foo50{{.*}}!type ![[TYPE50:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
112pub fn foo51(_: f32, _: f32, _: f32) { }
112pub fn foo51(_: f32, _: f32, _: f32) {}
113113// CHECK: define{{.*}}5foo51{{.*}}!type ![[TYPE51:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
114pub fn foo52(_: f64) { }
114pub fn foo52(_: f64) {}
115115// CHECK: define{{.*}}5foo52{{.*}}!type ![[TYPE52:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
116pub fn foo53(_: f64, _: f64) { }
116pub fn foo53(_: f64, _: f64) {}
117117// CHECK: define{{.*}}5foo53{{.*}}!type ![[TYPE53:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
118pub fn foo54(_: f64, _: f64, _: f64) { }
118pub fn foo54(_: f64, _: f64, _: f64) {}
119119// CHECK: define{{.*}}5foo54{{.*}}!type ![[TYPE54:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
120pub fn foo55(_: char) { }
120pub fn foo55(_: char) {}
121121// CHECK: define{{.*}}5foo55{{.*}}!type ![[TYPE55:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
122pub fn foo56(_: char, _: char) { }
122pub fn foo56(_: char, _: char) {}
123123// CHECK: define{{.*}}5foo56{{.*}}!type ![[TYPE56:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
124pub fn foo57(_: char, _: char, _: char) { }
124pub fn foo57(_: char, _: char, _: char) {}
125125// CHECK: define{{.*}}5foo57{{.*}}!type ![[TYPE57:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
126pub fn foo58(_: &str) { }
126pub fn foo58(_: &str) {}
127127// CHECK: define{{.*}}5foo58{{.*}}!type ![[TYPE58:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
128pub fn foo59(_: &str, _: &str) { }
128pub fn foo59(_: &str, _: &str) {}
129129// CHECK: define{{.*}}5foo59{{.*}}!type ![[TYPE59:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
130pub fn foo60(_: &str, _: &str, _: &str) { }
130pub fn foo60(_: &str, _: &str, _: &str) {}
131131// CHECK: define{{.*}}5foo60{{.*}}!type ![[TYPE60:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
132132
133133// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvvE"}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs+13-14
......@@ -4,7 +4,7 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
99extern crate core;
1010use core::ffi::*;
......@@ -40,32 +40,31 @@ pub struct Type4(Type4Helper<Type4>);
4040#[repr(transparent)]
4141pub struct Type4Helper<T>(*mut T);
4242
43pub fn foo1(_: Type1) { }
43pub fn foo1(_: Type1) {}
4444// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
45pub fn foo2(_: Type1, _: Type1) { }
45pub fn foo2(_: Type1, _: Type1) {}
4646// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
47pub fn foo3(_: Type1, _: Type1, _: Type1) { }
47pub fn foo3(_: Type1, _: Type1, _: Type1) {}
4848// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
49pub fn foo4(_: Type2) { }
49pub fn foo4(_: Type2) {}
5050// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
51pub fn foo5(_: Type2, _: Type2) { }
51pub fn foo5(_: Type2, _: Type2) {}
5252// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
53pub fn foo6(_: Type2, _: Type2, _: Type2) { }
53pub fn foo6(_: Type2, _: Type2, _: Type2) {}
5454// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
55pub fn foo7(_: Type3<Bar>) { }
55pub fn foo7(_: Type3<Bar>) {}
5656// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
57pub fn foo8(_: Type3<Bar>, _: Type3<Bar>) { }
57pub fn foo8(_: Type3<Bar>, _: Type3<Bar>) {}
5858// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
59pub fn foo9(_: Type3<Bar>, _: Type3<Bar>, _: Type3<Bar>) { }
59pub fn foo9(_: Type3<Bar>, _: Type3<Bar>, _: Type3<Bar>) {}
6060// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
61pub fn foo10(_: Type4) { }
61pub fn foo10(_: Type4) {}
6262// CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
63pub fn foo11(_: Type4, _: Type4) { }
63pub fn foo11(_: Type4, _: Type4) {}
6464// CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
65pub fn foo12(_: Type4, _: Type4, _: Type4) { }
65pub fn foo12(_: Type4, _: Type4, _: Type4) {}
6666// CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
6767
68
6968// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}3FooE"}
7069// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}3FooS_E"}
7170// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}3FooS_S_E"}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs+10-10
......@@ -4,25 +4,25 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
9pub fn foo1(_: (i32, i32)) { }
9pub fn foo1(_: (i32, i32)) {}
1010// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
11pub fn foo2(_: (i32, i32), _: (i32, i32)) { }
11pub fn foo2(_: (i32, i32), _: (i32, i32)) {}
1212// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
13pub fn foo3(_: (i32, i32), _: (i32, i32), _: (i32, i32)) { }
13pub fn foo3(_: (i32, i32), _: (i32, i32), _: (i32, i32)) {}
1414// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
15pub fn foo4(_: [i32; 32]) { }
15pub fn foo4(_: [i32; 32]) {}
1616// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
17pub fn foo5(_: [i32; 32], _: [i32; 32]) { }
17pub fn foo5(_: [i32; 32], _: [i32; 32]) {}
1818// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
19pub fn foo6(_: [i32; 32], _: [i32; 32], _: [i32; 32]) { }
19pub fn foo6(_: [i32; 32], _: [i32; 32], _: [i32; 32]) {}
2020// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
21pub fn foo7(_: &[i32]) { }
21pub fn foo7(_: &[i32]) {}
2222// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
23pub fn foo8(_: &[i32], _: &[i32]) { }
23pub fn foo8(_: &[i32], _: &[i32]) {}
2424// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
25pub fn foo9(_: &[i32], _: &[i32], _: &[i32]) { }
25pub fn foo9(_: &[i32], _: &[i32], _: &[i32]) {}
2626// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
2727
2828// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu5tupleIu3i32S_EE"}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs+58-44
......@@ -4,7 +4,7 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88
99extern crate core;
1010
......@@ -16,8 +16,7 @@ pub trait Trait1 {
1616pub struct Type1;
1717
1818impl Trait1 for Type1 {
19 fn foo(&self) {
20 }
19 fn foo(&self) {}
2120}
2221
2322pub trait Trait2<T> {
......@@ -27,8 +26,7 @@ pub trait Trait2<T> {
2726pub struct Type2;
2827
2928impl Trait2<i32> for Type2 {
30 fn bar(&self) {
31 }
29 fn bar(&self) {}
3230}
3331
3432pub trait Trait3<T> {
......@@ -38,8 +36,7 @@ pub trait Trait3<T> {
3836pub struct Type3;
3937
4038impl<T, U> Trait3<U> for T {
41 fn baz(&self, _: &U) {
42 }
39 fn baz(&self, _: &U) {}
4340}
4441
4542pub trait Trait4<'a, T> {
......@@ -64,71 +61,88 @@ pub trait Trait5<T, const N: usize> {
6461pub struct Type5;
6562
6663impl<T, U, const N: usize> Trait5<U, N> for T {
67 fn quux(&self, _: &[U; N]) {
68 }
64 fn quux(&self, _: &[U; N]) {}
6965}
7066
71pub fn foo1(_: &dyn Send) { }
67pub fn foo1(_: &dyn Send) {}
7268// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
73pub fn foo2(_: &dyn Send, _: &dyn Send) { }
69pub fn foo2(_: &dyn Send, _: &dyn Send) {}
7470// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
75pub fn foo3(_: &dyn Send, _: &dyn Send, _: &dyn Send) { }
71pub fn foo3(_: &dyn Send, _: &dyn Send, _: &dyn Send) {}
7672// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
77pub fn foo4(_: &(dyn Send + Sync)) { }
73pub fn foo4(_: &(dyn Send + Sync)) {}
7874// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
79pub fn foo5(_: &(dyn Send + Sync), _: &(dyn Sync + Send)) { }
75pub fn foo5(_: &(dyn Send + Sync), _: &(dyn Sync + Send)) {}
8076// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
81pub fn foo6(_: &(dyn Send + Sync), _: &(dyn Sync + Send), _: &(dyn Sync + Send)) { }
77pub fn foo6(_: &(dyn Send + Sync), _: &(dyn Sync + Send), _: &(dyn Sync + Send)) {}
8278// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
83pub fn foo7(_: &(dyn Trait1 + Send)) { }
79pub fn foo7(_: &(dyn Trait1 + Send)) {}
8480// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
85pub fn foo8(_: &(dyn Trait1 + Send), _: &(dyn Trait1 + Send)) { }
81pub fn foo8(_: &(dyn Trait1 + Send), _: &(dyn Trait1 + Send)) {}
8682// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
87pub fn foo9(_: &(dyn Trait1 + Send), _: &(dyn Trait1 + Send), _: &(dyn Trait1 + Send)) { }
83pub fn foo9(_: &(dyn Trait1 + Send), _: &(dyn Trait1 + Send), _: &(dyn Trait1 + Send)) {}
8884// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
89pub fn foo10(_: &(dyn Trait1 + Send + Sync)) { }
85pub fn foo10(_: &(dyn Trait1 + Send + Sync)) {}
9086// CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
91pub fn foo11(_: &(dyn Trait1 + Send + Sync), _: &(dyn Trait1 + Sync + Send)) { }
87pub fn foo11(_: &(dyn Trait1 + Send + Sync), _: &(dyn Trait1 + Sync + Send)) {}
9288// CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
93pub fn foo12(_: &(dyn Trait1 + Send + Sync),
94 _: &(dyn Trait1 + Sync + Send),
95 _: &(dyn Trait1 + Sync + Send)) { }
89pub fn foo12(
90 _: &(dyn Trait1 + Send + Sync),
91 _: &(dyn Trait1 + Sync + Send),
92 _: &(dyn Trait1 + Sync + Send),
93) {
94}
9695// CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
97pub fn foo13(_: &dyn Trait1) { }
96pub fn foo13(_: &dyn Trait1) {}
9897// CHECK: define{{.*}}5foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
99pub fn foo14(_: &dyn Trait1, _: &dyn Trait1) { }
98pub fn foo14(_: &dyn Trait1, _: &dyn Trait1) {}
10099// CHECK: define{{.*}}5foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
101pub fn foo15(_: &dyn Trait1, _: &dyn Trait1, _: &dyn Trait1) { }
100pub fn foo15(_: &dyn Trait1, _: &dyn Trait1, _: &dyn Trait1) {}
102101// CHECK: define{{.*}}5foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
103pub fn foo16<T>(_: &dyn Trait2<T>) { }
104pub fn bar16() { let a = Type2; foo16(&a); }
102pub fn foo16<T>(_: &dyn Trait2<T>) {}
103pub fn bar16() {
104 let a = Type2;
105 foo16(&a);
106}
105107// CHECK: define{{.*}}5foo16{{.*}}!type ![[TYPE16:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
106pub fn foo17<T>(_: &dyn Trait2<T>, _: &dyn Trait2<T>) { }
107pub fn bar17() { let a = Type2; foo17(&a, &a); }
108pub fn foo17<T>(_: &dyn Trait2<T>, _: &dyn Trait2<T>) {}
109pub fn bar17() {
110 let a = Type2;
111 foo17(&a, &a);
112}
108113// CHECK: define{{.*}}5foo17{{.*}}!type ![[TYPE17:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
109pub fn foo18<T>(_: &dyn Trait2<T>, _: &dyn Trait2<T>, _: &dyn Trait2<T>) { }
110pub fn bar18() { let a = Type2; foo18(&a, &a, &a); }
114pub fn foo18<T>(_: &dyn Trait2<T>, _: &dyn Trait2<T>, _: &dyn Trait2<T>) {}
115pub fn bar18() {
116 let a = Type2;
117 foo18(&a, &a, &a);
118}
111119// CHECK: define{{.*}}5foo18{{.*}}!type ![[TYPE18:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
112pub fn foo19(_: &dyn Trait3<Type3>) { }
120pub fn foo19(_: &dyn Trait3<Type3>) {}
113121// CHECK: define{{.*}}5foo19{{.*}}!type ![[TYPE19:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
114pub fn foo20(_: &dyn Trait3<Type3>, _: &dyn Trait3<Type3>) { }
122pub fn foo20(_: &dyn Trait3<Type3>, _: &dyn Trait3<Type3>) {}
115123// CHECK: define{{.*}}5foo20{{.*}}!type ![[TYPE20:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
116pub fn foo21(_: &dyn Trait3<Type3>, _: &dyn Trait3<Type3>, _: &dyn Trait3<Type3>) { }
124pub fn foo21(_: &dyn Trait3<Type3>, _: &dyn Trait3<Type3>, _: &dyn Trait3<Type3>) {}
117125// CHECK: define{{.*}}5foo21{{.*}}!type ![[TYPE21:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
118pub fn foo22<'a>(_: &dyn Trait4<'a, Type4, Output = &'a i32>) { }
126pub fn foo22<'a>(_: &dyn Trait4<'a, Type4, Output = &'a i32>) {}
119127// CHECK: define{{.*}}5foo22{{.*}}!type ![[TYPE22:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
120pub fn foo23<'a>(_: &dyn Trait4<'a, Type4, Output = &'a i32>,
121 _: &dyn Trait4<'a, Type4, Output = &'a i32>) { }
128pub fn foo23<'a>(
129 _: &dyn Trait4<'a, Type4, Output = &'a i32>,
130 _: &dyn Trait4<'a, Type4, Output = &'a i32>,
131) {
132}
122133// CHECK: define{{.*}}5foo23{{.*}}!type ![[TYPE23:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
123pub fn foo24<'a>(_: &dyn Trait4<'a, Type4, Output = &'a i32>,
124 _: &dyn Trait4<'a, Type4, Output = &'a i32>,
125 _: &dyn Trait4<'a, Type4, Output = &'a i32>) { }
134pub fn foo24<'a>(
135 _: &dyn Trait4<'a, Type4, Output = &'a i32>,
136 _: &dyn Trait4<'a, Type4, Output = &'a i32>,
137 _: &dyn Trait4<'a, Type4, Output = &'a i32>,
138) {
139}
126140// CHECK: define{{.*}}5foo24{{.*}}!type ![[TYPE24:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
127pub fn foo25(_: &dyn Trait5<Type5, 32>) { }
141pub fn foo25(_: &dyn Trait5<Type5, 32>) {}
128142// CHECK: define{{.*}}5foo25{{.*}}!type ![[TYPE25:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
129pub fn foo26(_: &dyn Trait5<Type5, 32>, _: &dyn Trait5<Type5, 32>) { }
143pub fn foo26(_: &dyn Trait5<Type5, 32>, _: &dyn Trait5<Type5, 32>) {}
130144// CHECK: define{{.*}}5foo26{{.*}}!type ![[TYPE26:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
131pub fn foo27(_: &dyn Trait5<Type5, 32>, _: &dyn Trait5<Type5, 32>, _: &dyn Trait5<Type5, 32>) { }
145pub fn foo27(_: &dyn Trait5<Type5, 32>, _: &dyn Trait5<Type5, 32>, _: &dyn Trait5<Type5, 32>) {}
132146// CHECK: define{{.*}}5foo27{{.*}}!type ![[TYPE27:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
133147
134148// CHECK: ![[TYPE13]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"}
tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs+14-14
......@@ -4,7 +4,7 @@
44//@ needs-sanitizer-cfi
55//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88#![feature(extern_types)]
99
1010pub struct Struct1<T> {
......@@ -19,33 +19,33 @@ pub union Union1<T> {
1919 member1: std::mem::ManuallyDrop<T>,
2020}
2121
22extern {
22extern "C" {
2323 pub type type1;
2424}
2525
26pub fn foo1(_: &Struct1::<i32>) { }
26pub fn foo1(_: &Struct1<i32>) {}
2727// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
28pub fn foo2(_: &Struct1::<i32>, _: &Struct1::<i32>) { }
28pub fn foo2(_: &Struct1<i32>, _: &Struct1<i32>) {}
2929// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
30pub fn foo3(_: &Struct1::<i32>, _: &Struct1::<i32>, _: &Struct1::<i32>) { }
30pub fn foo3(_: &Struct1<i32>, _: &Struct1<i32>, _: &Struct1<i32>) {}
3131// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
32pub fn foo4(_: &Enum1::<i32>) { }
32pub fn foo4(_: &Enum1<i32>) {}
3333// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
34pub fn foo5(_: &Enum1::<i32>, _: &Enum1::<i32>) { }
34pub fn foo5(_: &Enum1<i32>, _: &Enum1<i32>) {}
3535// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
36pub fn foo6(_: &Enum1::<i32>, _: &Enum1::<i32>, _: &Enum1::<i32>) { }
36pub fn foo6(_: &Enum1<i32>, _: &Enum1<i32>, _: &Enum1<i32>) {}
3737// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
38pub fn foo7(_: &Union1::<i32>) { }
38pub fn foo7(_: &Union1<i32>) {}
3939// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
40pub fn foo8(_: &Union1::<i32>, _: &Union1::<i32>) { }
40pub fn foo8(_: &Union1<i32>, _: &Union1<i32>) {}
4141// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
42pub fn foo9(_: &Union1::<i32>, _: &Union1::<i32>, _: &Union1::<i32>) { }
42pub fn foo9(_: &Union1<i32>, _: &Union1<i32>, _: &Union1<i32>) {}
4343// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
44pub fn foo10(_: *mut type1) { }
44pub fn foo10(_: *mut type1) {}
4545// CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
46pub fn foo11(_: *mut type1, _: *mut type1) { }
46pub fn foo11(_: *mut type1, _: *mut type1) {}
4747// CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
48pub fn foo12(_: *mut type1, _: *mut type1, _: *mut type1) { }
48pub fn foo12(_: *mut type1, _: *mut type1, _: *mut type1) {}
4949// CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
5050
5151// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}7Struct1Iu3i32EEE"}
tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs+1-1
......@@ -3,7 +3,7 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {
99 // CHECK-LABEL: define{{.*}}foo
tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs+1-1
......@@ -3,7 +3,7 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {
99 // CHECK-LABEL: define{{.*}}foo
tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs+1-1
......@@ -3,7 +3,7 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {
99 // CHECK-LABEL: define{{.*}}foo
tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs+1-1
......@@ -3,7 +3,7 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {
99 // CHECK-LABEL: define{{.*}}foo
tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs+5-9
......@@ -3,7 +3,7 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88pub trait Trait1 {
99 fn foo(&self);
......@@ -13,8 +13,7 @@ pub trait Trait1 {
1313pub struct Type1;
1414
1515impl Trait1 for Type1 {
16 fn foo(&self) {
17 }
16 fn foo(&self) {}
1817}
1918
2019pub trait Trait2<T> {
......@@ -24,8 +23,7 @@ pub trait Trait2<T> {
2423pub struct Type2;
2524
2625impl Trait2<i32> for Type2 {
27 fn bar(&self) {
28 }
26 fn bar(&self) {}
2927}
3028
3129pub trait Trait3<T> {
......@@ -35,8 +33,7 @@ pub trait Trait3<T> {
3533pub struct Type3;
3634
3735impl<T, U> Trait3<U> for T {
38 fn baz(&self, _: &U) {
39 }
36 fn baz(&self, _: &U) {}
4037}
4138
4239pub trait Trait4<'a, T> {
......@@ -61,8 +58,7 @@ pub trait Trait5<T, const N: usize> {
6158pub struct Type5;
6259
6360impl<T, U, const N: usize> Trait5<U, N> for T {
64 fn quux(&self, _: &[U; N]) {
65 }
61 fn quux(&self, _: &[U; N]) {}
6662}
6763
6864pub fn foo1(a: &dyn Trait1) {
tests/codegen/sanitizer/cfi/generalize-pointers.rs+13-13
......@@ -3,33 +3,33 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88extern crate core;
99
10pub fn foo0(_: &mut i32) { }
10pub fn foo0(_: &mut i32) {}
1111// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
12pub fn foo1(_: &mut i32, _: &mut i32) { }
12pub fn foo1(_: &mut i32, _: &mut i32) {}
1313// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
14pub fn foo2(_: &mut i32, _: &mut i32, _: &mut i32) { }
14pub fn foo2(_: &mut i32, _: &mut i32, _: &mut i32) {}
1515// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
16pub fn foo3(_: &i32) { }
16pub fn foo3(_: &i32) {}
1717// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
18pub fn foo4(_: &i32, _: &i32) { }
18pub fn foo4(_: &i32, _: &i32) {}
1919// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
20pub fn foo5(_: &i32, _: &i32, _: &i32) { }
20pub fn foo5(_: &i32, _: &i32, _: &i32) {}
2121// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
22pub fn foo6(_: *mut i32) { }
22pub fn foo6(_: *mut i32) {}
2323// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
24pub fn foo7(_: *mut i32, _: *mut i32) { }
24pub fn foo7(_: *mut i32, _: *mut i32) {}
2525// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
26pub fn foo8(_: *mut i32, _: *mut i32, _: *mut i32) { }
26pub fn foo8(_: *mut i32, _: *mut i32, _: *mut i32) {}
2727// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
28pub fn foo9(_: *const i32) { }
28pub fn foo9(_: *const i32) {}
2929// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
30pub fn foo10(_: *const i32, _: *const i32) { }
30pub fn foo10(_: *const i32, _: *const i32) {}
3131// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
32pub fn foo11(_: *const i32, _: *const i32, _: *const i32) { }
32pub fn foo11(_: *const i32, _: *const i32, _: *const i32) {}
3333// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
3434
3535// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvU3mutu3refIvEE.generalized"}
tests/codegen/sanitizer/cfi/normalize-integers.rs+13-13
......@@ -3,33 +3,33 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
88extern crate core;
99
10pub fn foo0(_: bool) { }
10pub fn foo0(_: bool) {}
1111// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}}
12pub fn foo1(_: bool, _: bool) { }
12pub fn foo1(_: bool, _: bool) {}
1313// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}}
14pub fn foo2(_: bool, _: bool, _: bool) { }
14pub fn foo2(_: bool, _: bool, _: bool) {}
1515// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}}
16pub fn foo3(_: char) { }
16pub fn foo3(_: char) {}
1717// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}}
18pub fn foo4(_: char, _: char) { }
18pub fn foo4(_: char, _: char) {}
1919// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}}
20pub fn foo5(_: char, _: char, _: char) { }
20pub fn foo5(_: char, _: char, _: char) {}
2121// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}}
22pub fn foo6(_: isize) { }
22pub fn foo6(_: isize) {}
2323// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}}
24pub fn foo7(_: isize, _: isize) { }
24pub fn foo7(_: isize, _: isize) {}
2525// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}}
26pub fn foo8(_: isize, _: isize, _: isize) { }
26pub fn foo8(_: isize, _: isize, _: isize) {}
2727// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}}
28pub fn foo9(_: (), _: usize) { }
28pub fn foo9(_: (), _: usize) {}
2929// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}}
30pub fn foo10(_: (), _: usize, _: usize) { }
30pub fn foo10(_: (), _: usize, _: usize) {}
3131// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}}
32pub fn foo11(_: (), _: usize, _: usize, _: usize) { }
32pub fn foo11(_: (), _: usize, _: usize, _: usize) {}
3333// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}}
3434
3535// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvu2u8E.normalized"}
tests/codegen/sanitizer/dataflow-instrument-functions.rs+2-3
......@@ -3,8 +3,7 @@
33//@ needs-sanitizer-dataflow
44//@ compile-flags: -Copt-level=0 -Zsanitizer=dataflow
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
8pub fn foo() {
9}
8pub fn foo() {}
109// CHECK: define{{.*}}foo{{.*}}.dfsan
tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs+6-7
......@@ -8,15 +8,14 @@
88//@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi
99
1010#![feature(no_core, lang_items)]
11#![crate_type="lib"]
11#![crate_type = "lib"]
1212#![no_core]
1313
14#[lang="sized"]
15trait Sized { }
16#[lang="copy"]
17trait Copy { }
14#[lang = "sized"]
15trait Sized {}
16#[lang = "copy"]
17trait Copy {}
1818
19pub fn foo() {
20}
19pub fn foo() {}
2120
2221// CHECK: !{{[0-9]+}} = !{i32 4, !"kcfi", i32 1}
tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs+5-5
......@@ -7,14 +7,14 @@
77//@ [x86_64] needs-llvm-components:
88//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
99
10#![crate_type="lib"]
10#![crate_type = "lib"]
1111#![feature(no_core, no_sanitize, lang_items)]
1212#![no_core]
1313
14#[lang="sized"]
15trait Sized { }
16#[lang="copy"]
17trait Copy { }
14#[lang = "sized"]
15trait Sized {}
16#[lang = "copy"]
17trait Copy {}
1818
1919impl Copy for i32 {}
2020
tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs+5-5
......@@ -7,14 +7,14 @@
77//@ [x86_64] needs-llvm-components:
88//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers
99
10#![crate_type="lib"]
10#![crate_type = "lib"]
1111#![feature(no_core, lang_items)]
1212#![no_core]
1313
14#[lang="sized"]
15trait Sized { }
16#[lang="copy"]
17trait Copy { }
14#[lang = "sized"]
15trait Sized {}
16#[lang = "copy"]
17trait Copy {}
1818
1919impl Copy for i32 {}
2020
tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs+5-5
......@@ -7,14 +7,14 @@
77//@ [x86_64] needs-llvm-components:
88//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers
99
10#![crate_type="lib"]
10#![crate_type = "lib"]
1111#![feature(no_core, lang_items)]
1212#![no_core]
1313
14#[lang="sized"]
15trait Sized { }
16#[lang="copy"]
17trait Copy { }
14#[lang = "sized"]
15trait Sized {}
16#[lang = "copy"]
17trait Copy {}
1818
1919impl Copy for i32 {}
2020
tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs+5-5
......@@ -7,14 +7,14 @@
77//@ [x86_64] needs-llvm-components:
88//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
99
10#![crate_type="lib"]
10#![crate_type = "lib"]
1111#![feature(no_core, lang_items)]
1212#![no_core]
1313
14#[lang="sized"]
15trait Sized { }
16#[lang="copy"]
17trait Copy { }
14#[lang = "sized"]
15trait Sized {}
16#[lang = "copy"]
17trait Copy {}
1818
1919impl Copy for i32 {}
2020
tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs+5-5
......@@ -7,14 +7,14 @@
77//@ [x86_64] needs-llvm-components:
88//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
99
10#![crate_type="lib"]
10#![crate_type = "lib"]
1111#![feature(no_core, lang_items)]
1212#![no_core]
1313
14#[lang="sized"]
15trait Sized { }
16#[lang="copy"]
17trait Copy { }
14#[lang = "sized"]
15trait Sized {}
16#[lang = "copy"]
17trait Copy {}
1818
1919impl Copy for i32 {}
2020
tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs+5-5
......@@ -7,14 +7,14 @@
77//@ [x86_64] needs-llvm-components:
88//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
99
10#![crate_type="lib"]
10#![crate_type = "lib"]
1111#![feature(no_core, lang_items)]
1212#![no_core]
1313
14#[lang="sized"]
15trait Sized { }
16#[lang="copy"]
17trait Copy { }
14#[lang = "sized"]
15trait Sized {}
16#[lang = "copy"]
17trait Copy {}
1818
1919impl Copy for i32 {}
2020
tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs+23-25
......@@ -7,30 +7,32 @@
77//@ [x86_64] needs-llvm-components:
88//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
99
10#![crate_type="lib"]
10#![crate_type = "lib"]
1111#![feature(arbitrary_self_types, no_core, lang_items)]
1212#![no_core]
1313
14#[lang="sized"]
15trait Sized { }
16#[lang="copy"]
17trait Copy { }
18#[lang="receiver"]
19trait Receiver { }
20#[lang="dispatch_from_dyn"]
21trait DispatchFromDyn<T> { }
14#[lang = "sized"]
15trait Sized {}
16#[lang = "copy"]
17trait Copy {}
18#[lang = "receiver"]
19trait Receiver {}
20#[lang = "dispatch_from_dyn"]
21trait DispatchFromDyn<T> {}
2222impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
2323#[lang = "unsize"]
24trait Unsize<T: ?Sized> { }
24trait Unsize<T: ?Sized> {}
2525#[lang = "coerce_unsized"]
26pub trait CoerceUnsized<T: ?Sized> { }
26pub trait CoerceUnsized<T: ?Sized> {}
2727impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
28#[lang="freeze"]
29trait Freeze { }
30#[lang="drop_in_place"]
31fn drop_in_place_fn<T>() { }
32#[lang="drop"]
33trait Drop { fn drop(&mut self); }
28#[lang = "freeze"]
29trait Freeze {}
30#[lang = "drop_in_place"]
31fn drop_in_place_fn<T>() {}
32#[lang = "drop"]
33trait Drop {
34 fn drop(&mut self);
35}
3436
3537pub trait Trait1 {
3638 fn foo(&self);
......@@ -39,8 +41,7 @@ pub trait Trait1 {
3941pub struct Type1;
4042
4143impl Trait1 for Type1 {
42 fn foo(&self) {
43 }
44 fn foo(&self) {}
4445}
4546
4647pub trait Trait2<T> {
......@@ -50,8 +51,7 @@ pub trait Trait2<T> {
5051pub struct Type2;
5152
5253impl Trait2<i32> for Type2 {
53 fn bar(&self) {
54 }
54 fn bar(&self) {}
5555}
5656
5757pub trait Trait3<T> {
......@@ -61,8 +61,7 @@ pub trait Trait3<T> {
6161pub struct Type3;
6262
6363impl<T, U> Trait3<U> for T {
64 fn baz(&self, _: &U) {
65 }
64 fn baz(&self, _: &U) {}
6665}
6766
6867pub trait Trait4<'a, T> {
......@@ -88,8 +87,7 @@ pub struct Type5;
8887impl Copy for Type5 {}
8988
9089impl<T, U, const N: usize> Trait5<U, N> for T {
91 fn quux(&self, _: &[U; N]) {
92 }
90 fn quux(&self, _: &[U; N]) {}
9391}
9492
9593pub fn foo1(a: &dyn Trait1) {
tests/codegen/sanitizer/memory-track-origins.rs+1-1
......@@ -11,7 +11,7 @@
1111//@[MSAN-1-LTO] compile-flags: -Zsanitizer-memory-track-origins=1 -C lto=fat
1212//@[MSAN-2-LTO] compile-flags: -Zsanitizer-memory-track-origins -C lto=fat
1313
14#![crate_type="lib"]
14#![crate_type = "lib"]
1515
1616// MSAN-0-NOT: @__msan_track_origins
1717// MSAN-1: @__msan_track_origins = weak_odr {{.*}}constant i32 1
tests/codegen/sanitizer/no-sanitize-inlining.rs+1-1
......@@ -8,7 +8,7 @@
88//@[ASAN] compile-flags: -Zsanitizer=address
99//@[LSAN] compile-flags: -Zsanitizer=leak
1010
11#![crate_type="lib"]
11#![crate_type = "lib"]
1212#![feature(no_sanitize)]
1313
1414// ASAN-LABEL: define void @test
tests/codegen/sanitizer/no-sanitize.rs+1-1
......@@ -4,7 +4,7 @@
44//@ needs-sanitizer-address
55//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88#![feature(no_sanitize)]
99
1010// CHECK-LABEL: ; no_sanitize::unsanitized
tests/codegen/set-discriminant-invalid.rs+5-13
......@@ -7,17 +7,12 @@ pub struct TokioError {
77 b: bool,
88}
99pub enum Error {
10 Api {
11 source: ApiError,
12 },
10 Api { source: ApiError },
1311 Ethereum,
14 Tokio {
15 source: TokioError,
16 },
12 Tokio { source: TokioError },
1713}
1814struct Api;
19impl IntoError<Error> for Api
20{
15impl IntoError<Error> for Api {
2116 type Source = ApiError;
2217 // CHECK-LABEL: @into_error
2318 // CHECK: llvm.trap()
......@@ -27,14 +22,11 @@ impl IntoError<Error> for Api
2722 // CHECK-NEXT: ret
2823 #[no_mangle]
2924 fn into_error(self, error: Self::Source) -> Error {
30 Error::Api {
31 source: error,
32 }
25 Error::Api { source: error }
3326 }
3427}
3528
36pub trait IntoError<E>
37{
29pub trait IntoError<E> {
3830 /// The underlying error
3931 type Source;
4032
tests/codegen/simd/issue-120720-reduce-nan.rs+2-3
......@@ -15,8 +15,7 @@ pub unsafe fn demo() -> bool {
1515 // CHECK: %0 = tail call reassoc double @llvm.vector.reduce.fadd.v8f64(
1616 // CHECK: %_0.i = fcmp uno double %0, 0.000000e+00
1717 // CHECK: ret i1 %_0.i
18 let res = unsafe {
19 _mm512_reduce_add_pd(_mm512_set_pd(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, f64::NAN))
20 };
18 let res =
19 unsafe { _mm512_reduce_add_pd(_mm512_set_pd(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, f64::NAN)) };
2120 res.is_nan()
2221}
tests/codegen/simd/swap-simd-types.rs+9-9
......@@ -13,18 +13,18 @@ use core::arch::x86_64::__m256;
1313// CHECK-LABEL: @swap_single_m256
1414#[no_mangle]
1515pub fn swap_single_m256(x: &mut __m256, y: &mut __m256) {
16// CHECK-NOT: alloca
17// CHECK: load <8 x float>{{.+}}align 32
18// CHECK: store <8 x float>{{.+}}align 32
16 // CHECK-NOT: alloca
17 // CHECK: load <8 x float>{{.+}}align 32
18 // CHECK: store <8 x float>{{.+}}align 32
1919 swap(x, y)
2020}
2121
2222// CHECK-LABEL: @swap_m256_slice
2323#[no_mangle]
2424pub fn swap_m256_slice(x: &mut [__m256], y: &mut [__m256]) {
25// CHECK-NOT: alloca
26// CHECK: load <8 x float>{{.+}}align 32
27// CHECK: store <8 x float>{{.+}}align 32
25 // CHECK-NOT: alloca
26 // CHECK: load <8 x float>{{.+}}align 32
27 // CHECK: store <8 x float>{{.+}}align 32
2828 if x.len() == y.len() {
2929 x.swap_with_slice(y);
3030 }
......@@ -33,8 +33,8 @@ pub fn swap_m256_slice(x: &mut [__m256], y: &mut [__m256]) {
3333// CHECK-LABEL: @swap_bytes32
3434#[no_mangle]
3535pub fn swap_bytes32(x: &mut [u8; 32], y: &mut [u8; 32]) {
36// CHECK-NOT: alloca
37// CHECK: load <32 x i8>{{.+}}align 1
38// CHECK: store <32 x i8>{{.+}}align 1
36 // CHECK-NOT: alloca
37 // CHECK: load <32 x i8>{{.+}}align 1
38 // CHECK: store <32 x i8>{{.+}}align 1
3939 swap(x, y)
4040}
tests/codegen/slice-position-bounds-check.rs+2-8
......@@ -3,9 +3,7 @@
33
44fn search<T: Ord + Eq>(arr: &mut [T], a: &T) -> Result<usize, ()> {
55 match arr.iter().position(|x| x == a) {
6 Some(p) => {
7 Ok(p)
8 },
6 Some(p) => Ok(p),
97 None => Err(()),
108 }
119}
......@@ -15,11 +13,7 @@ fn search<T: Ord + Eq>(arr: &mut [T], a: &T) -> Result<usize, ()> {
1513pub fn position_no_bounds_check(y: &mut [u32], x: &u32, z: &u32) -> bool {
1614 // This contains "call assume" so we cannot just rule out all calls
1715 // CHECK-NOT: panic_bounds_check
18 if let Ok(p) = search(y, x) {
19 y[p] == *z
20 } else {
21 false
22 }
16 if let Ok(p) = search(y, x) { y[p] == *z } else { false }
2317}
2418
2519// just to make sure that panicking really emits "panic_bounds_check" somewhere in the IR
tests/codegen/slice-windows-no-bounds-check.rs+1-4
......@@ -12,10 +12,7 @@ pub fn naive_string_search(haystack: &str, needle: &str) -> Option<usize> {
1212 }
1313 // CHECK-NOT: panic
1414 // CHECK-NOT: fail
15 haystack
16 .as_bytes()
17 .windows(needle.len())
18 .position(|sub| sub == needle.as_bytes())
15 haystack.as_bytes().windows(needle.len()).position(|sub| sub == needle.as_bytes())
1916}
2017
2118// CHECK-LABEL: @next
tests/codegen/some-abis-do-extend-params-to-32-bits.rs+54-19
......@@ -24,9 +24,12 @@
2424#![no_std]
2525#![no_core]
2626
27#[lang="sized"] trait Sized { }
28#[lang="freeze"] trait Freeze { }
29#[lang="copy"] trait Copy { }
27#[lang = "sized"]
28trait Sized {}
29#[lang = "freeze"]
30trait Freeze {}
31#[lang = "copy"]
32trait Copy {}
3033
3134// The patterns in this file are written in the style of a table to make the
3235// uniformities and distinctions more apparent.
......@@ -40,7 +43,8 @@
4043// aarch64-linux: void @c_arg_u8(i8 %_a)
4144// arm: void @c_arg_u8(i8 zeroext %_a)
4245// riscv: void @c_arg_u8(i8 zeroext %_a)
43#[no_mangle] pub extern "C" fn c_arg_u8(_a: u8) { }
46#[no_mangle]
47pub extern "C" fn c_arg_u8(_a: u8) {}
4448
4549// x86_64: void @c_arg_u16(i16 zeroext %_a)
4650// i686: void @c_arg_u16(i16 zeroext %_a)
......@@ -49,7 +53,8 @@
4953// aarch64-linux: void @c_arg_u16(i16 %_a)
5054// arm: void @c_arg_u16(i16 zeroext %_a)
5155// riscv: void @c_arg_u16(i16 zeroext %_a)
52#[no_mangle] pub extern "C" fn c_arg_u16(_a: u16) { }
56#[no_mangle]
57pub extern "C" fn c_arg_u16(_a: u16) {}
5358
5459// x86_64: void @c_arg_u32(i32 %_a)
5560// i686: void @c_arg_u32(i32 %_a)
......@@ -58,7 +63,8 @@
5863// aarch64-linux: void @c_arg_u32(i32 %_a)
5964// arm: void @c_arg_u32(i32 %_a)
6065// riscv: void @c_arg_u32(i32 signext %_a)
61#[no_mangle] pub extern "C" fn c_arg_u32(_a: u32) { }
66#[no_mangle]
67pub extern "C" fn c_arg_u32(_a: u32) {}
6268
6369// x86_64: void @c_arg_u64(i64 %_a)
6470// i686: void @c_arg_u64(i64 %_a)
......@@ -67,7 +73,8 @@
6773// aarch64-linux: void @c_arg_u64(i64 %_a)
6874// arm: void @c_arg_u64(i64 %_a)
6975// riscv: void @c_arg_u64(i64 %_a)
70#[no_mangle] pub extern "C" fn c_arg_u64(_a: u64) { }
76#[no_mangle]
77pub extern "C" fn c_arg_u64(_a: u64) {}
7178
7279// x86_64: void @c_arg_i8(i8 signext %_a)
7380// i686: void @c_arg_i8(i8 signext %_a)
......@@ -76,7 +83,8 @@
7683// aarch64-linux: void @c_arg_i8(i8 %_a)
7784// arm: void @c_arg_i8(i8 signext %_a)
7885// riscv: void @c_arg_i8(i8 signext %_a)
79#[no_mangle] pub extern "C" fn c_arg_i8(_a: i8) { }
86#[no_mangle]
87pub extern "C" fn c_arg_i8(_a: i8) {}
8088
8189// x86_64: void @c_arg_i16(i16 signext %_a)
8290// i686: void @c_arg_i16(i16 signext %_a)
......@@ -85,7 +93,8 @@
8593// aarch64-linux: void @c_arg_i16(i16 %_a)
8694// arm: void @c_arg_i16(i16 signext %_a)
8795// riscv: void @c_arg_i16(i16 signext %_a)
88#[no_mangle] pub extern "C" fn c_arg_i16(_a: i16) { }
96#[no_mangle]
97pub extern "C" fn c_arg_i16(_a: i16) {}
8998
9099// x86_64: void @c_arg_i32(i32 %_a)
91100// i686: void @c_arg_i32(i32 %_a)
......@@ -94,7 +103,8 @@
94103// aarch64-linux: void @c_arg_i32(i32 %_a)
95104// arm: void @c_arg_i32(i32 %_a)
96105// riscv: void @c_arg_i32(i32 signext %_a)
97#[no_mangle] pub extern "C" fn c_arg_i32(_a: i32) { }
106#[no_mangle]
107pub extern "C" fn c_arg_i32(_a: i32) {}
98108
99109// x86_64: void @c_arg_i64(i64 %_a)
100110// i686: void @c_arg_i64(i64 %_a)
......@@ -103,7 +113,8 @@
103113// aarch64-linux: void @c_arg_i64(i64 %_a)
104114// arm: void @c_arg_i64(i64 %_a)
105115// riscv: void @c_arg_i64(i64 %_a)
106#[no_mangle] pub extern "C" fn c_arg_i64(_a: i64) { }
116#[no_mangle]
117pub extern "C" fn c_arg_i64(_a: i64) {}
107118
108119// x86_64: zeroext i8 @c_ret_u8()
109120// i686: zeroext i8 @c_ret_u8()
......@@ -112,7 +123,10 @@
112123// aarch64-linux: i8 @c_ret_u8()
113124// arm: zeroext i8 @c_ret_u8()
114125// riscv: zeroext i8 @c_ret_u8()
115#[no_mangle] pub extern "C" fn c_ret_u8() -> u8 { 0 }
126#[no_mangle]
127pub extern "C" fn c_ret_u8() -> u8 {
128 0
129}
116130
117131// x86_64: zeroext i16 @c_ret_u16()
118132// i686: zeroext i16 @c_ret_u16()
......@@ -121,7 +135,10 @@
121135// aarch64-linux: i16 @c_ret_u16()
122136// arm: zeroext i16 @c_ret_u16()
123137// riscv: zeroext i16 @c_ret_u16()
124#[no_mangle] pub extern "C" fn c_ret_u16() -> u16 { 0 }
138#[no_mangle]
139pub extern "C" fn c_ret_u16() -> u16 {
140 0
141}
125142
126143// x86_64: i32 @c_ret_u32()
127144// i686: i32 @c_ret_u32()
......@@ -130,7 +147,10 @@
130147// aarch64-linux: i32 @c_ret_u32()
131148// arm: i32 @c_ret_u32()
132149// riscv: signext i32 @c_ret_u32()
133#[no_mangle] pub extern "C" fn c_ret_u32() -> u32 { 0 }
150#[no_mangle]
151pub extern "C" fn c_ret_u32() -> u32 {
152 0
153}
134154
135155// x86_64: i64 @c_ret_u64()
136156// i686: i64 @c_ret_u64()
......@@ -139,7 +159,10 @@
139159// aarch64-linux: i64 @c_ret_u64()
140160// arm: i64 @c_ret_u64()
141161// riscv: i64 @c_ret_u64()
142#[no_mangle] pub extern "C" fn c_ret_u64() -> u64 { 0 }
162#[no_mangle]
163pub extern "C" fn c_ret_u64() -> u64 {
164 0
165}
143166
144167// x86_64: signext i8 @c_ret_i8()
145168// i686: signext i8 @c_ret_i8()
......@@ -148,7 +171,10 @@
148171// aarch64-linux: i8 @c_ret_i8()
149172// arm: signext i8 @c_ret_i8()
150173// riscv: signext i8 @c_ret_i8()
151#[no_mangle] pub extern "C" fn c_ret_i8() -> i8 { 0 }
174#[no_mangle]
175pub extern "C" fn c_ret_i8() -> i8 {
176 0
177}
152178
153179// x86_64: signext i16 @c_ret_i16()
154180// i686: signext i16 @c_ret_i16()
......@@ -157,7 +183,10 @@
157183// aarch64-linux: i16 @c_ret_i16()
158184// arm: signext i16 @c_ret_i16()
159185// riscv: signext i16 @c_ret_i16()
160#[no_mangle] pub extern "C" fn c_ret_i16() -> i16 { 0 }
186#[no_mangle]
187pub extern "C" fn c_ret_i16() -> i16 {
188 0
189}
161190
162191// x86_64: i32 @c_ret_i32()
163192// i686: i32 @c_ret_i32()
......@@ -166,7 +195,10 @@
166195// aarch64-linux: i32 @c_ret_i32()
167196// arm: i32 @c_ret_i32()
168197// riscv: signext i32 @c_ret_i32()
169#[no_mangle] pub extern "C" fn c_ret_i32() -> i32 { 0 }
198#[no_mangle]
199pub extern "C" fn c_ret_i32() -> i32 {
200 0
201}
170202
171203// x86_64: i64 @c_ret_i64()
172204// i686: i64 @c_ret_i64()
......@@ -175,7 +207,10 @@
175207// aarch64-linux: i64 @c_ret_i64()
176208// arm: i64 @c_ret_i64()
177209// riscv: i64 @c_ret_i64()
178#[no_mangle] pub extern "C" fn c_ret_i64() -> i64 { 0 }
210#[no_mangle]
211pub extern "C" fn c_ret_i64() -> i64 {
212 0
213}
179214
180215const C_SOURCE_FILE: &'static str = r##"
181216#include <stdlib.h>
tests/codegen/sparc-struct-abi.rs+8-11
......@@ -6,12 +6,12 @@
66#![feature(no_core, lang_items)]
77#![no_core]
88
9#[lang="sized"]
10trait Sized { }
11#[lang="freeze"]
12trait Freeze { }
13#[lang="copy"]
14trait Copy { }
9#[lang = "sized"]
10trait Sized {}
11#[lang = "freeze"]
12trait Freeze {}
13#[lang = "copy"]
14trait Copy {}
1515
1616#[repr(C)]
1717pub struct Bool {
......@@ -26,7 +26,6 @@ pub extern "C" fn structbool() -> Bool {
2626 Bool { b: true }
2727}
2828
29
3029#[repr(C)]
3130pub struct BoolFloat {
3231 b: bool,
......@@ -44,8 +43,7 @@ pub extern "C" fn structboolfloat() -> BoolFloat {
4443// CHECK: define void @structboolfloat_input({ i32, float } inreg %0)
4544// CHECK-NEXT: start:
4645#[no_mangle]
47pub extern "C" fn structboolfloat_input(a: BoolFloat) { }
48
46pub extern "C" fn structboolfloat_input(a: BoolFloat) {}
4947
5048#[repr(C)]
5149pub struct ShortDouble {
......@@ -64,8 +62,7 @@ pub extern "C" fn structshortdouble() -> ShortDouble {
6462// CHECK: define void @structshortdouble_input({ i64, double } %0)
6563// CHECK-NEXT: start:
6664#[no_mangle]
67pub extern "C" fn structshortdouble_input(a: ShortDouble) { }
68
65pub extern "C" fn structshortdouble_input(a: ShortDouble) {}
6966
7067#[repr(C)]
7168pub struct FloatLongFloat {
tests/codegen/split-lto-unit.rs+2-3
......@@ -3,9 +3,8 @@
33//@ needs-sanitizer-cfi
44//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsplit-lto-unit
55
6#![crate_type="lib"]
6#![crate_type = "lib"]
77
8pub fn foo() {
9}
8pub fn foo() {}
109
1110// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1}
tests/codegen/sroa-fragment-debuginfo.rs+11-11
......@@ -13,13 +13,13 @@ pub struct ExtraSlice<'input> {
1313
1414#[no_mangle]
1515pub fn extra(s: &[u8]) {
16// CHECK: void @extra(
17// CHECK: %slice.dbg.spill1 = alloca [4 x i8],
18// CHECK: %slice.dbg.spill = alloca [16 x i8],
19// CHECK: %s.dbg.spill = alloca [16 x i8],
20// CHECK: dbg{{.}}declare({{(metadata )?}}ptr %s.dbg.spill, {{(metadata )?}}![[S_EXTRA:.*]], {{(metadata )?}}!DIExpression()
21// CHECK: dbg{{.}}declare({{(metadata )?}}ptr %slice.dbg.spill, {{(metadata )?}}![[SLICE_EXTRA:.*]], {{(metadata )?}}!DIExpression(DW_OP_LLVM_fragment, 0, 128)
22// CHECK: dbg{{.}}declare({{(metadata )?}}ptr %slice.dbg.spill1, {{(metadata )?}}![[SLICE_EXTRA]], {{(metadata )?}}!DIExpression(DW_OP_LLVM_fragment, 128, 32)
16 // CHECK: void @extra(
17 // CHECK: %slice.dbg.spill1 = alloca [4 x i8],
18 // CHECK: %slice.dbg.spill = alloca [16 x i8],
19 // CHECK: %s.dbg.spill = alloca [16 x i8],
20 // CHECK: dbg{{.}}declare({{(metadata )?}}ptr %s.dbg.spill, {{(metadata )?}}![[S_EXTRA:.*]], {{(metadata )?}}!DIExpression()
21 // CHECK: dbg{{.}}declare({{(metadata )?}}ptr %slice.dbg.spill, {{(metadata )?}}![[SLICE_EXTRA:.*]], {{(metadata )?}}!DIExpression(DW_OP_LLVM_fragment, 0, 128)
22 // CHECK: dbg{{.}}declare({{(metadata )?}}ptr %slice.dbg.spill1, {{(metadata )?}}![[SLICE_EXTRA]], {{(metadata )?}}!DIExpression(DW_OP_LLVM_fragment, 128, 32)
2323 let slice = ExtraSlice { slice: s, extra: s.len() as u32 };
2424}
2525
......@@ -35,10 +35,10 @@ pub fn zst(s: &[u8]) {
3535 // The field `extra` is a ZST. The fragment for the field `slice` encompasses the whole
3636 // variable, so is not a fragment. In that case, the variable must have no fragment.
3737
38// CHECK: void @zst(
39// CHECK-NOT: dbg{{.}}declare({{(metadata )?}}ptr %slice.dbg.spill, {{(metadata )?}}!{}, {{(metadata )?}}!DIExpression(DW_OP_LLVM_fragment,
40// CHECK: dbg{{.}}declare({{(metadata )?}}ptr %{{.*}}, {{(metadata )?}}![[SLICE_ZST:.*]], {{(metadata )?}}!DIExpression()
41// CHECK-NOT: dbg{{.}}declare({{(metadata )?}}ptr %{{.*}}, {{(metadata )?}}![[SLICE_ZST]],
38 // CHECK: void @zst(
39 // CHECK-NOT: dbg{{.}}declare({{(metadata )?}}ptr %slice.dbg.spill, {{(metadata )?}}!{}, {{(metadata )?}}!DIExpression(DW_OP_LLVM_fragment,
40 // CHECK: dbg{{.}}declare({{(metadata )?}}ptr %{{.*}}, {{(metadata )?}}![[SLICE_ZST:.*]], {{(metadata )?}}!DIExpression()
41 // CHECK-NOT: dbg{{.}}declare({{(metadata )?}}ptr %{{.*}}, {{(metadata )?}}![[SLICE_ZST]],
4242 let slice = ZstSlice { slice: s, extra: Zst };
4343}
4444
tests/codegen/stack-probes-inline.rs+2-2
......@@ -27,6 +27,6 @@ trait Sized {}
2727
2828#[no_mangle]
2929pub fn foo() {
30// CHECK: @foo() unnamed_addr #0
31// CHECK: attributes #0 = { {{.*}}"probe-stack"="inline-asm"{{.*}} }
30 // CHECK: @foo() unnamed_addr #0
31 // CHECK: attributes #0 = { {{.*}}"probe-stack"="inline-asm"{{.*}} }
3232}
tests/codegen/static-relocation-model-msvc.rs+1-3
......@@ -20,7 +20,5 @@ extern crate extern_decl;
2020
2121#[no_mangle]
2222pub fn access_extern() -> u8 {
23 unsafe {
24 extern_decl::extern_fn() + extern_decl::extern_static
25 }
23 unsafe { extern_decl::extern_fn() + extern_decl::extern_static }
2624}
tests/codegen/stores.rs+12-12
......@@ -4,10 +4,10 @@
44#![crate_type = "lib"]
55
66pub struct Bytes {
7 a: u8,
8 b: u8,
9 c: u8,
10 d: u8,
7 a: u8,
8 b: u8,
9 c: u8,
10 d: u8,
1111}
1212
1313// CHECK-LABEL: small_array_alignment
......@@ -15,10 +15,10 @@ pub struct Bytes {
1515// dependent alignment
1616#[no_mangle]
1717pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) {
18// CHECK: [[TMP:%.+]] = alloca [4 x i8], align 4
19// CHECK: %y = alloca [4 x i8], align 1
20// CHECK: store i32 %0, ptr [[TMP]]
21// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 {{.+}}, ptr align 4 {{.+}}, i{{[0-9]+}} 4, i1 false)
18 // CHECK: [[TMP:%.+]] = alloca [4 x i8], align 4
19 // CHECK: %y = alloca [4 x i8], align 1
20 // CHECK: store i32 %0, ptr [[TMP]]
21 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 {{.+}}, ptr align 4 {{.+}}, i{{[0-9]+}} 4, i1 false)
2222 *x = y;
2323}
2424
......@@ -27,9 +27,9 @@ pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) {
2727// dependent alignment
2828#[no_mangle]
2929pub fn small_struct_alignment(x: &mut Bytes, y: Bytes) {
30// CHECK: [[TMP:%.+]] = alloca [4 x i8], align 4
31// CHECK: %y = alloca [4 x i8], align 1
32// CHECK: store i32 %0, ptr [[TMP]]
33// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 {{.+}}, ptr align 4 {{.+}}, i{{[0-9]+}} 4, i1 false)
30 // CHECK: [[TMP:%.+]] = alloca [4 x i8], align 4
31 // CHECK: %y = alloca [4 x i8], align 1
32 // CHECK: store i32 %0, ptr [[TMP]]
33 // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 {{.+}}, ptr align 4 {{.+}}, i{{[0-9]+}} 4, i1 false)
3434 *x = y;
3535}
tests/codegen/swap-large-types.rs+16-16
......@@ -4,7 +4,7 @@
44#![crate_type = "lib"]
55
66use std::mem::swap;
7use std::ptr::{read, copy_nonoverlapping, write};
7use std::ptr::{copy_nonoverlapping, read, write};
88
99type KeccakBuffer = [[u64; 5]; 5];
1010
......@@ -15,7 +15,7 @@ type KeccakBuffer = [[u64; 5]; 5];
1515// CHECK-LABEL: @swap_basic
1616#[no_mangle]
1717pub fn swap_basic(x: &mut KeccakBuffer, y: &mut KeccakBuffer) {
18// CHECK: alloca [200 x i8]
18 // CHECK: alloca [200 x i8]
1919
2020 // SAFETY: exclusive references are always valid to read/write,
2121 // are non-overlapping, and nothing here panics so it's drop-safe.
......@@ -32,9 +32,9 @@ pub fn swap_basic(x: &mut KeccakBuffer, y: &mut KeccakBuffer) {
3232// CHECK-LABEL: @swap_std
3333#[no_mangle]
3434pub fn swap_std(x: &mut KeccakBuffer, y: &mut KeccakBuffer) {
35// CHECK-NOT: alloca
36// CHECK: load <{{[0-9]+}} x i64>
37// CHECK: store <{{[0-9]+}} x i64>
35 // CHECK-NOT: alloca
36 // CHECK: load <{{[0-9]+}} x i64>
37 // CHECK: store <{{[0-9]+}} x i64>
3838 swap(x, y)
3939}
4040
......@@ -44,9 +44,9 @@ pub fn swap_std(x: &mut KeccakBuffer, y: &mut KeccakBuffer) {
4444// CHECK-LABEL: @swap_slice
4545#[no_mangle]
4646pub fn swap_slice(x: &mut [KeccakBuffer], y: &mut [KeccakBuffer]) {
47// CHECK-NOT: alloca
48// CHECK: load <{{[0-9]+}} x i64>
49// CHECK: store <{{[0-9]+}} x i64>
47 // CHECK-NOT: alloca
48 // CHECK: load <{{[0-9]+}} x i64>
49 // CHECK: store <{{[0-9]+}} x i64>
5050 if x.len() == y.len() {
5151 x.swap_with_slice(y);
5252 }
......@@ -59,9 +59,9 @@ type OneKilobyteBuffer = [u8; 1024];
5959// CHECK-LABEL: @swap_1kb_slices
6060#[no_mangle]
6161pub fn swap_1kb_slices(x: &mut [OneKilobyteBuffer], y: &mut [OneKilobyteBuffer]) {
62// CHECK-NOT: alloca
63// CHECK: load <{{[0-9]+}} x i8>
64// CHECK: store <{{[0-9]+}} x i8>
62 // CHECK-NOT: alloca
63 // CHECK: load <{{[0-9]+}} x i8>
64 // CHECK: store <{{[0-9]+}} x i8>
6565 if x.len() == y.len() {
6666 x.swap_with_slice(y);
6767 }
......@@ -81,10 +81,10 @@ pub struct BigButHighlyAligned([u8; 64 * 3]);
8181// CHECK-LABEL: @swap_big_aligned
8282#[no_mangle]
8383pub fn swap_big_aligned(x: &mut BigButHighlyAligned, y: &mut BigButHighlyAligned) {
84// CHECK-NOT: call void @llvm.memcpy
85// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192)
86// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192)
87// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192)
88// CHECK-NOT: call void @llvm.memcpy
84 // CHECK-NOT: call void @llvm.memcpy
85 // CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192)
86 // CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192)
87 // CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192)
88 // CHECK-NOT: call void @llvm.memcpy
8989 swap(x, y)
9090}
tests/codegen/target-feature-overrides.rs+7-8
......@@ -9,7 +9,6 @@
99#![crate_type = "lib"]
1010#![no_core]
1111
12
1312#[lang = "sized"]
1413trait Sized {}
1514#[lang = "copy"]
......@@ -23,19 +22,19 @@ extern "C" {
2322#[target_feature(enable = "avx")]
2423#[no_mangle]
2524pub unsafe fn apple() -> u32 {
26// CHECK-LABEL: @apple()
27// CHECK-SAME: [[APPLEATTRS:#[0-9]+]] {
28// CHECK: {{.*}}call{{.*}}@peach
25 // CHECK-LABEL: @apple()
26 // CHECK-SAME: [[APPLEATTRS:#[0-9]+]] {
27 // CHECK: {{.*}}call{{.*}}@peach
2928 peach()
3029}
3130
3231// target features same as global
3332#[no_mangle]
3433pub unsafe fn banana() -> u32 {
35// CHECK-LABEL: @banana()
36// CHECK-SAME: [[BANANAATTRS:#[0-9]+]] {
37// COMPAT: {{.*}}call{{.*}}@peach
38// INCOMPAT: {{.*}}call{{.*}}@apple
34 // CHECK-LABEL: @banana()
35 // CHECK-SAME: [[BANANAATTRS:#[0-9]+]] {
36 // COMPAT: {{.*}}call{{.*}}@peach
37 // INCOMPAT: {{.*}}call{{.*}}@apple
3938 apple() // Compatible for inline in COMPAT revision and can't be inlined in INCOMPAT
4039}
4140
tests/codegen/thin-lto.rs+1-2
......@@ -3,5 +3,4 @@
33
44// CHECK: main
55
6pub fn main() {
7}
6pub fn main() {}
tests/codegen/tied-features-strength.rs-1
......@@ -19,7 +19,6 @@
1919//@ [ENABLE_NEON] compile-flags: -C target-feature=+neon -Copt-level=0
2020// ENABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+fp-armv8,?)|(\+neon,?))*}}" }
2121
22
2322#![feature(no_core, lang_items)]
2423#![no_core]
2524
tests/codegen/to_vec.rs+2-2
......@@ -5,6 +5,6 @@
55// CHECK-LABEL: @copy_to_vec
66#[no_mangle]
77fn copy_to_vec(s: &[u64]) -> Vec<u64> {
8 s.to_vec()
9 // CHECK: call void @llvm.memcpy
8 s.to_vec()
9 // CHECK: call void @llvm.memcpy
1010}
tests/codegen/transmute-optimized.rs+8-2
......@@ -5,7 +5,9 @@
55// destination types for transmutes.
66
77#[repr(u32)]
8pub enum AlwaysZero32 { X = 0 }
8pub enum AlwaysZero32 {
9 X = 0,
10}
911
1012// CHECK-LABEL: i32 @issue_109958(i32
1113#[no_mangle]
......@@ -81,7 +83,11 @@ pub fn div_transmute_nonzero(a: u32, b: std::num::NonZero<i32>) -> u32 {
8183}
8284
8385#[repr(i8)]
84pub enum OneTwoThree { One = 1, Two = 2, Three = 3 }
86pub enum OneTwoThree {
87 One = 1,
88 Two = 2,
89 Three = 3,
90}
8591
8692// CHECK-LABEL: i8 @ordering_transmute_onetwothree(i8
8793#[no_mangle]
tests/codegen/try_identity.rs+3-3
......@@ -13,9 +13,9 @@ type R = Result<u64, i32>;
1313// optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not.
1414#[no_mangle]
1515pub fn try_identity(x: R) -> R {
16// CHECK: start:
17// FIXME(JakobDegen): Broken by deaggregation change CHECK-NOT\: br {{.*}}
18// CHECK ret void
16 // CHECK: start:
17 // FIXME(JakobDegen): Broken by deaggregation change CHECK-NOT\: br {{.*}}
18 // CHECK ret void
1919 let y = match into_result(x) {
2020 Err(e) => return from_error(From::from(e)),
2121 Ok(v) => v,
tests/codegen/try_question_mark_nop.rs+6-16
......@@ -4,7 +4,7 @@
44#![crate_type = "lib"]
55#![feature(try_blocks)]
66
7use std::ops::ControlFlow::{self, Continue, Break};
7use std::ops::ControlFlow::{self, Break, Continue};
88use std::ptr::NonNull;
99
1010// CHECK-LABEL: @option_nop_match_32
......@@ -27,9 +27,7 @@ pub fn option_nop_traits_32(x: Option<u32>) -> Option<u32> {
2727 // CHECK-NEXT: insertvalue { i32, i32 }
2828 // CHECK-NEXT: insertvalue { i32, i32 }
2929 // CHECK-NEXT: ret { i32, i32 }
30 try {
31 x?
32 }
30 try { x? }
3331}
3432
3533// CHECK-LABEL: @result_nop_match_32
......@@ -52,9 +50,7 @@ pub fn result_nop_traits_32(x: Result<i32, u32>) -> Result<i32, u32> {
5250 // CHECK-NEXT: insertvalue { i32, i32 }
5351 // CHECK-NEXT: insertvalue { i32, i32 }
5452 // CHECK-NEXT: ret { i32, i32 }
55 try {
56 x?
57 }
53 try { x? }
5854}
5955
6056// CHECK-LABEL: @result_nop_match_64
......@@ -77,9 +73,7 @@ pub fn result_nop_traits_64(x: Result<i64, u64>) -> Result<i64, u64> {
7773 // CHECK-NEXT: insertvalue { i64, i64 }
7874 // CHECK-NEXT: insertvalue { i64, i64 }
7975 // CHECK-NEXT: ret { i64, i64 }
80 try {
81 x?
82 }
76 try { x? }
8377}
8478
8579// CHECK-LABEL: @result_nop_match_ptr
......@@ -102,9 +96,7 @@ pub fn result_nop_traits_ptr(x: Result<u64, NonNull<()>>) -> Result<u64, NonNull
10296 // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr }
10397 // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr }
10498 // CHECK-NEXT: ret
105 try {
106 x?
107 }
99 try { x? }
108100}
109101
110102// CHECK-LABEL: @control_flow_nop_match_32
......@@ -127,7 +119,5 @@ pub fn control_flow_nop_traits_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32,
127119 // CHECK-NEXT: insertvalue { i32, i32 }
128120 // CHECK-NEXT: insertvalue { i32, i32 }
129121 // CHECK-NEXT: ret { i32, i32 }
130 try {
131 x?
132 }
122 try { x? }
133123}
tests/codegen/tune-cpu-on-functions.rs+1-1
......@@ -9,7 +9,7 @@
99
1010// CHECK-LABEL: define {{.*}} @exported() {{.*}} #0
1111#[no_mangle]
12pub extern fn exported() {
12pub extern "C" fn exported() {
1313 not_exported();
1414}
1515
tests/codegen/tuple-layout-opt.rs+19-7
......@@ -2,34 +2,46 @@
22
33// Test that tuples get optimized layout, in particular with a ZST in the last field (#63244)
44
5#![crate_type="lib"]
5#![crate_type = "lib"]
66
77type ScalarZstLast = (u128, ());
88// CHECK: define {{(dso_local )?}}i128 @test_ScalarZstLast(i128 %_1)
99#[no_mangle]
10pub fn test_ScalarZstLast(_: ScalarZstLast) -> ScalarZstLast { loop {} }
10pub fn test_ScalarZstLast(_: ScalarZstLast) -> ScalarZstLast {
11 loop {}
12}
1113
1214type ScalarZstFirst = ((), u128);
1315// CHECK: define {{(dso_local )?}}i128 @test_ScalarZstFirst(i128 %_1)
1416#[no_mangle]
15pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { loop {} }
17pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst {
18 loop {}
19}
1620
1721type ScalarPairZstLast = (u8, u128, ());
1822// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1)
1923#[no_mangle]
20pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { loop {} }
24pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast {
25 loop {}
26}
2127
2228type ScalarPairZstFirst = ((), u8, u128);
2329// CHECK: define {{(dso_local )?}}{ i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1)
2430#[no_mangle]
25pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { loop {} }
31pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst {
32 loop {}
33}
2634
2735type ScalarPairLotsOfZsts = ((), u8, (), u128, ());
2836// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1)
2937#[no_mangle]
30pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { loop {} }
38pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts {
39 loop {}
40}
3141
3242type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ());
3343// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1)
3444#[no_mangle]
35pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { loop {} }
45pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting {
46 loop {}
47}
tests/codegen/union-abi.rs+72-23
......@@ -4,7 +4,7 @@
44// This test that using union forward the abi of the inner type, as
55// discussed in #54668
66
7#![crate_type="lib"]
7#![crate_type = "lib"]
88#![feature(repr_simd)]
99
1010#[derive(Copy, Clone)]
......@@ -15,62 +15,111 @@ pub enum Unhab {}
1515pub struct i64x4(i64, i64, i64, i64);
1616
1717#[derive(Copy, Clone)]
18pub union UnionI64x4{ a:(), b: i64x4 }
18pub union UnionI64x4 {
19 a: (),
20 b: i64x4,
21}
1922
2023// CHECK: define {{(dso_local )?}}void @test_UnionI64x4(ptr {{.*}} %_1)
2124#[no_mangle]
22pub fn test_UnionI64x4(_: UnionI64x4) { loop {} }
23
24pub union UnionI64x4_{ a: i64x4, b: (), c:i64x4, d: Unhab, e: ((),()), f: UnionI64x4 }
25pub fn test_UnionI64x4(_: UnionI64x4) {
26 loop {}
27}
28
29pub union UnionI64x4_ {
30 a: i64x4,
31 b: (),
32 c: i64x4,
33 d: Unhab,
34 e: ((), ()),
35 f: UnionI64x4,
36}
2537
2638// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_(ptr {{.*}} %_1)
2739#[no_mangle]
28pub fn test_UnionI64x4_(_: UnionI64x4_) { loop {} }
40pub fn test_UnionI64x4_(_: UnionI64x4_) {
41 loop {}
42}
2943
30pub union UnionI64x4I64{ a: i64x4, b: i64 }
44pub union UnionI64x4I64 {
45 a: i64x4,
46 b: i64,
47}
3148
3249// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64(ptr {{.*}} %_1)
3350#[no_mangle]
34pub fn test_UnionI64x4I64(_: UnionI64x4I64) { loop {} }
51pub fn test_UnionI64x4I64(_: UnionI64x4I64) {
52 loop {}
53}
3554
36pub union UnionI64x4Tuple{ a: i64x4, b: (i64, i64, i64, i64) }
55pub union UnionI64x4Tuple {
56 a: i64x4,
57 b: (i64, i64, i64, i64),
58}
3759
3860// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple(ptr {{.*}} %_1)
3961#[no_mangle]
40pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) { loop {} }
41
62pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) {
63 loop {}
64}
4265
43pub union UnionF32{a:f32}
66pub union UnionF32 {
67 a: f32,
68}
4469
4570// CHECK: define {{(dso_local )?}}float @test_UnionF32(float %_1)
4671#[no_mangle]
47pub fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} }
72pub fn test_UnionF32(_: UnionF32) -> UnionF32 {
73 loop {}
74}
4875
49pub union UnionF32F32{a:f32, b:f32}
76pub union UnionF32F32 {
77 a: f32,
78 b: f32,
79}
5080
5181// CHECK: define {{(dso_local )?}}float @test_UnionF32F32(float %_1)
5282#[no_mangle]
53pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 { loop {} }
83pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 {
84 loop {}
85}
5486
55pub union UnionF32U32{a:f32, b:u32}
87pub union UnionF32U32 {
88 a: f32,
89 b: u32,
90}
5691
5792// CHECK: define {{(dso_local )?}}i32 @test_UnionF32U32(i32{{( %0)?}})
5893#[no_mangle]
59pub fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 { loop {} }
94pub fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 {
95 loop {}
96}
6097
61pub union UnionU128{a:u128}
98pub union UnionU128 {
99 a: u128,
100}
62101// CHECK: define {{(dso_local )?}}i128 @test_UnionU128(i128 %_1)
63102#[no_mangle]
64pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} }
103pub fn test_UnionU128(_: UnionU128) -> UnionU128 {
104 loop {}
105}
65106
66107#[repr(C)]
67pub union CUnionU128{a:u128}
108pub union CUnionU128 {
109 a: u128,
110}
68111// CHECK: define {{(dso_local )?}}void @test_CUnionU128(ptr {{.*}} %_1)
69112#[no_mangle]
70pub fn test_CUnionU128(_: CUnionU128) { loop {} }
113pub fn test_CUnionU128(_: CUnionU128) {
114 loop {}
115}
71116
72pub union UnionBool { b:bool }
117pub union UnionBool {
118 b: bool,
119}
73120// CHECK: define {{(dso_local )?}}noundef zeroext i1 @test_UnionBool(i8 %b)
74121#[no_mangle]
75pub fn test_UnionBool(b: UnionBool) -> bool { unsafe { b.b } }
122pub fn test_UnionBool(b: UnionBool) -> bool {
123 unsafe { b.b }
124}
76125// CHECK: %_0 = trunc i8 %b to i1
tests/codegen/unwind-abis/aapcs-unwind-abi.rs+4-6
......@@ -2,8 +2,8 @@
22//@ compile-flags: --target=armv7-unknown-linux-gnueabihf --crate-type=rlib -Cno-prepopulate-passes
33#![no_core]
44#![feature(no_core, lang_items, c_unwind)]
5#[lang="sized"]
6trait Sized { }
5#[lang = "sized"]
6trait Sized {}
77
88// Test that `nounwind` attributes are correctly applied to exported `aapcs` and
99// `aapcs-unwind` extern functions. `aapcs-unwind` functions MUST NOT have this attribute. We
......@@ -11,13 +11,11 @@ trait Sized { }
1111
1212// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1313#[no_mangle]
14pub extern "aapcs" fn rust_item_that_cannot_unwind() {
15}
14pub extern "aapcs" fn rust_item_that_cannot_unwind() {}
1615
1716// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1817#[no_mangle]
19pub extern "aapcs-unwind" fn rust_item_that_can_unwind() {
20}
18pub extern "aapcs-unwind" fn rust_item_that_can_unwind() {}
2119
2220// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2321// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/c-unwind-abi.rs+2-4
......@@ -10,13 +10,11 @@
1010
1111// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1212#[no_mangle]
13pub extern "C" fn rust_item_that_cannot_unwind() {
14}
13pub extern "C" fn rust_item_that_cannot_unwind() {}
1514
1615// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1716#[no_mangle]
18pub extern "C-unwind" fn rust_item_that_can_unwind() {
19}
17pub extern "C-unwind" fn rust_item_that_can_unwind() {}
2018
2119// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2220// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/cdecl-unwind-abi.rs+2-4
......@@ -10,13 +10,11 @@
1010
1111// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1212#[no_mangle]
13pub extern "cdecl" fn rust_item_that_cannot_unwind() {
14}
13pub extern "cdecl" fn rust_item_that_cannot_unwind() {}
1514
1615// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1716#[no_mangle]
18pub extern "cdecl-unwind" fn rust_item_that_can_unwind() {
19}
17pub extern "cdecl-unwind" fn rust_item_that_can_unwind() {}
2018
2119// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2220// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/fastcall-unwind-abi.rs+4-6
......@@ -2,8 +2,8 @@
22//@ compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -Cno-prepopulate-passes
33#![no_core]
44#![feature(no_core, lang_items, c_unwind)]
5#[lang="sized"]
6trait Sized { }
5#[lang = "sized"]
6trait Sized {}
77
88// Test that `nounwind` attributes are correctly applied to exported `fastcall` and
99// `fastcall-unwind` extern functions. `fastcall-unwind` functions MUST NOT have this attribute. We
......@@ -11,13 +11,11 @@ trait Sized { }
1111
1212// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1313#[no_mangle]
14pub extern "fastcall" fn rust_item_that_cannot_unwind() {
15}
14pub extern "fastcall" fn rust_item_that_cannot_unwind() {}
1615
1716// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1817#[no_mangle]
19pub extern "fastcall-unwind" fn rust_item_that_can_unwind() {
20}
18pub extern "fastcall-unwind" fn rust_item_that_can_unwind() {}
2119
2220// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2321// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/stdcall-unwind-abi.rs+4-6
......@@ -2,8 +2,8 @@
22//@ compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -Cno-prepopulate-passes
33#![no_core]
44#![feature(no_core, lang_items, c_unwind)]
5#[lang="sized"]
6trait Sized { }
5#[lang = "sized"]
6trait Sized {}
77
88// Test that `nounwind` attributes are correctly applied to exported `stdcall` and `stdcall-unwind`
99// extern functions. `stdcall-unwind` functions MUST NOT have this attribute. We disable
......@@ -11,13 +11,11 @@ trait Sized { }
1111
1212// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1313#[no_mangle]
14pub extern "stdcall" fn rust_item_that_cannot_unwind() {
15}
14pub extern "stdcall" fn rust_item_that_cannot_unwind() {}
1615
1716// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1817#[no_mangle]
19pub extern "stdcall-unwind" fn rust_item_that_can_unwind() {
20}
18pub extern "stdcall-unwind" fn rust_item_that_can_unwind() {}
2119
2220// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2321// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/system-unwind-abi.rs+2-4
......@@ -10,13 +10,11 @@
1010
1111// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1212#[no_mangle]
13pub extern "system" fn rust_item_that_cannot_unwind() {
14}
13pub extern "system" fn rust_item_that_cannot_unwind() {}
1514
1615// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1716#[no_mangle]
18pub extern "system-unwind" fn rust_item_that_can_unwind() {
19}
17pub extern "system-unwind" fn rust_item_that_can_unwind() {}
2018
2119// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2220// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/sysv64-unwind-abi.rs+4-6
......@@ -2,8 +2,8 @@
22//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib -Cno-prepopulate-passes
33#![no_core]
44#![feature(no_core, lang_items, c_unwind)]
5#[lang="sized"]
6trait Sized { }
5#[lang = "sized"]
6trait Sized {}
77
88// Test that `nounwind` attributes are correctly applied to exported `sysv64` and
99// `sysv64-unwind` extern functions. `sysv64-unwind` functions MUST NOT have this attribute. We
......@@ -11,13 +11,11 @@ trait Sized { }
1111
1212// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1313#[no_mangle]
14pub extern "sysv64" fn rust_item_that_cannot_unwind() {
15}
14pub extern "sysv64" fn rust_item_that_cannot_unwind() {}
1615
1716// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1817#[no_mangle]
19pub extern "sysv64-unwind" fn rust_item_that_can_unwind() {
20}
18pub extern "sysv64-unwind" fn rust_item_that_can_unwind() {}
2119
2220// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2321// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/thiscall-unwind-abi.rs+4-6
......@@ -2,8 +2,8 @@
22//@ compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -Cno-prepopulate-passes
33#![no_core]
44#![feature(no_core, lang_items, c_unwind)]
5#[lang="sized"]
6trait Sized { }
5#[lang = "sized"]
6trait Sized {}
77
88// Test that `nounwind` attributes are correctly applied to exported `thiscall` and
99// `thiscall-unwind` extern functions. `thiscall-unwind` functions MUST NOT have this attribute. We
......@@ -11,13 +11,11 @@ trait Sized { }
1111
1212// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1313#[no_mangle]
14pub extern "thiscall" fn rust_item_that_cannot_unwind() {
15}
14pub extern "thiscall" fn rust_item_that_cannot_unwind() {}
1615
1716// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1817#[no_mangle]
19pub extern "thiscall-unwind" fn rust_item_that_can_unwind() {
20}
18pub extern "thiscall-unwind" fn rust_item_that_can_unwind() {}
2119
2220// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2321// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/vectorcall-unwind-abi.rs+4-6
......@@ -2,8 +2,8 @@
22//@ compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -Cno-prepopulate-passes
33#![no_core]
44#![feature(no_core, lang_items, c_unwind, abi_vectorcall)]
5#[lang="sized"]
6trait Sized { }
5#[lang = "sized"]
6trait Sized {}
77
88// Test that `nounwind` attributes are correctly applied to exported `vectorcall` and
99// `vectorcall-unwind` extern functions. `vectorcall-unwind` functions MUST NOT have this attribute.
......@@ -11,13 +11,11 @@ trait Sized { }
1111
1212// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1313#[no_mangle]
14pub extern "vectorcall" fn rust_item_that_cannot_unwind() {
15}
14pub extern "vectorcall" fn rust_item_that_cannot_unwind() {}
1615
1716// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1817#[no_mangle]
19pub extern "vectorcall-unwind" fn rust_item_that_can_unwind() {
20}
18pub extern "vectorcall-unwind" fn rust_item_that_can_unwind() {}
2119
2220// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2321// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/unwind-abis/win64-unwind-abi.rs+4-6
......@@ -2,8 +2,8 @@
22//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib -Cno-prepopulate-passes
33#![no_core]
44#![feature(no_core, lang_items, c_unwind)]
5#[lang="sized"]
6trait Sized { }
5#[lang = "sized"]
6trait Sized {}
77
88// Test that `nounwind` attributes are correctly applied to exported `win64` and
99// `win64-unwind` extern functions. `win64-unwind` functions MUST NOT have this attribute. We
......@@ -11,13 +11,11 @@ trait Sized { }
1111
1212// CHECK: @rust_item_that_cannot_unwind() unnamed_addr #0 {
1313#[no_mangle]
14pub extern "win64" fn rust_item_that_cannot_unwind() {
15}
14pub extern "win64" fn rust_item_that_cannot_unwind() {}
1615
1716// CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
1817#[no_mangle]
19pub extern "win64-unwind" fn rust_item_that_can_unwind() {
20}
18pub extern "win64-unwind" fn rust_item_that_can_unwind() {}
2119
2220// Now, make some assertions that the LLVM attributes for these functions are correct. First, make
2321// sure that the first item is correctly marked with the `nounwind` attribute:
tests/codegen/vec-iter-collect-len.rs+1-1
......@@ -1,5 +1,5 @@
11//@ compile-flags: -O
2#![crate_type="lib"]
2#![crate_type = "lib"]
33
44#[no_mangle]
55pub fn get_len() -> usize {
tests/codegen/vtable-upcast.rs+3-3
......@@ -8,15 +8,15 @@ pub trait Base {
88 fn base(&self);
99}
1010
11pub trait A : Base {
11pub trait A: Base {
1212 fn a(&self);
1313}
1414
15pub trait B : Base {
15pub trait B: Base {
1616 fn b(&self);
1717}
1818
19pub trait Diamond : A + B {
19pub trait Diamond: A + B {
2020 fn diamond(&self);
2121}
2222
tests/codegen/wasm_exceptions.rs+17-9
......@@ -5,7 +5,7 @@
55#![feature(core_intrinsics)]
66#![feature(rustc_attrs)]
77
8extern {
8extern "C" {
99 fn may_panic();
1010
1111 #[rustc_nounwind]
......@@ -16,7 +16,9 @@ struct LogOnDrop;
1616
1717impl Drop for LogOnDrop {
1818 fn drop(&mut self) {
19 unsafe { log_number(0); }
19 unsafe {
20 log_number(0);
21 }
2022 }
2123}
2224
......@@ -24,7 +26,9 @@ impl Drop for LogOnDrop {
2426#[no_mangle]
2527pub fn test_cleanup() {
2628 let _log_on_drop = LogOnDrop;
27 unsafe { may_panic(); }
29 unsafe {
30 may_panic();
31 }
2832
2933 // CHECK-NOT: call
3034 // CHECK: invoke void @may_panic()
......@@ -35,12 +39,16 @@ pub fn test_cleanup() {
3539#[no_mangle]
3640pub fn test_rtry() {
3741 unsafe {
38 core::intrinsics::catch_unwind(|_| {
39 may_panic();
40 }, core::ptr::null_mut(), |data, exception| {
41 log_number(data as usize);
42 log_number(exception as usize);
43 });
42 core::intrinsics::catch_unwind(
43 |_| {
44 may_panic();
45 },
46 core::ptr::null_mut(),
47 |data, exception| {
48 log_number(data as usize);
49 log_number(exception as usize);
50 },
51 );
4452 }
4553
4654 // CHECK-NOT: call
tests/codegen/zip.rs+2-2
......@@ -5,7 +5,7 @@
55// CHECK-LABEL: @zip_copy
66#[no_mangle]
77pub fn zip_copy(xs: &[u8], ys: &mut [u8]) {
8// CHECK: memcpy
8 // CHECK: memcpy
99 for (x, y) in xs.iter().zip(ys) {
1010 *y = *x;
1111 }
......@@ -14,7 +14,7 @@ pub fn zip_copy(xs: &[u8], ys: &mut [u8]) {
1414// CHECK-LABEL: @zip_copy_mapped
1515#[no_mangle]
1616pub fn zip_copy_mapped(xs: &[u8], ys: &mut [u8]) {
17// CHECK: memcpy
17 // CHECK: memcpy
1818 for (x, y) in xs.iter().map(|&x| x).zip(ys) {
1919 *y = x;
2020 }
tests/codegen/zst-offset.rs+4-5
......@@ -6,14 +6,13 @@
66// Hack to get the correct size for the length part in slices
77// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
88#[no_mangle]
9pub fn helper(_: usize) {
10}
9pub fn helper(_: usize) {}
1110
1211// Check that we correctly generate a GEP for a ZST that is not included in Scalar layout
1312// CHECK-LABEL: @scalar_layout
1413#[no_mangle]
1514pub fn scalar_layout(s: &(u64, ())) {
16// CHECK: getelementptr inbounds i8, {{.+}}, [[USIZE]] 8
15 // CHECK: getelementptr inbounds i8, {{.+}}, [[USIZE]] 8
1716 let x = &s.1;
1817 witness(&x); // keep variable in an alloca
1918}
......@@ -22,7 +21,7 @@ pub fn scalar_layout(s: &(u64, ())) {
2221// CHECK-LABEL: @scalarpair_layout
2322#[no_mangle]
2423pub fn scalarpair_layout(s: &(u64, u32, ())) {
25// CHECK: getelementptr inbounds i8, {{.+}}, [[USIZE]] 12
24 // CHECK: getelementptr inbounds i8, {{.+}}, [[USIZE]] 12
2625 let x = &s.2;
2726 witness(&x); // keep variable in an alloca
2827}
......@@ -34,7 +33,7 @@ pub struct U64x4(u64, u64, u64, u64);
3433// CHECK-LABEL: @vector_layout
3534#[no_mangle]
3635pub fn vector_layout(s: &(U64x4, ())) {
37// CHECK: getelementptr inbounds i8, {{.+}}, [[USIZE]] 32
36 // CHECK: getelementptr inbounds i8, {{.+}}, [[USIZE]] 32
3837 let x = &s.1;
3938 witness(&x); // keep variable in an alloca
4039}
tests/run-make/a-b-a-linker-guard/a.rs+2-2
......@@ -2,7 +2,7 @@
22#![crate_type = "dylib"]
33
44#[cfg(x)]
5pub fn foo(x: u32) { }
5pub fn foo(x: u32) {}
66
77#[cfg(y)]
8pub fn foo(x: i32) { }
8pub fn foo(x: i32) {}
tests/run-make/allow-non-lint-warnings-cmdline/foo.rs+1-1
......@@ -2,4 +2,4 @@
22#[derive(Copy, Clone)]
33pub struct Foo;
44
5pub fn main() { }
5pub fn main() {}
tests/run-make/allow-warnings-cmdline-stability/foo.rs+3-1
......@@ -2,4 +2,6 @@
22
33extern crate bar;
44
5pub fn main() { bar::baz() }
5pub fn main() {
6 bar::baz()
7}
tests/run-make/atomic-lock-free/atomic_lock_free.rs+1-1
......@@ -1,5 +1,5 @@
11#![feature(no_core, intrinsics, lang_items)]
2#![crate_type="rlib"]
2#![crate_type = "rlib"]
33#![no_core]
44
55extern "rust-intrinsic" {
tests/run-make/bare-outfile/foo.rs+1-2
......@@ -1,2 +1 @@
1fn main() {
2}
1fn main() {}
tests/run-make/box-struct-no-segfault/foo.rs+4-4
......@@ -1,8 +1,8 @@
1#![crate_type="lib"]
1#![crate_type = "lib"]
22pub struct Foo(());
33
44impl Foo {
5 pub fn new() -> Foo {
6 Foo(())
7 }
5 pub fn new() -> Foo {
6 Foo(())
7 }
88}
tests/run-make/box-struct-no-segfault/main.rs+2-2
......@@ -1,7 +1,7 @@
1#![crate_type="lib"]
1#![crate_type = "lib"]
22extern crate foo;
33use foo::Foo;
44
55pub fn crash() -> Box<Foo> {
6 Box::new(Foo::new())
6 Box::new(Foo::new())
77}
tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs+8-10
......@@ -1,16 +1,16 @@
11#![crate_type = "staticlib"]
22#![feature(c_variadic)]
33
4use std::ffi::{c_char, c_double, c_int, c_long, c_longlong};
54use std::ffi::VaList;
6use std::ffi::{CString, CStr};
5use std::ffi::{c_char, c_double, c_int, c_long, c_longlong};
6use std::ffi::{CStr, CString};
77
88macro_rules! continue_if {
99 ($cond:expr) => {
1010 if !($cond) {
1111 return 0xff;
1212 }
13 }
13 };
1414}
1515
1616unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool {
......@@ -59,13 +59,11 @@ pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize {
5959 continue_if!(ap.arg::<c_int>() == 16);
6060 continue_if!(ap.arg::<c_char>() == 'A' as c_char);
6161 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!"));
62 ap.with_copy(|mut ap| {
63 if compare_c_str(ap.arg::<*const c_char>(), "Correct") {
64 0
65 } else {
66 0xff
67 }
68 })
62 ap.with_copy(
63 |mut ap| {
64 if compare_c_str(ap.arg::<*const c_char>(), "Correct") { 0 } else { 0xff }
65 },
66 )
6967}
7068
7169#[no_mangle]
tests/run-make/compiler-lookup-paths-2/c.rs+1-1
......@@ -1,3 +1,3 @@
11#![crate_type = "lib"]
2extern crate b;
32extern crate a;
3extern crate b;
tests/run-make/crate-data-smoke/rmake.rs+6-27
......@@ -3,41 +3,20 @@ use std::process::Output;
33use run_make_support::{bin_name, rust_lib_name, rustc};
44
55fn compare_stdout<S: AsRef<str>>(output: Output, expected: S) {
6 assert_eq!(
7 String::from_utf8(output.stdout).unwrap().trim(),
8 expected.as_ref()
9 );
6 assert_eq!(String::from_utf8(output.stdout).unwrap().trim(), expected.as_ref());
107}
118
129fn main() {
1310 compare_stdout(rustc().print("crate-name").input("crate.rs").run(), "foo");
11 compare_stdout(rustc().print("file-names").input("crate.rs").run(), bin_name("foo"));
1412 compare_stdout(
15 rustc().print("file-names").input("crate.rs").run(),
16 bin_name("foo"),
17 );
18 compare_stdout(
19 rustc()
20 .print("file-names")
21 .crate_type("lib")
22 .arg("--test")
23 .input("crate.rs")
24 .run(),
13 rustc().print("file-names").crate_type("lib").arg("--test").input("crate.rs").run(),
2514 bin_name("foo"),
2615 );
2716 compare_stdout(
28 rustc()
29 .print("file-names")
30 .arg("--test")
31 .input("lib.rs")
32 .run(),
17 rustc().print("file-names").arg("--test").input("lib.rs").run(),
3318 bin_name("mylib"),
3419 );
35 compare_stdout(
36 rustc().print("file-names").input("lib.rs").run(),
37 rust_lib_name("mylib"),
38 );
39 compare_stdout(
40 rustc().print("file-names").input("rlib.rs").run(),
41 rust_lib_name("mylib"),
42 );
20 compare_stdout(rustc().print("file-names").input("lib.rs").run(), rust_lib_name("mylib"));
21 compare_stdout(rustc().print("file-names").input("rlib.rs").run(), rust_lib_name("mylib"));
4322}
tests/run-make/cross-lang-lto-clang/rustlib.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="staticlib"]
1#![crate_type = "staticlib"]
22
33#[no_mangle]
44pub extern "C" fn rust_always_inlined() -> u32 {
tests/run-make/cross-lang-lto-pgo-smoketest/rustlib.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="staticlib"]
1#![crate_type = "staticlib"]
22
33#[no_mangle]
44pub extern "C" fn rust_always_inlined() -> u32 {
tests/run-make/cross-lang-lto-upstream-rlibs/staticlib.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="staticlib"]
1#![crate_type = "staticlib"]
22
33extern crate upstream;
44
tests/run-make/debug-assertions/debug.rs+17-3
......@@ -15,19 +15,33 @@ fn main() {
1515fn debug_assert_eq() {
1616 let mut hit1 = false;
1717 let mut hit2 = false;
18 debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 });
18 debug_assert_eq!(
19 {
20 hit1 = true;
21 1
22 },
23 {
24 hit2 = true;
25 2
26 }
27 );
1928 assert!(!hit1);
2029 assert!(!hit2);
2130}
2231
2332fn debug_assert() {
2433 let mut hit = false;
25 debug_assert!({ hit = true; false });
34 debug_assert!({
35 hit = true;
36 false
37 });
2638 assert!(!hit);
2739}
2840
2941fn overflow() {
30 fn add(a: u8, b: u8) -> u8 { a + b }
42 fn add(a: u8, b: u8) -> u8 {
43 a + b
44 }
3145
3246 add(200u8, 200u8);
3347}
tests/run-make/dep-info-spaces/lib.rs+1-1
......@@ -1,4 +1,4 @@
1#[path="foo foo.rs"]
1#[path = "foo foo.rs"]
22pub mod foo;
33
44pub mod bar;
tests/run-make/dep-info/lib.rs+1-1
......@@ -1,4 +1,4 @@
11#![crate_name = "foo"]
22
3pub mod foo;
43pub mod bar;
4pub mod foo;
tests/run-make/deref-impl-rustdoc-ice/baz.rs+4-2
......@@ -1,8 +1,10 @@
1extern crate foo;
21extern crate bar;
2extern crate foo;
33
44pub struct Bar;
55impl ::std::ops::Deref for Bar {
66 type Target = bar::S;
7 fn deref(&self) -> &Self::Target { unimplemented!() }
7 fn deref(&self) -> &Self::Target {
8 unimplemented!()
9 }
810}
tests/run-make/deref-impl-rustdoc-ice/foo.rs+3-1
......@@ -3,7 +3,9 @@
33extern crate proc_macro;
44
55#[proc_macro_derive(A)]
6pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { ts }
6pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream {
7 ts
8}
79
810#[derive(Debug)]
911struct S;
tests/run-make/dylib-chain/m2.rs+3-1
......@@ -1,4 +1,6 @@
11#![crate_type = "dylib"]
22extern crate m1;
33
4pub fn m2() { m1::m1() }
4pub fn m2() {
5 m1::m1()
6}
tests/run-make/dylib-chain/m3.rs+3-1
......@@ -1,4 +1,6 @@
11#![crate_type = "dylib"]
22extern crate m2;
33
4pub fn m3() { m2::m2() }
4pub fn m3() {
5 m2::m2()
6}
tests/run-make/dylib-chain/m4.rs+3-1
......@@ -1,3 +1,5 @@
11extern crate m3;
22
3fn main() { m3::m3() }
3fn main() {
4 m3::m3()
5}
tests/run-make/emit/test-26235.rs+17-8
......@@ -6,16 +6,22 @@ fn main() {
66 type Key = u32;
77 const NUM_THREADS: usize = 2;
88
9 #[derive(Clone,Copy)]
9 #[derive(Clone, Copy)]
1010 struct Stats<S> {
1111 upsert: S,
1212 delete: S,
1313 insert: S,
14 update: S
14 update: S,
1515 };
1616
17 impl<S> Stats<S> where S: Copy {
18 fn dot<B, F, T>(self, s: Stats<T>, f: F) -> Stats<B> where F: Fn(S, T) -> B {
17 impl<S> Stats<S>
18 where
19 S: Copy,
20 {
21 fn dot<B, F, T>(self, s: Stats<T>, f: F) -> Stats<B>
22 where
23 F: Fn(S, T) -> B,
24 {
1925 let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self;
2026 let Stats { upsert: u2, delete: d2, insert: i2, update: p2 } = s;
2127 Stats { upsert: f(u1, u2), delete: f(d1, d2), insert: f(i1, i2), update: f(p1, p2) }
......@@ -38,9 +44,12 @@ fn main() {
3844 make_threads();
3945
4046 {
41 let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold(
42 Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y)));
43 println!("upserts: {}, deletes: {}, inserts: {}, updates: {}",
44 upsert, delete, insert, update);
47 let Stats { ref upsert, ref delete, ref insert, ref update } = stats
48 .iter()
49 .fold(Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y)));
50 println!(
51 "upserts: {}, deletes: {}, inserts: {}, updates: {}",
52 upsert, delete, insert, update
53 );
4554 }
4655}
tests/run-make/extern-diff-internal-name/test.rs+1-2
......@@ -1,5 +1,4 @@
11#[macro_use]
22extern crate foo;
33
4fn main() {
5}
4fn main() {}
tests/run-make/extern-flag-disambiguates/a.rs+3-1
......@@ -3,4 +3,6 @@
33
44static FOO: usize = 3;
55
6pub fn token() -> &'static usize { &FOO }
6pub fn token() -> &'static usize {
7 &FOO
8}
tests/run-make/extern-flag-disambiguates/b.rs+6-2
......@@ -5,5 +5,9 @@ extern crate a;
55
66static FOO: usize = 3;
77
8pub fn token() -> &'static usize { &FOO }
9pub fn a_token() -> &'static usize { a::token() }
8pub fn token() -> &'static usize {
9 &FOO
10}
11pub fn a_token() -> &'static usize {
12 a::token()
13}
tests/run-make/extern-flag-disambiguates/c.rs+6-2
......@@ -5,5 +5,9 @@ extern crate a;
55
66static FOO: usize = 3;
77
8pub fn token() -> &'static usize { &FOO }
9pub fn a_token() -> &'static usize { a::token() }
8pub fn token() -> &'static usize {
9 &FOO
10}
11pub fn a_token() -> &'static usize {
12 a::token()
13}
tests/run-make/extern-flag-disambiguates/d.rs+7-3
......@@ -1,9 +1,13 @@
1#[cfg(before)] extern crate a;
1#[cfg(before)]
2extern crate a;
3#[cfg(after)]
4extern crate a;
25extern crate b;
36extern crate c;
4#[cfg(after)] extern crate a;
57
6fn t(a: &'static usize) -> usize { a as *const _ as usize }
8fn t(a: &'static usize) -> usize {
9 a as *const _ as usize
10}
711
812fn main() {
913 assert_eq!(t(a::token()), t(b::a_token()));
tests/run-make/extern-fn-explicit-align/test.rs+2-2
......@@ -1,6 +1,6 @@
11// Issue #80127: Passing structs via FFI should work with explicit alignment.
22
3use std::ffi::{CStr, c_char};
3use std::ffi::{c_char, CStr};
44use std::ptr::null_mut;
55
66#[repr(C)]
......@@ -18,7 +18,7 @@ pub struct TwoU64s {
1818
1919#[repr(C)]
2020pub struct WrappedU64s {
21 pub a: TwoU64s
21 pub a: TwoU64s,
2222}
2323
2424#[repr(C)]
tests/run-make/extern-fn-reachable/dylib.rs+10-5
......@@ -1,14 +1,19 @@
11#![crate_type = "dylib"]
22#![allow(dead_code)]
33
4#[no_mangle] pub extern "C" fn fun1() {}
5#[no_mangle] extern "C" fn fun2() {}
4#[no_mangle]
5pub extern "C" fn fun1() {}
6#[no_mangle]
7extern "C" fn fun2() {}
68
79mod foo {
8 #[no_mangle] pub extern "C" fn fun3() {}
10 #[no_mangle]
11 pub extern "C" fn fun3() {}
912}
1013pub mod bar {
11 #[no_mangle] pub extern "C" fn fun4() {}
14 #[no_mangle]
15 pub extern "C" fn fun4() {}
1216}
1317
14#[no_mangle] pub fn fun5() {}
18#[no_mangle]
19pub fn fun5() {}
tests/run-make/extern-fn-struct-passing-abi/test.rs+6-2
......@@ -90,8 +90,12 @@ extern "C" {
9090 fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect);
9191
9292 fn byval_rect_with_many_huge64(
93 a: Huge64, b: Huge64, c: Huge64,
94 d: Huge64, e: Huge64, f: Huge64,
93 a: Huge64,
94 b: Huge64,
95 c: Huge64,
96 d: Huge64,
97 e: Huge64,
98 f: Huge64,
9599 g: Rect,
96100 );
97101
tests/run-make/extern-multiple-copies/bar.rs+1-1
......@@ -1,5 +1,5 @@
1extern crate foo2; // foo2 first to exhibit the bug
21extern crate foo1;
2extern crate foo2; // foo2 first to exhibit the bug
33
44fn main() {
55 /* ... */
tests/run-make/external-crate-panic-handle-no-lint/app.rs-1
......@@ -1,7 +1,6 @@
11#![crate_type = "bin"]
22#![no_main]
33#![no_std]
4
54#![deny(unused_extern_crates)]
65
76// `panic` provides a `panic_handler` so it shouldn't trip the `unused_extern_crates` lint
tests/run-make/incr-prev-body-beyond-eof/a.rs-4
......@@ -9,8 +9,4 @@ fn main() {
99// Basically, avoid modifying this file, including adding or removing whitespace!
1010fn foo() {
1111 assert_eq!(1, 1);
12
13
14
15
1612}
tests/run-make/incr-prev-body-beyond-eof/b.rs+1-1
......@@ -8,5 +8,5 @@ fn main() {
88// a.rs, the body must end on a line number which does not exist in b.rs.
99// Basically, avoid modifying this file, including adding or removing whitespace!
1010fn foo() {
11 assert_eq!(1, 1);////
11 assert_eq!(1, 1); ////
1212}
tests/run-make/inline-always-many-cgu/foo.rs+2-4
......@@ -2,11 +2,9 @@
22
33pub mod a {
44 #[inline(always)]
5 pub fn foo() {
6 }
5 pub fn foo() {}
76
8 pub fn bar() {
9 }
7 pub fn bar() {}
108}
119
1210#[no_mangle]
tests/run-make/interdependent-c-libraries/main.rs+1-1
......@@ -1,5 +1,5 @@
1extern crate foo;
21extern crate bar;
2extern crate foo;
33
44fn main() {
55 bar::doit();
tests/run-make/intrinsic-unreachable/exit-ret.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="lib"]
1#![crate_type = "lib"]
22use std::arch::asm;
33
44#[deny(unreachable_code)]
tests/run-make/intrinsic-unreachable/exit-unreachable.rs+1-1
......@@ -1,5 +1,5 @@
11#![feature(core_intrinsics)]
2#![crate_type="lib"]
2#![crate_type = "lib"]
33use std::arch::asm;
44
55use std::intrinsics;
tests/run-make/issue-18943/foo.rs+3-3
......@@ -1,5 +1,5 @@
1trait Foo { }
1trait Foo {}
22
3trait Bar { }
3trait Bar {}
44
5impl<'a> Foo for Bar + 'a { }
5impl<'a> Foo for Bar + 'a {}
tests/run-make/issue-20626/foo.rs+3-1
......@@ -1,4 +1,6 @@
1fn identity(a: &u32) -> &u32 { a }
1fn identity(a: &u32) -> &u32 {
2 a
3}
24
35fn print_foo(f: &fn(&u32) -> &u32, x: &u32) {
46 print!("{}", (*f)(x));
tests/run-make/issue-22131/foo.rs+3-1
......@@ -2,4 +2,6 @@
22/// assert_eq!(foo::foo(), 1);
33/// ```
44#[cfg(feature = "bar")]
5pub fn foo() -> i32 { 1 }
5pub fn foo() -> i32 {
6 1
7}
tests/run-make/issue-26006/in/libc/lib.rs+2-2
......@@ -1,3 +1,3 @@
1#![crate_type="rlib"]
1#![crate_type = "rlib"]
22
3pub fn something(){}
3pub fn something() {}
tests/run-make/issue-26006/in/time/lib.rs+1-1
......@@ -1,4 +1,4 @@
11#![feature(rustc_private)]
22extern crate libc;
33
4fn main(){}
4fn main() {}
tests/run-make/issue-37839/b.rs+2-1
......@@ -1,2 +1,3 @@
11#![crate_type = "lib"]
2#[macro_use] extern crate a;
2#[macro_use]
3extern crate a;
tests/run-make/issue-47551/eh_frame-terminator.rs+1-3
......@@ -7,9 +7,7 @@ struct Foo {
77
88impl Foo {
99 const fn new() -> Self {
10 Self {
11 array: [0x1122_3344_5566_7788; 10240]
12 }
10 Self { array: [0x1122_3344_5566_7788; 10240] }
1311 }
1412}
1513
tests/run-make/issue-69368/c.rs+1-1
......@@ -2,8 +2,8 @@
22#![feature(start)]
33#![no_std]
44
5extern crate alloc;
65extern crate a;
6extern crate alloc;
77extern crate b;
88
99use alloc::vec::Vec;
tests/run-make/link-arg/empty.rs+1-1
......@@ -1 +1 @@
1fn main() { }
1fn main() {}
tests/run-make/long-linker-command-lines-cmd-exe/foo.rs+13-11
......@@ -13,13 +13,13 @@
1313
1414use std::env;
1515use std::fs::{self, File};
16use std::io::{BufWriter, Write, Read};
16use std::io::{BufWriter, Read, Write};
1717use std::path::PathBuf;
1818use std::process::Command;
1919
2020fn main() {
2121 if !cfg!(windows) {
22 return
22 return;
2323 }
2424
2525 let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
......@@ -31,16 +31,16 @@ fn main() {
3131 let file = file.to_str().unwrap();
3232 fs::copy(&file[1..], &ok).unwrap();
3333 }
34 None => { File::create(&not_ok).unwrap(); }
34 None => {
35 File::create(&not_ok).unwrap();
36 }
3537 }
36 return
38 return;
3739 }
3840
3941 let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
4042 let me = env::current_exe().unwrap();
41 let bat = me.parent()
42 .unwrap()
43 .join("foo.bat");
43 let bat = me.parent().unwrap().join("foo.bat");
4444 let bat_linker = format!("linker={}", bat.display());
4545 for i in (1..).map(|i| i * 10) {
4646 println!("attempt: {}", i);
......@@ -61,8 +61,10 @@ fn main() {
6161 drop(fs::remove_file(&not_ok));
6262 let status = Command::new(&rustc)
6363 .arg(&file)
64 .arg("-C").arg(&bat_linker)
65 .arg("--out-dir").arg(&tmpdir)
64 .arg("-C")
65 .arg(&bat_linker)
66 .arg("--out-dir")
67 .arg(&tmpdir)
6668 .env("YOU_ARE_A_LINKER", "1")
6769 .env("MY_LINKER", &me)
6870 .status()
......@@ -74,7 +76,7 @@ fn main() {
7476
7577 if !ok.exists() {
7678 assert!(not_ok.exists());
77 continue
79 continue;
7880 }
7981
8082 let mut contents = Vec::new();
......@@ -96,6 +98,6 @@ fn main() {
9698 assert!(contents.windows(exp.len()).any(|w| w == &exp[..]));
9799 }
98100
99 break
101 break;
100102 }
101103}
tests/run-make/long-linker-command-lines/foo.rs+23-18
......@@ -34,9 +34,7 @@ fn write_test_case(file: &Path, n: usize) -> HashSet<String> {
3434fn read_linker_args(path: &Path) -> String {
3535 let contents = fs::read(path).unwrap();
3636 if cfg!(target_env = "msvc") {
37 let mut i = contents.chunks(2).map(|c| {
38 c[0] as u16 | ((c[1] as u16) << 8)
39 });
37 let mut i = contents.chunks(2).map(|c| c[0] as u16 | ((c[1] as u16) << 8));
4038 assert_eq!(i.next(), Some(0xfeff), "Expected UTF-16 BOM");
4139 String::from_utf16(&i.collect::<Vec<u16>>()).unwrap()
4240 } else {
......@@ -52,7 +50,7 @@ fn main() {
5250 let file = file.to_str().expect("non-utf8 file argument");
5351 fs::copy(&file[1..], &ok).unwrap();
5452 }
55 return
53 return;
5654 }
5755
5856 let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
......@@ -65,28 +63,35 @@ fn main() {
6563 drop(fs::remove_file(&ok));
6664 let output = Command::new(&rustc)
6765 .arg(&file)
68 .arg("-C").arg(&me_as_linker)
69 .arg("--out-dir").arg(&tmpdir)
66 .arg("-C")
67 .arg(&me_as_linker)
68 .arg("--out-dir")
69 .arg(&tmpdir)
7070 .env("YOU_ARE_A_LINKER", "1")
7171 .output()
7272 .unwrap();
7373
7474 if !output.status.success() {
7575 let stderr = String::from_utf8_lossy(&output.stderr);
76 panic!("status: {}\nstdout:\n{}\nstderr:\n{}",
77 output.status,
78 String::from_utf8_lossy(&output.stdout),
79 stderr.lines().map(|l| {
80 if l.len() > 200 {
81 format!("{}...\n", &l[..200])
82 } else {
83 format!("{}\n", l)
84 }
85 }).collect::<String>());
76 panic!(
77 "status: {}\nstdout:\n{}\nstderr:\n{}",
78 output.status,
79 String::from_utf8_lossy(&output.stdout),
80 stderr
81 .lines()
82 .map(|l| {
83 if l.len() > 200 {
84 format!("{}...\n", &l[..200])
85 } else {
86 format!("{}\n", l)
87 }
88 })
89 .collect::<String>()
90 );
8691 }
8792
8893 if !ok.exists() {
89 continue
94 continue;
9095 }
9196
9297 let linker_args = read_linker_args(&ok);
......@@ -101,6 +106,6 @@ fn main() {
101106 linker_args,
102107 );
103108
104 break
109 break;
105110 }
106111}
tests/run-make/many-crates-but-no-match/crateA1.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_name="crateA"]
1#![crate_name = "crateA"]
22
33// Base crate
44pub fn func<T>() {}
tests/run-make/many-crates-but-no-match/crateA2.rs+4-2
......@@ -1,4 +1,6 @@
1#![crate_name="crateA"]
1#![crate_name = "crateA"]
22
33// Base crate
4pub fn func<T>() { println!("hello"); }
4pub fn func<T>() {
5 println!("hello");
6}
tests/run-make/many-crates-but-no-match/crateA3.rs+4-2
......@@ -1,4 +1,6 @@
1#![crate_name="crateA"]
1#![crate_name = "crateA"]
22
33// Base crate
4pub fn foo<T>() { println!("world!"); }
4pub fn foo<T>() {
5 println!("world!");
6}
tests/run-make/metadata-flag-frobs-symbols/foo.rs+3-1
......@@ -3,4 +3,6 @@
33
44static FOO: usize = 3;
55
6pub fn foo() -> &'static usize { &FOO }
6pub fn foo() -> &'static usize {
7 &FOO
8}
tests/run-make/mixing-deps/dylib.rs+3-1
......@@ -3,4 +3,6 @@ extern crate both;
33
44use std::mem;
55
6pub fn addr() -> usize { unsafe { mem::transmute(&both::foo) } }
6pub fn addr() -> usize {
7 unsafe { mem::transmute(&both::foo) }
8}
tests/run-make/mixing-deps/prog.rs+2-3
......@@ -1,9 +1,8 @@
1extern crate dylib;
21extern crate both;
2extern crate dylib;
33
44use std::mem;
55
66fn main() {
7 assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) },
8 dylib::addr());
7 assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) }, dylib::addr());
98}
tests/run-make/mixing-libs/dylib.rs+3-1
......@@ -1,4 +1,6 @@
11#![crate_type = "dylib"]
22extern crate rlib;
33
4pub fn dylib() { rlib::rlib() }
4pub fn dylib() {
5 rlib::rlib()
6}
tests/run-make/native-link-modifier-whole-archive/native_lib_in_src.rs+6-4
......@@ -1,9 +1,11 @@
11use std::io::Write;
22
3#[link(name = "c_static_lib_with_constructor",
4 kind = "static",
5 modifiers = "-bundle,+whole-archive")]
6extern {}
3#[link(
4 name = "c_static_lib_with_constructor",
5 kind = "static",
6 modifiers = "-bundle,+whole-archive"
7)]
8extern "C" {}
79
810pub fn hello() {
911 print!("native_lib_in_src.");
tests/run-make/non-pie-thread-local/foo.rs+3-1
......@@ -2,7 +2,9 @@
22
33struct Destroy;
44impl Drop for Destroy {
5 fn drop(&mut self) { println!("drop"); }
5 fn drop(&mut self) {
6 println!("drop");
7 }
68}
79
810thread_local! {
tests/run-make/pass-non-c-like-enum-to-c/nonclike.rs+2-2
......@@ -4,7 +4,7 @@ pub enum TT {
44 BB,
55}
66
7#[repr(C,u8)]
7#[repr(C, u8)]
88pub enum T {
99 A(u64),
1010 B,
......@@ -16,6 +16,6 @@ extern "C" {
1616}
1717
1818fn main() {
19 assert_eq!(33, unsafe { tt_add(TT::AA(1,2), TT::AA(10,20)) });
19 assert_eq!(33, unsafe { tt_add(TT::AA(1, 2), TT::AA(10, 20)) });
2020 assert_eq!(11, unsafe { t_add(T::A(1), T::A(10)) });
2121}
tests/run-make/pdb-buildinfo-cl-cmd/main.rs+1-2
......@@ -1,2 +1 @@
1fn main() {
2}
1fn main() {}
tests/run-make/pgo-branch-weights/interesting.rs+2-3
......@@ -1,5 +1,5 @@
1#![crate_name="interesting"]
2#![crate_type="rlib"]
1#![crate_name = "interesting"]
2#![crate_type = "rlib"]
33
44extern crate opaque;
55
......@@ -22,7 +22,6 @@ pub fn function_called_42_times(c: char) {
2222 // This branch is taken 12 times
2323 opaque::f1();
2424 } else {
25
2625 if c == 'b' {
2726 // This branch is taken 28 times
2827 opaque::f2();
tests/run-make/pgo-branch-weights/opaque.rs+2-2
......@@ -1,5 +1,5 @@
1#![crate_name="opaque"]
2#![crate_type="rlib"]
1#![crate_name = "opaque"]
2#![crate_type = "rlib"]
33
44pub fn f1() {}
55pub fn f2() {}
tests/run-make/pgo-indirect-call-promotion/interesting.rs+2-6
......@@ -1,5 +1,5 @@
1#![crate_name="interesting"]
2#![crate_type="rlib"]
1#![crate_name = "interesting"]
2#![crate_type = "rlib"]
33
44extern crate opaque;
55
......@@ -15,7 +15,6 @@ pub fn function_called_never() {
1515
1616#[no_mangle]
1717pub fn call_a_bunch_of_functions(fns: &[fn()]) {
18
1918 // Indirect call promotion transforms the below into something like
2019 //
2120 // for f in fns {
......@@ -33,13 +32,11 @@ pub fn call_a_bunch_of_functions(fns: &[fn()]) {
3332 }
3433}
3534
36
3735pub trait Foo {
3836 fn foo(&self);
3937}
4038
4139impl Foo for u32 {
42
4340 #[no_mangle]
4441 fn foo(&self) {
4542 opaque::opaque_f2();
......@@ -48,7 +45,6 @@ impl Foo for u32 {
4845
4946#[no_mangle]
5047pub fn call_a_bunch_of_trait_methods(trait_objects: &[&dyn Foo]) {
51
5248 // Same as above, just with vtables in between
5349 for x in trait_objects {
5450 x.foo();
tests/run-make/pgo-indirect-call-promotion/main.rs+2-3
......@@ -2,9 +2,8 @@ extern crate interesting;
22
33fn main() {
44 // function pointer case
5 let fns: Vec<_> = std::iter::repeat(interesting::function_called_always as fn())
6 .take(1000)
7 .collect();
5 let fns: Vec<_> =
6 std::iter::repeat(interesting::function_called_always as fn()).take(1000).collect();
87 interesting::call_a_bunch_of_functions(&fns[..]);
98
109 // Trait object case
tests/run-make/pgo-indirect-call-promotion/opaque.rs+2-2
......@@ -1,5 +1,5 @@
1#![crate_name="opaque"]
2#![crate_type="rlib"]
1#![crate_name = "opaque"]
2#![crate_type = "rlib"]
33
44#[no_mangle]
55pub fn opaque_f1() {}
tests/run-make/pgo-use/main.rs+1-1
......@@ -11,7 +11,7 @@ pub fn hot_function(c: u8) {
1111fn main() {
1212 let arg = std::env::args().skip(1).next().unwrap();
1313
14 for i in 0 .. 1000_000 {
14 for i in 0..1000_000 {
1515 let some_value = arg.as_bytes()[i % arg.len()];
1616 if some_value == b'!' {
1717 // This branch is never taken at runtime
tests/run-make/pointer-auth-link-with-c/test.rs+3-1
......@@ -4,5 +4,7 @@ extern "C" {
44}
55
66fn main() {
7 unsafe {foo();}
7 unsafe {
8 foo();
9 }
810}
tests/run-make/pretty-print-to-file/input.rs+4-4
......@@ -1,5 +1,5 @@
1#[crate_type="lib"]
1#[crate_type = "lib"]
22
3pub fn
4foo() -> i32
5{ 45 }
3pub fn foo() -> i32 {
4 45
5}
tests/run-make/print-check-cfg/rmake.rs+6-4
......@@ -40,19 +40,21 @@ fn main() {
4040 /*contains*/ &["feature", "feature=\"\"", "feature=\"test\"", "feature=\"lol\""],
4141 );
4242 check(
43 /*args*/ &[
43 /*args*/
44 &[
4445 r#"--check-cfg=cfg(feature, values(any()))"#,
45 r#"--check-cfg=cfg(feature, values("tmp"))"#
46 r#"--check-cfg=cfg(feature, values("tmp"))"#,
4647 ],
4748 /*has_any*/ false,
4849 /*has_any_any*/ false,
4950 /*contains*/ &["unix", "miri", "feature=any()"],
5051 );
5152 check(
52 /*args*/ &[
53 /*args*/
54 &[
5355 r#"--check-cfg=cfg(has_foo, has_bar)"#,
5456 r#"--check-cfg=cfg(feature, values("tmp"))"#,
55 r#"--check-cfg=cfg(feature, values("tmp"))"#
57 r#"--check-cfg=cfg(feature, values("tmp"))"#,
5658 ],
5759 /*has_any*/ false,
5860 /*has_any_any*/ false,
tests/run-make/proc-macro-init-order/b.rs+2-1
......@@ -1,2 +1,3 @@
11#![crate_type = "lib"]
2#[macro_use] extern crate a;
2#[macro_use]
3extern crate a;
tests/run-make/proc-macro-init-order/c.rs+1-1
......@@ -1,3 +1,3 @@
11#![crate_type = "staticlib"]
2extern crate b;
32extern crate a;
3extern crate b;
tests/run-make/prune-link-args/empty.rs+1-1
......@@ -1 +1 @@
1fn main() { }
1fn main() {}
tests/run-make/raw-dylib-alt-calling-convention/driver.rs+2-3
......@@ -2,7 +2,6 @@ extern crate raw_dylib_alt_calling_convention_test;
22
33fn main() {
44 raw_dylib_alt_calling_convention_test::library_function(
5 std::env::args().skip(1).next().map_or(
6 false,
7 |s| std::str::FromStr::from_str(&s).unwrap()));
5 std::env::args().skip(1).next().map_or(false, |s| std::str::FromStr::from_str(&s).unwrap()),
6 );
87}
tests/run-make/raw-dylib-c/lib.rs+3-3
......@@ -1,16 +1,16 @@
11#[link(name = "extern_1.dll", kind = "raw-dylib", modifiers = "+verbatim")]
2extern {
2extern "C" {
33 fn extern_fn_1();
44}
55
66#[link(name = "extern_2", kind = "raw-dylib")]
7extern {
7extern "C" {
88 fn extern_fn_3();
99}
1010
1111pub fn library_function() {
1212 #[link(name = "extern_1", kind = "raw-dylib")]
13 extern {
13 extern "C" {
1414 fn extern_fn_2();
1515 fn print_extern_variable();
1616 static mut extern_variable: i32;
tests/run-make/raw-dylib-cross-compilation/lib.rs+1-1
......@@ -8,7 +8,7 @@
88trait Sized {}
99
1010#[link(name = "extern_1", kind = "raw-dylib")]
11extern {
11extern "C" {
1212 fn extern_fn();
1313}
1414
tests/run-make/raw-dylib-custom-dlltool/lib.rs+1-1
......@@ -1,5 +1,5 @@
11#[link(name = "extern_1", kind = "raw-dylib")]
2extern {
2extern "C" {
33 fn extern_fn_1();
44}
55
tests/run-make/raw-dylib-import-name-type/driver.rs+1-1
......@@ -76,7 +76,7 @@ extern "vectorcall" {
7676}
7777
7878#[link(name = "extern", kind = "raw-dylib")]
79extern {
79extern "C" {
8080 fn print_extern_variable_undecorated();
8181 fn print_extern_variable_noprefix();
8282 fn print_extern_variable_decorated();
tests/run-make/raw-dylib-inline-cross-dylib/driver.rs+1-1
......@@ -2,7 +2,7 @@ extern crate raw_dylib_test;
22extern crate raw_dylib_test_wrapper;
33
44#[link(name = "extern_2", kind = "raw-dylib")]
5extern {
5extern "C" {
66 fn extern_fn_2();
77}
88
tests/run-make/raw-dylib-inline-cross-dylib/lib.rs+1-1
......@@ -1,5 +1,5 @@
11#[link(name = "extern_1", kind = "raw-dylib")]
2extern {
2extern "C" {
33 fn extern_fn_1();
44 fn extern_fn_2();
55}
tests/run-make/raw-dylib-link-ordinal/lib.rs+1-1
......@@ -1,5 +1,5 @@
11#[link(name = "exporter", kind = "raw-dylib")]
2extern {
2extern "C" {
33 #[link_ordinal(13)]
44 fn imported_function();
55 #[link_ordinal(5)]
tests/run-make/reproducible-build-2/linker.rs+2-2
......@@ -1,7 +1,7 @@
11use std::env;
2use std::path::Path;
32use std::fs::File;
43use std::io::{Read, Write};
4use std::path::Path;
55
66fn main() {
77 let mut dst = env::current_exe().unwrap();
......@@ -19,7 +19,7 @@ fn main() {
1919 if !path.is_file() {
2020 out.push_str(&arg);
2121 out.push_str("\n");
22 continue
22 continue;
2323 }
2424
2525 let mut contents = Vec::new();
tests/run-make/reproducible-build-2/reproducible-build-aux.rs+2-2
......@@ -1,4 +1,4 @@
1#![crate_type="lib"]
1#![crate_type = "lib"]
22
33pub static STATIC: i32 = 1234;
44
......@@ -18,7 +18,7 @@ impl<T1, T2> Drop for Struct<T1, T2> {
1818pub enum Enum {
1919 Variant1,
2020 Variant2(u32),
21 Variant3 { x: u32 }
21 Variant3 { x: u32 },
2222}
2323
2424pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64);
tests/run-make/reproducible-build-2/reproducible-build.rs+8-11
......@@ -18,6 +18,8 @@
1818// - Trait object shims
1919// - Fn Pointer shims
2020
21// ignore-tidy-linelength
22
2123#![allow(dead_code, warnings)]
2224
2325extern crate reproducible_build_aux;
......@@ -40,7 +42,7 @@ impl<T1, T2> Drop for Struct<T1, T2> {
4042pub enum Enum {
4143 Variant1,
4244 Variant2(u32),
43 Variant3 { x: u32 }
45 Variant3 { x: u32 },
4446}
4547
4648struct TupleStruct(i8, i16, i32, i64);
......@@ -67,19 +69,14 @@ fn main() {
6769 generic_fn::<char, Struct<u32, u64>>();
6870 generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
6971
70 let dropped = Struct {
71 x: "",
72 y: 'a',
73 };
72 let dropped = Struct { x: "", y: 'a' };
7473
7574 let _ = Enum::Variant1;
7675 let _ = Enum::Variant2(0);
7776 let _ = Enum::Variant3 { x: 0 };
7877 let _ = TupleStruct(1, 2, 3, 4);
7978
80 let closure = |x| {
81 x + 1i32
82 };
79 let closure = |x| x + 1i32;
8380
8481 fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
8582 f(STATIC)
......@@ -94,13 +91,13 @@ fn main() {
9491 f(0);
9592 }
9693
97 with_fn_once_adapter(|_:i32| { });
94 with_fn_once_adapter(|_: i32| {});
9895
9996 reproducible_build_aux::regular_fn(STATIC);
10097 reproducible_build_aux::generic_fn::<u32, char>();
10198 reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
102 reproducible_build_aux::generic_fn::<Struct<u64, u32>,
103 reproducible_build_aux::Struct<u32, u64>>();
99 reproducible_build_aux::generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>(
100 );
104101
105102 let _ = reproducible_build_aux::Enum::Variant1;
106103 let _ = reproducible_build_aux::Enum::Variant2(0);
tests/run-make/reproducible-build/linker.rs+2-2
......@@ -1,7 +1,7 @@
11use std::env;
2use std::path::Path;
32use std::fs::File;
43use std::io::{Read, Write};
4use std::path::Path;
55
66fn main() {
77 let mut dst = env::current_exe().unwrap();
......@@ -19,7 +19,7 @@ fn main() {
1919 if !path.is_file() {
2020 out.push_str(&arg);
2121 out.push_str("\n");
22 continue
22 continue;
2323 }
2424
2525 let mut contents = Vec::new();
tests/run-make/reproducible-build/reproducible-build-aux.rs+2-2
......@@ -1,4 +1,4 @@
1#![crate_type="lib"]
1#![crate_type = "lib"]
22
33pub static STATIC: i32 = 1234;
44
......@@ -18,7 +18,7 @@ impl<T1, T2> Drop for Struct<T1, T2> {
1818pub enum Enum {
1919 Variant1,
2020 Variant2(u32),
21 Variant3 { x: u32 }
21 Variant3 { x: u32 },
2222}
2323
2424pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64);
tests/run-make/reproducible-build/reproducible-build.rs+8-11
......@@ -18,6 +18,8 @@
1818// - Trait object shims
1919// - Fn Pointer shims
2020
21// ignore-tidy-linelength
22
2123#![allow(dead_code, warnings)]
2224
2325extern crate reproducible_build_aux;
......@@ -40,7 +42,7 @@ impl<T1, T2> Drop for Struct<T1, T2> {
4042pub enum Enum {
4143 Variant1,
4244 Variant2(u32),
43 Variant3 { x: u32 }
45 Variant3 { x: u32 },
4446}
4547
4648struct TupleStruct(i8, i16, i32, i64);
......@@ -67,19 +69,14 @@ fn main() {
6769 generic_fn::<char, Struct<u32, u64>>();
6870 generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
6971
70 let dropped = Struct {
71 x: "",
72 y: 'a',
73 };
72 let dropped = Struct { x: "", y: 'a' };
7473
7574 let _ = Enum::Variant1;
7675 let _ = Enum::Variant2(0);
7776 let _ = Enum::Variant3 { x: 0 };
7877 let _ = TupleStruct(1, 2, 3, 4);
7978
80 let closure = |x| {
81 x + 1i32
82 };
79 let closure = |x| x + 1i32;
8380
8481 fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
8582 f(STATIC)
......@@ -94,13 +91,13 @@ fn main() {
9491 f(0);
9592 }
9693
97 with_fn_once_adapter(|_:i32| { });
94 with_fn_once_adapter(|_: i32| {});
9895
9996 reproducible_build_aux::regular_fn(STATIC);
10097 reproducible_build_aux::generic_fn::<u32, char>();
10198 reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
102 reproducible_build_aux::generic_fn::<Struct<u64, u32>,
103 reproducible_build_aux::Struct<u32, u64>>();
99 reproducible_build_aux::generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>(
100 );
104101
105102 let _ = reproducible_build_aux::Enum::Variant1;
106103 let _ = reproducible_build_aux::Enum::Variant2(0);
tests/run-make/reset-codegen-1/foo.rs+1-1
......@@ -1 +1 @@
1fn main() { }
1fn main() {}
tests/run-make/resolve-rename/bar.rs+3-1
......@@ -2,4 +2,6 @@
22
33extern crate foo;
44
5pub fn bar() { foo::foo() }
5pub fn bar() {
6 foo::foo()
7}
tests/run-make/resolve-rename/baz.rs+3-1
......@@ -2,4 +2,6 @@
22
33extern crate bar;
44
5pub fn baz() { bar::bar() }
5pub fn baz() {
6 bar::bar()
7}
tests/run-make/return-non-c-like-enum-from-c/nonclike.rs+1-1
......@@ -4,7 +4,7 @@ pub enum TT {
44 BB,
55}
66
7#[repr(C,u8)]
7#[repr(C, u8)]
88pub enum T {
99 A(u64),
1010 B,
tests/run-make/return-non-c-like-enum/nonclike.rs+1-1
......@@ -9,7 +9,7 @@ pub extern "C" fn tt_new(a: u64, b: u64) -> TT {
99 TT::AA(a, b)
1010}
1111
12#[repr(C,u8)]
12#[repr(C, u8)]
1313pub enum T {
1414 A(u64),
1515 B,
tests/run-make/rlib-chain/m2.rs+3-1
......@@ -1,4 +1,6 @@
11#![crate_type = "rlib"]
22extern crate m1;
33
4pub fn m2() { m1::m1() }
4pub fn m2() {
5 m1::m1()
6}
tests/run-make/rlib-chain/m3.rs+3-1
......@@ -1,4 +1,6 @@
11#![crate_type = "rlib"]
22extern crate m2;
33
4pub fn m3() { m2::m2() }
4pub fn m3() {
5 m2::m2()
6}
tests/run-make/rlib-chain/m4.rs+3-1
......@@ -1,3 +1,5 @@
11extern crate m3;
22
3fn main() { m3::m3() }
3fn main() {
4 m3::m3()
5}
tests/run-make/rustdoc-error-lines/input.rs+1-3
......@@ -6,9 +6,7 @@
66/// #![feature(bool_to_option)]
77/// let x: char = 1;
88/// ```
9pub fn foo() {
10
11}
9pub fn foo() {}
1210
1311/// Add some text around the test...
1412///
tests/run-make/rustdoc-error-lines/rmake.rs+4-4
......@@ -11,10 +11,10 @@ fn main() {
1111 let should_contain = &[
1212 "input.rs - foo (line 5)",
1313 "input.rs:7:15",
14 "input.rs - bar (line 15)",
15 "input.rs:17:15",
16 "input.rs - bar (line 24)",
17 "input.rs:26:15",
14 "input.rs - bar (line 13)",
15 "input.rs:15:15",
16 "input.rs - bar (line 22)",
17 "input.rs:24:15",
1818 ];
1919 for text in should_contain {
2020 assert!(output.contains(text), "output doesn't contains {:?}", text);
tests/run-make/rustdoc-map-file/foo.rs+2-2
......@@ -1,5 +1,5 @@
1pub use private::Quz;
21pub use hidden::Bar;
2pub use private::Quz;
33
44mod private {
55 pub struct Quz;
......@@ -12,5 +12,5 @@ pub mod hidden {
1212
1313#[macro_export]
1414macro_rules! foo {
15 () => {}
15 () => {};
1616}
tests/run-make/rustdoc-scrape-examples-invalid-expr/src/lib.rs+3-1
......@@ -1 +1,3 @@
1pub const fn f() -> usize { 5 }
1pub const fn f() -> usize {
2 5
3}
tests/run-make/rustdoc-scrape-examples-macros/examples/ex.rs+5-5
......@@ -8,20 +8,20 @@ a_proc_macro!(); // no
88
99#[an_attr_macro]
1010fn a() {
11 f(); // no
11 f(); // no
1212}
1313
1414#[an_attr_macro(with_span)]
1515fn b() {
16 f(); // yes
16 f(); // yes
1717}
1818
1919fn c() {
20 a_rules_macro!(f()); // yes
20 a_rules_macro!(f()); // yes
2121}
2222
2323fn d() {
24 a_rules_macro!(()); // no
24 a_rules_macro!(()); // no
2525}
2626
27fn main(){}
27fn main() {}
tests/run-make/rustdoc-scrape-examples-macros/src/lib.rs+3-1
......@@ -8,5 +8,7 @@ pub fn f() {}
88
99#[macro_export]
1010macro_rules! a_rules_macro {
11 ($e:expr) => { ($e, foobar::f()); }
11 ($e:expr) => {
12 ($e, foobar::f());
13 };
1214}
tests/run-make/rustdoc-scrape-examples-test/examples/ex.rs+1-1
......@@ -2,5 +2,5 @@ fn main() {}
22
33#[test]
44fn a_test() {
5 foobar::ok();
5 foobar::ok();
66}
tests/run-make/rustdoc-scrape-examples-whitespace/examples/ex.rs+4-2
......@@ -1,8 +1,10 @@
11struct Foo;
22impl Foo {
3 fn bar() { foobar::ok(); }
3 fn bar() {
4 foobar::ok();
5 }
46}
57
68fn main() {
7 Foo::bar();
9 Foo::bar();
810}
tests/run-make/share-generics-dylib/linked_leaf.rs+2-1
......@@ -1,11 +1,12 @@
1// Blank line after this one because it must come before `instance_user_{a,b}_rlib`.
12extern crate instance_user_dylib;
3
24extern crate instance_user_a_rlib;
35extern crate instance_user_b_rlib;
46
57use std::cell::Cell;
68
79fn main() {
8
910 instance_user_a_rlib::foo();
1011 instance_user_b_rlib::foo();
1112 instance_user_dylib::foo();
tests/run-make/split-debuginfo/main.rs+1-1
......@@ -1,6 +1,6 @@
11extern crate bar;
22
3use bar::{Bar, make_bar};
3use bar::{make_bar, Bar};
44
55fn main() {
66 let b = make_bar(3);
tests/run-make/stable-symbol-names/stable-symbol-names1.rs+11-11
......@@ -1,31 +1,31 @@
1#![crate_type="rlib"]
1#![crate_type = "rlib"]
22
33pub trait Foo {
4 fn generic_method<T>();
4 fn generic_method<T>();
55}
66
77pub struct Bar;
88
99impl Foo for Bar {
10 fn generic_method<T>() {}
10 fn generic_method<T>() {}
1111}
1212
1313pub fn mono_function() {
14 Bar::generic_method::<Bar>();
14 Bar::generic_method::<Bar>();
1515}
1616
1717pub fn mono_function_lifetime<'a>(x: &'a u64) -> u64 {
18 *x
18 *x
1919}
2020
2121pub fn generic_function<T>(t: T) -> T {
22 t
22 t
2323}
2424
2525pub fn user() {
26 generic_function(0u32);
27 generic_function("abc");
28 let x = 2u64;
29 generic_function(&x);
30 let _ = mono_function_lifetime(&x);
26 generic_function(0u32);
27 generic_function("abc");
28 let x = 2u64;
29 generic_function(&x);
30 let _ = mono_function_lifetime(&x);
3131}
tests/run-make/stable-symbol-names/stable-symbol-names2.rs+9-9
......@@ -1,17 +1,17 @@
1#![crate_type="rlib"]
1#![crate_type = "rlib"]
22
33extern crate stable_symbol_names1;
44
55pub fn user() {
6 stable_symbol_names1::generic_function(1u32);
7 stable_symbol_names1::generic_function("def");
8 let x = 2u64;
9 stable_symbol_names1::generic_function(&x);
10 stable_symbol_names1::mono_function();
11 stable_symbol_names1::mono_function_lifetime(&0);
6 stable_symbol_names1::generic_function(1u32);
7 stable_symbol_names1::generic_function("def");
8 let x = 2u64;
9 stable_symbol_names1::generic_function(&x);
10 stable_symbol_names1::mono_function();
11 stable_symbol_names1::mono_function_lifetime(&0);
1212}
1313
1414pub fn trait_impl_test_function() {
15 use stable_symbol_names1::*;
16 Bar::generic_method::<Bar>();
15 use stable_symbol_names1::*;
16 Bar::generic_method::<Bar>();
1717}
tests/run-make/static-unwinding/lib.rs+7-2
......@@ -5,11 +5,16 @@ pub static mut statik: isize = 0;
55struct A;
66impl Drop for A {
77 fn drop(&mut self) {
8 unsafe { statik = 1; }
8 unsafe {
9 statik = 1;
10 }
911 }
1012}
1113
12pub fn callback<F>(f: F) where F: FnOnce() {
14pub fn callback<F>(f: F)
15where
16 F: FnOnce(),
17{
1318 let _a = A;
1419 f();
1520}
tests/run-make/static-unwinding/main.rs+7-3
......@@ -7,15 +7,19 @@ static mut statik: isize = 0;
77struct A;
88impl Drop for A {
99 fn drop(&mut self) {
10 unsafe { statik = 1; }
10 unsafe {
11 statik = 1;
12 }
1113 }
1214}
1315
1416fn main() {
15 thread::spawn(move|| {
17 thread::spawn(move || {
1618 let _a = A;
1719 lib::callback(|| panic!());
18 }).join().unwrap_err();
20 })
21 .join()
22 .unwrap_err();
1923
2024 unsafe {
2125 assert_eq!(lib::statik, 1);
tests/run-make/suspicious-library/bar.rs+3-1
......@@ -1,3 +1,5 @@
11extern crate foo;
22
3fn main() { foo::foo() }
3fn main() {
4 foo::foo()
5}
tests/run-make/symbol-mangling-hashed/a_dylib.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="dylib"]
1#![crate_type = "dylib"]
22pub fn hello() {
33 println!("hello dylib");
44}
tests/run-make/symbol-mangling-hashed/a_rlib.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="rlib"]
1#![crate_type = "rlib"]
22
33pub fn hello() {
44 println!("hello rlib");
tests/run-make/symbol-mangling-hashed/b_bin.rs+1-1
......@@ -1,5 +1,5 @@
1extern crate a_rlib;
21extern crate a_dylib;
2extern crate a_rlib;
33extern crate b_dylib;
44
55fn main() {
tests/run-make/symbol-mangling-hashed/b_dylib.rs+2-2
......@@ -1,7 +1,7 @@
1#![crate_type="dylib"]
1#![crate_type = "dylib"]
22
3extern crate a_rlib;
43extern crate a_dylib;
4extern crate a_rlib;
55
66pub fn hello() {
77 a_rlib::hello();
tests/run-make/symbol-visibility/a_cdylib.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="cdylib"]
1#![crate_type = "cdylib"]
22
33extern crate an_rlib;
44
tests/run-make/symbol-visibility/a_rust_dylib.rs+4-2
......@@ -1,4 +1,4 @@
1#![crate_type="dylib"]
1#![crate_type = "dylib"]
22
33extern crate an_rlib;
44
......@@ -12,4 +12,6 @@ pub extern "C" fn public_c_function_from_rust_dylib() {
1212}
1313
1414// This should be exported if -Zshare-generics=yes
15pub fn public_generic_function_from_rust_dylib<T>(x: T) -> T { x }
15pub fn public_generic_function_from_rust_dylib<T>(x: T) -> T {
16 x
17}
tests/run-make/symbol-visibility/an_executable.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="bin"]
1#![crate_type = "bin"]
22
33extern crate an_rlib;
44
tests/run-make/symbol-visibility/an_rlib.rs+1-1
......@@ -1,4 +1,4 @@
1#![crate_type="rlib"]
1#![crate_type = "rlib"]
22
33pub fn public_rust_function_from_rlib() {}
44
tests/run-make/symlinked-extern/bar.rs+1-2
......@@ -2,5 +2,4 @@
22
33extern crate foo;
44
5pub fn bar(_s: foo::S) {
6}
5pub fn bar(_s: foo::S) {}
tests/run-make/symlinked-extern/foo.rs+3-1
......@@ -2,4 +2,6 @@
22
33pub struct S;
44
5pub fn foo() -> S { S }
5pub fn foo() -> S {
6 S
7}
tests/run-make/target-cpu-native/foo.rs+1-2
......@@ -1,2 +1 @@
1fn main() {
2}
1fn main() {}
tests/run-make/test-harness/test-ignore-cfg.rs+2-4
......@@ -1,9 +1,7 @@
11#[test]
22#[cfg_attr(ignorecfg, ignore)]
3fn shouldignore() {
4}
3fn shouldignore() {}
54
65#[test]
76#[cfg_attr(noignorecfg, ignore)]
8fn shouldnotignore() {
9}
7fn shouldnotignore() {}
tests/run-make/type-mismatch-same-crate-name/crateA.rs+2-2
......@@ -3,7 +3,7 @@ mod foo {
33}
44
55mod bar {
6 pub trait Bar{}
6 pub trait Bar {}
77
88 pub fn bar() -> Box<Bar> {
99 unimplemented!()
......@@ -12,5 +12,5 @@ mod bar {
1212
1313// This makes the publicly accessible path
1414// differ from the internal one.
15pub use bar::{bar, Bar};
1516pub use foo::Foo;
16pub use bar::{Bar, bar};
tests/run-make/type-mismatch-same-crate-name/crateB.rs+2-2
......@@ -1,4 +1,4 @@
11extern crate crateA;
22
3pub fn try_foo(x: crateA::Foo){}
4pub fn try_bar(x: Box<crateA::Bar>){}
3pub fn try_foo(x: crateA::Foo) {}
4pub fn try_bar(x: Box<crateA::Bar>) {}
tests/run-make/use-suggestions-rust-2018/use-suggestions.rs+1-1
......@@ -1,3 +1,3 @@
11fn main() {
2 let x = Baz{};
2 let x = Baz {};
33}
tests/run-make/wasm-custom-section/bar.rs+1-1
......@@ -10,4 +10,4 @@ pub static A: [u8; 2] = [5, 6];
1010pub static B: [u8; 2] = [7, 8];
1111
1212#[no_mangle]
13pub extern fn foo() {}
13pub extern "C" fn foo() {}
tests/run-make/wasm-custom-sections-opt/foo.rs+1-1
......@@ -13,7 +13,7 @@ pub mod another {
1313}
1414
1515#[no_mangle]
16pub extern fn foo() {
16pub extern "C" fn foo() {
1717 // This will import `another::foo` through ThinLTO passes, and it better not
1818 // also accidentally import the `FOO` custom section into this module as
1919 // well
tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs+2-7
......@@ -14,9 +14,7 @@ pub struct ArenaAllocator {
1414
1515impl ArenaAllocator {
1616 pub const fn new() -> Self {
17 Self {
18 arena: UnsafeCell::new(Arena::new()),
19 }
17 Self { arena: UnsafeCell::new(Arena::new()) }
2018 }
2119}
2220
......@@ -42,10 +40,7 @@ struct Arena {
4240
4341impl Arena {
4442 pub const fn new() -> Self {
45 Self {
46 buf: [0x55; ARENA_SIZE],
47 allocated: 0,
48 }
43 Self { buf: [0x55; ARENA_SIZE], allocated: 0 }
4944 }
5045
5146 pub unsafe fn alloc(&mut self, layout: Layout) -> *mut u8 {
tests/run-make/wasm-exceptions-nostd/src/lib.rs+18-16
......@@ -1,9 +1,7 @@
11#![no_std]
22#![crate_type = "cdylib"]
3
43// Allow a few unstable features because we create a panic
54// runtime for native wasm exceptions from scratch
6
75#![feature(core_intrinsics)]
86#![feature(lang_items)]
97#![feature(link_llvm_intrinsics)]
......@@ -39,20 +37,24 @@ pub extern "C" fn start() -> usize {
3937 let data = 0x1234usize as *mut u8; // Something to recognize
4038
4139 unsafe {
42 core::intrinsics::catch_unwind(|data: *mut u8| {
43 let _log_on_drop = LogOnDrop;
44
45 logging::log_str(&alloc::format!("`r#try` called with ptr {:?}", data));
46 let x = [12];
47 let _ = x[4]; // should panic
48
49 logging::log_str("This line should not be visible! :(");
50 }, data, |data, exception| {
51 let exception = *Box::from_raw(exception as *mut String);
52 logging::log_str("Caught something!");
53 logging::log_str(&alloc::format!(" data : {:?}", data));
54 logging::log_str(&alloc::format!(" exception: {:?}", exception));
55 });
40 core::intrinsics::catch_unwind(
41 |data: *mut u8| {
42 let _log_on_drop = LogOnDrop;
43
44 logging::log_str(&alloc::format!("`r#try` called with ptr {:?}", data));
45 let x = [12];
46 let _ = x[4]; // should panic
47
48 logging::log_str("This line should not be visible! :(");
49 },
50 data,
51 |data, exception| {
52 let exception = *Box::from_raw(exception as *mut String);
53 logging::log_str("Caught something!");
54 logging::log_str(&alloc::format!(" data : {:?}", data));
55 logging::log_str(&alloc::format!(" exception: {:?}", exception));
56 },
57 );
5658 }
5759
5860 logging::log_str("This program terminates correctly.");
tests/run-make/wasm-exceptions-nostd/src/panicking.rs+1-4
......@@ -17,10 +17,7 @@ fn panic_handler(info: &core::panic::PanicInfo<'_>) -> ! {
1717 use alloc::boxed::Box;
1818 use alloc::string::ToString;
1919
20 let msg = info
21 .message()
22 .map(|msg| msg.to_string())
23 .unwrap_or("(no message)".to_string());
20 let msg = info.message().map(|msg| msg.to_string()).unwrap_or("(no message)".to_string());
2421 let exception = Box::new(msg.to_string());
2522 unsafe {
2623 let exception_raw = Box::into_raw(exception);
tests/run-make/wasm-export-all-symbols/bar.rs+1-1
......@@ -1,7 +1,7 @@
11#![crate_type = "rlib"]
22
33#[no_mangle]
4pub extern fn foo() {}
4pub extern "C" fn foo() {}
55
66#[no_mangle]
77pub static FOO: u64 = 42;
tests/run-make/wasm-symbols-not-exported/bar.rs+2-3
......@@ -11,15 +11,14 @@ unsafe impl GlobalAlloc for B {
1111 1 as *mut u8
1212 }
1313
14 unsafe fn dealloc(&self, ptr: *mut u8, x: Layout) {
15 }
14 unsafe fn dealloc(&self, ptr: *mut u8, x: Layout) {}
1615}
1716
1817#[global_allocator]
1918static A: B = B;
2019
2120#[no_mangle]
22pub extern fn foo(a: u32) -> u32 {
21pub extern "C" fn foo(a: u32) -> u32 {
2322 assert_eq!(a, 3);
2423 a * 2
2524}
tests/run-make/wasm-symbols-not-exported/foo.rs+1-1
......@@ -1,7 +1,7 @@
11#![crate_type = "cdylib"]
22
33#[no_mangle]
4pub extern fn foo() {
4pub extern "C" fn foo() {
55 println!("foo");
66 panic!("test");
77}
tests/run-make/wasm-symbols-not-imported/foo.rs+1-1
......@@ -4,7 +4,7 @@
44use core::panic::PanicInfo;
55
66#[no_mangle]
7pub extern fn foo() {
7pub extern "C" fn foo() {
88 panic!()
99}
1010
tests/run-make/windows-spawn/spawn.rs+1-1
......@@ -6,5 +6,5 @@ fn main() {
66 assert_eq!(
77 Command::new("hopefullydoesntexist").arg("bar").spawn().unwrap_err().kind(),
88 ErrorKind::NotFound
9 )
9 );
1010}
tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs+8-16
......@@ -1,17 +1,9 @@
11fn main() {
2 cc::Build::new()
3 .file("foo.c")
4 .compile("foo_c");
2 cc::Build::new().file("foo.c").compile("foo_c");
53
6 cc::Build::new()
7 .file("foo_asm.s")
8 .compile("foo_asm");
4 cc::Build::new().file("foo_asm.s").compile("foo_asm");
95
10 cc::Build::new()
11 .cpp(true)
12 .cpp_set_stdlib(None)
13 .file("foo_cxx.cpp")
14 .compile("foo_cxx");
6 cc::Build::new().cpp(true).cpp_set_stdlib(None).file("foo_cxx.cpp").compile("foo_cxx");
157
168 // When the cmake crate detects the clang compiler, it passes the
179 // "--target" argument to the linker which subsequently fails. The
......@@ -20,11 +12,11 @@ fn main() {
2012 // `CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY` can be used
2113 // https://cmake.org/cmake/help/v3.5/module/CMakeForceCompiler.html
2214 let dst = cmake::Config::new("libcmake_foo")
23 .build_target("cmake_foo")
24 .define("CMAKE_C_COMPILER_FORCED", "1")
25 .define("CMAKE_CXX_COMPILER_FORCED", "1")
26 .define("CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY", "1")
27 .build();
15 .build_target("cmake_foo")
16 .define("CMAKE_C_COMPILER_FORCED", "1")
17 .define("CMAKE_CXX_COMPILER_FORCED", "1")
18 .define("CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY", "1")
19 .build();
2820 println!("cargo:rustc-link-search=native={}/build/", dst.display());
2921 println!("cargo:rustc-link-lib=static=cmake_foo");
3022}