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`
This commit is contained in:
bors 2024-05-31 12:18:57 +00:00
commit 2a2c29aafa
391 changed files with 2145 additions and 2015 deletions

View File

@ -10,9 +10,27 @@ ignore = [
"/build-*/",
"/vendor/",
# Tests for now are not formatted, as they are sometimes pretty-printing constrained
# (and generally rustfmt can move around comments in UI-testing incompatible ways).
"/tests/",
# Some tests are not formatted, for multiple reasons:
# - some contain syntax errors that cause rustfmt to give an error
# - some UI tests are broken by different formatting
# - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
"/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
"/tests/crashes/", # Many tests contain syntax errors.
"/tests/debuginfo/", # Tests are somewhat sensitive to source code layout.
"/tests/incremental/", # Tests are somewhat sensitive to source code layout.
"/tests/mir-opt/",
"/tests/pretty/",
"/tests/run-make/translation/test.rs", # Contains syntax errors.
"/tests/run-make-fulldeps/",
"/tests/run-pass-valgrind/",
"/tests/rustdoc/",
"/tests/rustdoc-gui/",
"/tests/rustdoc-js/",
"/tests/rustdoc-json/",
"/tests/rustdoc-js-std/",
"/tests/rustdoc-ui/",
"/tests/ui/",
"/tests/ui-fulldeps/",
# Do not format submodules.
# FIXME: sync submodule list with tidy/bootstrap/etc

View File

@ -1,7 +1,7 @@
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=1
//@ only-x86_64
#![crate_type="rlib"]
#![crate_type = "rlib"]
// CHECK-LABEL: align_offset_byte_ptr
// CHECK: leaq 31

View File

@ -5,8 +5,8 @@
#![feature(portable_simd)]
use std::simd::Simd;
use std::arch::asm;
use std::simd::Simd;
#[target_feature(enable = "avx")]
#[no_mangle]

View File

@ -18,7 +18,8 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 {
// CHECK: {{call .*_mm_blend_ps.*}}
// CHECK-NOT: blendps
// CHECK: ret
#[inline(never)] |x, y| _mm_blend_ps(x, y, 0b0101)
#[inline(never)]
|x, y| _mm_blend_ps(x, y, 0b0101)
};
f(x, y)
}
@ -33,9 +34,8 @@ pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 {
// CHECK: blendps
// CHECK-NOT: _mm_blend_ps
// CHECK: ret
#[inline(never)] |x, y| unsafe {
_mm_blend_ps(x, y, 0b0101)
}
#[inline(never)]
|x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
};
f(x, y)
}
@ -52,9 +52,8 @@ pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 {
// CHECK-NOT: _mm_blend_ps
// CHECK: ret
let f = {
#[inline] |x, y| unsafe {
_mm_blend_ps(x, y, 0b0101)
}
#[inline]
|x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
};
f(x, y)
}

View File

@ -4,8 +4,7 @@
//@ revisions: opt-speed opt-size
//@ [opt-speed] compile-flags: -Copt-level=2 -Cdebug-assertions=no
//@ [opt-size] compile-flags: -Copt-level=s -Cdebug-assertions=no
#![crate_type="rlib"]
#![crate_type = "rlib"]
#![feature(core_intrinsics)]
#![feature(pointer_is_aligned_to)]
@ -16,9 +15,7 @@
// CHECK: retq
#[no_mangle]
pub unsafe fn is_aligned_to_unchecked(ptr: *const u8, align: usize) -> bool {
unsafe {
std::intrinsics::assume(align.is_power_of_two())
}
unsafe { std::intrinsics::assume(align.is_power_of_two()) }
ptr.is_aligned_to(align)
}

View File

@ -3,10 +3,9 @@
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic
//@ [x64] needs-llvm-components: x86
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]
#![crate_type = "rlib"]
#[lang = "sized"]
trait Sized {}
@ -17,9 +16,7 @@ trait Copy {}
// CHECK: {{(jmpq|callq)}} *other_fn@GOTPCREL(%rip)
#[no_mangle]
pub fn call_other_fn() -> u8 {
unsafe {
other_fn()
}
unsafe { other_fn() }
}
// CHECK-LABEL: other_fn:
@ -27,9 +24,9 @@ pub fn call_other_fn() -> u8 {
#[no_mangle]
#[inline(never)]
pub fn other_fn() -> u8 {
unsafe {
foreign_fn()
}
unsafe { foreign_fn() }
}
extern "C" {fn foreign_fn() -> u8;}
extern "C" {
fn foreign_fn() -> u8;
}

View File

@ -3,10 +3,9 @@
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie
//@ [x64] needs-llvm-components: x86
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]
#![crate_type = "rlib"]
#[lang = "sized"]
trait Sized {}
@ -18,9 +17,7 @@ trait Copy {}
// CHECK: {{(jmp|callq)}} other_fn
#[no_mangle]
pub fn call_other_fn() -> u8 {
unsafe {
other_fn()
}
unsafe { other_fn() }
}
// CHECK-LABEL: other_fn:
@ -30,9 +27,9 @@ pub fn call_other_fn() -> u8 {
#[no_mangle]
#[inline(never)]
pub fn other_fn() -> u8 {
unsafe {
foreign_fn()
}
unsafe { foreign_fn() }
}
extern "C" {fn foreign_fn() -> u8;}
extern "C" {
fn foreign_fn() -> u8;
}

View File

@ -10,12 +10,9 @@
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
#![crate_type = "lib"]
#![allow(incomplete_features)]
#![feature(unsized_locals, unsized_fn_params)]
// CHECK-LABEL: emptyfn:
#[no_mangle]
pub fn emptyfn() {
@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __security_check_cookie
}
// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
@ -205,7 +201,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}
// CHECK-LABEL: local_large_var_moved
@ -259,7 +255,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// EOF
// ```
// all: __security_check_cookie
// strong: __security_check_cookie
// basic: __security_check_cookie
@ -267,7 +262,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// missing-NOT: __security_check_cookie
}
extern "C" {
// A call to an external `alloca` function is *not* recognized as an
// `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 ())) {
// missing-NOT: __security_check_cookie
}
// CHECK-LABEL: alloca_dynamic_arg
#[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@ -340,7 +333,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
// CHECK-LABEL: unsized_fn_param
#[no_mangle]
pub 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])) {
// alloca, and is therefore not protected by the `strong` or `basic`
// heuristics.
// We should have a __security_check_cookie call in `all` and `strong` modes but
// LLVM does not support generating stack protectors in functions with funclet
// based EH personalities.

View File

@ -10,12 +10,9 @@
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
#![crate_type = "lib"]
#![allow(incomplete_features)]
#![feature(unsized_locals, unsized_fn_params)]
// CHECK-LABEL: emptyfn:
#[no_mangle]
pub fn emptyfn() {
@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __security_check_cookie
}
// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
@ -213,7 +209,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}
// CHECK-LABEL: local_large_var_moved
@ -267,7 +263,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// EOF
// ```
// all: __security_check_cookie
// strong: __security_check_cookie
// basic: __security_check_cookie
@ -275,7 +270,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// missing-NOT: __security_check_cookie
}
extern "C" {
// A call to an external `alloca` function is *not* recognized as an
// `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 ())) {
// missing-NOT: __security_check_cookie
}
// CHECK-LABEL: alloca_dynamic_arg
#[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@ -348,7 +341,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
// CHECK-LABEL: unsized_fn_param
#[no_mangle]
pub 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])) {
// alloca, and is therefore not protected by the `strong` or `basic`
// heuristics.
// We should have a __security_check_cookie call in `all` and `strong` modes but
// LLVM does not support generating stack protectors in functions with funclet
// based EH personalities.

View File

@ -143,7 +143,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __stack_chk_fail
}
// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
@ -194,7 +193,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}
// CHECK-LABEL: local_large_var_moved
@ -255,7 +254,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// missing-NOT: __stack_chk_fail
}
extern "C" {
// A call to an external `alloca` function is *not* recognized as an
// `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 ())) {
// missing-NOT: __stack_chk_fail
}
// CHECK-LABEL: alloca_dynamic_arg
#[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@ -328,7 +325,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
// CHECK-LABEL: unsized_fn_param
#[no_mangle]
pub 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])) {
// alloca, and is therefore not protected by the `strong` or `basic`
// heuristics.
// all: __stack_chk_fail
// strong-NOT: __stack_chk_fail
// basic-NOT: __stack_chk_fail

View File

@ -9,15 +9,15 @@
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]
#![crate_type = "rlib"]
#[lang="sized"]
#[lang = "sized"]
trait Sized {}
#[lang="copy"]
#[lang = "copy"]
trait Copy {}
#[lang="sync"]
#[lang = "sync"]
trait Sync {}
#[lang = "drop_in_place"]
@ -42,9 +42,7 @@ extern "C" {
// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG]], :lo12:chaenomeles]
#[no_mangle]
pub fn banana() -> u8 {
unsafe {
*(chaenomeles as *mut u8)
}
unsafe { *(chaenomeles as *mut u8) }
}
// CHECK-LABEL: peach:
@ -53,9 +51,7 @@ pub fn banana() -> u8 {
// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:banana]
#[no_mangle]
pub fn peach() -> u8 {
unsafe {
*(banana as *mut u8)
}
unsafe { *(banana as *mut u8) }
}
// CHECK-LABEL: mango:
@ -65,9 +61,7 @@ pub fn peach() -> u8 {
// A64-NEXT: ldr {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:EXOCHORDA]
#[no_mangle]
pub fn mango() -> u8 {
unsafe {
*EXOCHORDA
}
unsafe { *EXOCHORDA }
}
// CHECK-LABEL: orange:

View File

@ -4,5 +4,4 @@
// CHECK: main
pub fn main() {
}
pub fn main() {}

View File

@ -8,7 +8,7 @@
#![feature(core_intrinsics)]
#![feature(rustc_attrs)]
extern {
extern "C" {
fn may_panic();
#[rustc_nounwind]
@ -19,7 +19,9 @@ struct LogOnDrop;
impl Drop for LogOnDrop {
fn drop(&mut self) {
unsafe { log_number(0); }
unsafe {
log_number(0);
}
}
}
@ -27,7 +29,9 @@ impl Drop for LogOnDrop {
#[no_mangle]
pub fn test_cleanup() {
let _log_on_drop = LogOnDrop;
unsafe { may_panic(); }
unsafe {
may_panic();
}
// CHECK-NOT: call
// CHECK: try
@ -41,12 +45,16 @@ pub fn test_cleanup() {
#[no_mangle]
pub fn test_rtry() {
unsafe {
core::intrinsics::catch_unwind(|_| {
may_panic();
}, core::ptr::null_mut(), |data, exception| {
log_number(data as usize);
log_number(exception as usize);
});
core::intrinsics::catch_unwind(
|_| {
may_panic();
},
core::ptr::null_mut(),
|data, exception| {
log_number(data as usize);
log_number(exception as usize);
},
);
}
// CHECK-NOT: call

View File

@ -5,7 +5,7 @@
//@ only-x86_64-fortanix-unknown-sgx
#[no_mangle]
pub extern fn plus_one(r: &mut u64) {
pub extern "C" fn plus_one(r: &mut u64) {
*r = *r + 1;
}

View File

@ -5,7 +5,7 @@
//@ only-x86_64-fortanix-unknown-sgx
#[no_mangle]
pub extern fn myret() {}
pub extern "C" fn myret() {}
// CHECK: myret:
// CHECK: popq [[REGISTER:%[a-z]+]]
// CHECK-NEXT: lfence

View File

@ -2,25 +2,43 @@
#![crate_type = "lib"]
pub trait Trait : Sized {
pub trait Trait: Sized {
fn without_self() -> u32;
fn without_self_default() -> u32 { 0 }
fn without_self_default() -> u32 {
0
}
fn with_default_impl(self) -> Self { self }
fn with_default_impl_generic<T>(self, x: T) -> (Self, T) { (self, x) }
fn with_default_impl(self) -> Self {
self
}
fn with_default_impl_generic<T>(self, x: T) -> (Self, T) {
(self, x)
}
fn without_default_impl(x: u32) -> (Self, u32);
fn without_default_impl_generic<T>(x: T) -> (Self, T);
}
impl Trait for char {
fn without_self() -> u32 { 2 }
fn without_default_impl(x: u32) -> (Self, u32) { ('c', x) }
fn without_default_impl_generic<T>(x: T) -> (Self, T) { ('c', x) }
fn without_self() -> u32 {
2
}
fn without_default_impl(x: u32) -> (Self, u32) {
('c', x)
}
fn without_default_impl_generic<T>(x: T) -> (Self, T) {
('c', x)
}
}
impl Trait for u32 {
fn without_self() -> u32 { 1 }
fn without_default_impl(x: u32) -> (Self, u32) { (0, x) }
fn without_default_impl_generic<T>(x: T) -> (Self, T) { (0, x) }
fn without_self() -> u32 {
1
}
fn without_default_impl(x: u32) -> (Self, u32) {
(0, x)
}
fn without_default_impl_generic<T>(x: T) -> (Self, T) {
(0, x)
}
}

View File

@ -2,22 +2,19 @@
#[inline]
pub fn inlined_fn(x: i32, y: i32) -> i32 {
let closure = |a, b| { a + b };
let closure = |a, b| a + b;
closure(x, y)
}
pub fn inlined_fn_generic<T>(x: i32, y: i32, z: T) -> (i32, T) {
let closure = |a, b| { a + b };
let closure = |a, b| a + b;
(closure(x, y), z)
}
pub fn non_inlined_fn(x: i32, y: i32) -> i32 {
let closure = |a, b| { a + b };
let closure = |a, b| a + b;
closure(x, y)
}

View File

@ -14,7 +14,6 @@ extern crate cgu_extern_closures;
//~ MONO_ITEM fn cross_crate_closures::start[0]
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]::{{closure}}[0]
let _ = cgu_extern_closures::inlined_fn(1, 2);

View File

@ -24,8 +24,6 @@ fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl
let _ = Trait::with_default_impl('c');
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<&str>
let _ = Trait::with_default_impl_generic(0u32, "abc");
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<bool>

View File

@ -15,7 +15,6 @@ impl Drop for StructWithDtor {
//~ MONO_ITEM fn start
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor; 2]> - shim(Some([StructWithDtor; 2])) @@ drop_in_place_intrinsic-cgu.0[Internal]
let x = [StructWithDtor(0), StructWithDtor(1)];

View File

@ -16,7 +16,6 @@ fn take_fn_pointer<T1, T2>(f: fn(T1, T2), x: T1, y: T2) {
//~ MONO_ITEM fn start
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn take_fn_once::<u32, &str, fn(u32, &str) {function::<u32, &str>}>
//~ MONO_ITEM fn function::<u32, &str>
//~ MONO_ITEM fn <fn(u32, &str) {function::<u32, &str>} as std::ops::FnOnce<(u32, &str)>>::call_once - shim(fn(u32, &str) {function::<u32, &str>})

View File

@ -21,7 +21,7 @@ struct StructNoDrop<T1, T2> {
enum EnumWithDrop<T1, T2> {
A(T1),
B(T2)
B(T2),
}
impl<T1, T2> Drop for EnumWithDrop<T1, T2> {
@ -30,10 +30,9 @@ impl<T1, T2> Drop for EnumWithDrop<T1, T2> {
enum EnumNoDrop<T1, T2> {
A(T1),
B(T2)
B(T2),
}
struct NonGenericNoDrop(#[allow(dead_code)] i32);
struct NonGenericWithDrop(#[allow(dead_code)] i32);
@ -67,24 +66,24 @@ fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn <EnumWithDrop<i32, i64> as std::ops::Drop>::drop
let _ = match EnumWithDrop::A::<i32, i64>(0) {
EnumWithDrop::A(x) => x,
EnumWithDrop::B(x) => x as i32
EnumWithDrop::B(x) => x as i32,
};
//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop<f64, f32>> - shim(Some(EnumWithDrop<f64, f32>)) @@ generic_drop_glue-cgu.0[Internal]
//~ MONO_ITEM fn <EnumWithDrop<f64, f32> as std::ops::Drop>::drop
let _ = match EnumWithDrop::B::<f64, f32>(1.0) {
EnumWithDrop::A(x) => x,
EnumWithDrop::B(x) => x as f64
EnumWithDrop::B(x) => x as f64,
};
let _ = match EnumNoDrop::A::<i32, i64>(0) {
EnumNoDrop::A(x) => x,
EnumNoDrop::B(x) => x as i32
EnumNoDrop::B(x) => x as i32,
};
let _ = match EnumNoDrop::B::<f64, f32>(1.0) {
EnumNoDrop::A(x) => x,
EnumNoDrop::B(x) => x as f64
EnumNoDrop::B(x) => x as f64,
};
0

View File

@ -8,15 +8,13 @@ struct Struct<T> {
f: fn(x: T) -> T,
}
fn id<T>(x: T) -> T { x }
fn id<T>(x: T) -> T {
x
}
impl<T> Struct<T> {
fn new(x: T) -> Struct<T> {
Struct {
x: x,
f: id
}
Struct { x: x, f: id }
}
fn get<T2>(self, x: T2) -> (T, T2) {
@ -25,11 +23,10 @@ impl<T> Struct<T> {
}
pub struct LifeTimeOnly<'a> {
_a: &'a u32
_a: &'a u32,
}
impl<'a> LifeTimeOnly<'a> {
//~ MONO_ITEM fn LifeTimeOnly::<'_>::foo
pub fn foo(&self) {}
//~ MONO_ITEM fn LifeTimeOnly::<'_>::bar

View File

@ -10,11 +10,13 @@ trait Trait {
}
struct Struct<T> {
_a: T
_a: T,
}
impl<T> Trait for Struct<T> {
fn foo(&self) -> u32 { 0 }
fn foo(&self) -> u32 {
0
}
fn bar(&self) {}
}

View File

@ -7,7 +7,7 @@
//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal]
struct StructWithDrop {
x: i32
x: i32,
}
impl Drop for StructWithDrop {
@ -16,12 +16,12 @@ impl Drop for StructWithDrop {
}
struct StructNoDrop {
x: i32
x: i32,
}
//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal]
enum EnumWithDrop {
A(i32)
A(i32),
}
impl Drop for EnumWithDrop {
@ -30,7 +30,7 @@ impl Drop for EnumWithDrop {
}
enum EnumNoDrop {
A(i32)
A(i32),
}
//~ MONO_ITEM fn start
@ -39,10 +39,10 @@ fn start(_: isize, _: *const *const u8) -> isize {
let _ = StructWithDrop { x: 0 }.x;
let _ = StructNoDrop { x: 0 }.x;
let _ = match EnumWithDrop::A(0) {
EnumWithDrop::A(x) => x
EnumWithDrop::A(x) => x,
};
let _ = match EnumNoDrop::A(0) {
EnumNoDrop::A(x) => x
EnumNoDrop::A(x) => x,
};
0

View File

@ -25,7 +25,9 @@ fn bar() {
baz();
}
struct Struct { _x: i32 }
struct Struct {
_x: i32,
}
impl Struct {
//~ MONO_ITEM fn Struct::foo

View File

@ -1,12 +1,12 @@
//@ compile-flags:-Zprint-mono-items=eager
#![deny(dead_code)]
#![crate_type="lib"]
#![crate_type = "lib"]
use std::ops::{Index, IndexMut, Add, Deref};
use std::ops::{Add, Deref, Index, IndexMut};
pub struct Indexable {
data: [u8; 3]
data: [u8; 3],
}
impl Index<usize> for Indexable {
@ -14,32 +14,22 @@ impl Index<usize> for Indexable {
//~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index
fn index(&self, index: usize) -> &Self::Output {
if index >= 3 {
&self.data[0]
} else {
&self.data[index]
}
if index >= 3 { &self.data[0] } else { &self.data[index] }
}
}
impl IndexMut<usize> for Indexable {
//~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
if index >= 3 {
&mut self.data[0]
} else {
&mut self.data[index]
}
if index >= 3 { &mut self.data[0] } else { &mut self.data[index] }
}
}
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne
#[derive(PartialEq)]
pub struct Equatable(u32);
impl Add<u32> for Equatable {
type Output = u32;

View File

@ -2,9 +2,9 @@
#![feature(start)]
pub static FN : fn() = foo::<i32>;
pub static FN: fn() = foo::<i32>;
pub fn foo<T>() { }
pub fn foo<T>() {}
//~ MONO_ITEM fn foo::<T>
//~ MONO_ITEM static FN

View File

@ -9,7 +9,6 @@ pub trait SomeTrait {
}
impl SomeTrait for i64 {
//~ MONO_ITEM fn <i64 as SomeTrait>::foo
fn foo(&self) {}
@ -17,7 +16,6 @@ impl SomeTrait for i64 {
}
impl SomeTrait for i32 {
//~ MONO_ITEM fn <i32 as SomeTrait>::foo
fn foo(&self) {}
@ -31,7 +29,6 @@ pub trait SomeGenericTrait<T> {
// Concrete impl of generic trait
impl SomeGenericTrait<u32> for f64 {
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::foo
fn foo(&self, _: u32) {}
@ -40,7 +37,6 @@ impl SomeGenericTrait<u32> for f64 {
// Generic impl of generic trait
impl<T> SomeGenericTrait<T> for f32 {
fn foo(&self, _: T) {}
fn bar<T2>(&self, _: T, _: T2) {}
}
@ -48,26 +44,26 @@ impl<T> SomeGenericTrait<T> for f32 {
//~ MONO_ITEM fn start
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn <i32 as SomeTrait>::bar::<char>
0i32.bar('x');
//~ MONO_ITEM fn <i32 as SomeTrait>::bar::<char>
0i32.bar('x');
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<&str>
0f64.bar(0u32, "&str");
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<&str>
0f64.bar(0u32, "&str");
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<()>
0f64.bar(0u32, ());
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<()>
0f64.bar(0u32, ());
//~ MONO_ITEM fn <f32 as SomeGenericTrait<char>>::foo
0f32.foo('x');
//~ MONO_ITEM fn <f32 as SomeGenericTrait<char>>::foo
0f32.foo('x');
//~ MONO_ITEM fn <f32 as SomeGenericTrait<i64>>::foo
0f32.foo(-1i64);
//~ MONO_ITEM fn <f32 as SomeGenericTrait<i64>>::foo
0f32.foo(-1i64);
//~ MONO_ITEM fn <f32 as SomeGenericTrait<u32>>::bar::<()>
0f32.bar(0u32, ());
//~ MONO_ITEM fn <f32 as SomeGenericTrait<u32>>::bar::<()>
0f32.bar(0u32, ());
//~ MONO_ITEM fn <f32 as SomeGenericTrait<&str>>::bar::<&str>
0f32.bar("&str", "&str");
//~ MONO_ITEM fn <f32 as SomeGenericTrait<&str>>::bar::<&str>
0f32.bar("&str", "&str");
0
0
}

View File

@ -3,16 +3,19 @@
#![deny(dead_code)]
#![feature(start)]
trait Trait : Sized {
fn foo(self) -> Self { self }
trait Trait: Sized {
fn foo(self) -> Self {
self
}
}
impl Trait for u32 {
fn foo(self) -> u32 { self }
fn foo(self) -> u32 {
self
}
}
impl Trait for char {
}
impl Trait for char {}
fn take_foo_once<T, F: FnOnce(T) -> T>(f: F, arg: T) -> T {
(f)(arg)

View File

@ -4,8 +4,10 @@
#![feature(start)]
trait SomeTrait {
fn foo(&self) { }
fn bar<T>(&self, x: T) -> T { x }
fn foo(&self) {}
fn bar<T>(&self, x: T) -> T {
x
}
}
impl SomeTrait for i8 {
@ -17,7 +19,7 @@ impl SomeTrait for i8 {
}
trait SomeGenericTrait<T1> {
fn foo(&self) { }
fn foo(&self) {}
fn bar<T2>(&self, x: T1, y: T2) {}
}

View File

@ -27,7 +27,7 @@ impl Trait for char {
struct Struct<T: ?Sized> {
_a: u32,
_b: i32,
_c: T
_c: T,
}
impl Trait for f64 {
@ -60,11 +60,7 @@ fn start(_: isize, _: *const *const u8) -> isize {
let _char_unsized = char_sized as &Trait;
// struct field
let struct_sized = &Struct {
_a: 1,
_b: 2,
_c: 3.0f64
};
let struct_sized = &Struct { _a: 1, _b: 2, _c: 3.0f64 };
//~ MONO_ITEM fn std::ptr::drop_in_place::<f64> - shim(None) @@ unsizing-cgu.0[Internal]
//~ MONO_ITEM fn <f64 as Trait>::foo
let _struct_unsized = struct_sized as &Struct<Trait>;

View File

@ -1,6 +1,6 @@
//@ compile-flags:-Zprint-mono-items=eager
#![crate_type="lib"]
#![crate_type = "lib"]
#![deny(dead_code)]
// 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) {
}
pub struct Struct<T> {
x: T
x: T,
}
impl<T> Struct<T> {
@ -29,7 +29,7 @@ impl<T> Struct<T> {
pub enum Enum<T> {
A(T),
B { x: T }
B { x: T },
}
impl<T> Enum<T> {
@ -56,7 +56,7 @@ impl<T> TupleStruct<T> {
pub type Pair<T> = (T, T);
pub struct NonGeneric {
x: i32
x: i32,
}
impl NonGeneric {

View File

@ -3,7 +3,7 @@
//@ compile-flags:-Zshare-generics=yes -Copt-level=0
//@ no-prefer-dynamic
#![crate_type="rlib"]
#![crate_type = "rlib"]
pub fn generic_fn<T>(x: T, y: T) -> (T, T) {
(x, y)

View File

@ -3,7 +3,7 @@
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=y
#![allow(dead_code)]
#![crate_type="lib"]
#![crate_type = "lib"]
//@ aux-build:cgu_generic_function.rs
extern crate cgu_generic_function;

View File

@ -3,7 +3,7 @@
//@ compile-flags:-Zprint-mono-items=lazy
//@ compile-flags:-Zinline-in-all-cgus
#![crate_type="lib"]
#![crate_type = "lib"]
//@ aux-build:cgu_explicit_inlining.rs
extern crate cgu_explicit_inlining;
@ -15,8 +15,7 @@ extern crate cgu_explicit_inlining;
//~ MONO_ITEM fn cgu_explicit_inlining::always_inlined @@ inlining_from_extern_crate[Internal] inlining_from_extern_crate-mod2[Internal]
//~ MONO_ITEM fn user @@ inlining_from_extern_crate[External]
pub fn user()
{
pub fn user() {
cgu_explicit_inlining::inlined();
cgu_explicit_inlining::always_inlined();
@ -28,8 +27,7 @@ pub mod mod1 {
use cgu_explicit_inlining;
//~ MONO_ITEM fn mod1::user @@ inlining_from_extern_crate-mod1[External]
pub fn user()
{
pub fn user() {
cgu_explicit_inlining::inlined();
// does not generate a monomorphization in this crate
@ -41,8 +39,7 @@ pub mod mod2 {
use cgu_explicit_inlining;
//~ MONO_ITEM fn mod2::user @@ inlining_from_extern_crate-mod2[External]
pub fn user()
{
pub fn user() {
cgu_explicit_inlining::always_inlined();
// does not generate a monomorphization in this crate

View File

@ -3,13 +3,15 @@
//@ compile-flags:-Zprint-mono-items=eager
#![allow(dead_code)]
#![crate_type="lib"]
#![crate_type = "lib"]
//~ MONO_ITEM fn generic::<u32> @@ local_generic.volatile[External]
//~ MONO_ITEM fn generic::<u64> @@ local_generic.volatile[External]
//~ MONO_ITEM fn generic::<char> @@ local_generic.volatile[External]
//~ MONO_ITEM fn generic::<&str> @@ local_generic.volatile[External]
pub fn generic<T>(x: T) -> T { x }
pub fn generic<T>(x: T) -> T {
x
}
//~ MONO_ITEM fn user @@ local_generic[Internal]
fn user() {

View File

@ -4,16 +4,13 @@
//@ compile-flags:-Zinline-in-all-cgus=no
#![allow(dead_code)]
#![crate_type="lib"]
#![crate_type = "lib"]
mod inline {
//~ MONO_ITEM fn inline::inlined_function @@ local_inlining_but_not_all-inline[External]
#[inline]
pub fn inlined_function()
{
}
pub fn inlined_function() {}
}
pub mod user1 {
@ -37,7 +34,5 @@ pub mod user2 {
pub mod non_user {
//~ MONO_ITEM fn non_user::baz @@ local_inlining_but_not_all-non_user[External]
pub fn baz() {
}
pub fn baz() {}
}

View File

@ -4,17 +4,14 @@
//@ compile-flags:-Zinline-in-all-cgus
#![allow(dead_code)]
#![crate_type="lib"]
#![crate_type = "lib"]
mod inline {
// Important: This function should show up in all codegen units where it is inlined
//~ MONO_ITEM fn inline::inlined_function @@ local_inlining-user1[Internal] local_inlining-user2[Internal]
#[inline(always)]
pub fn inlined_function()
{
}
pub fn inlined_function() {}
}
pub mod user1 {
@ -38,7 +35,5 @@ pub mod user2 {
pub mod non_user {
//~ MONO_ITEM fn non_user::baz @@ local_inlining-non_user[External]
pub fn baz() {
}
pub fn baz() {}
}

View File

@ -4,16 +4,13 @@
//@ compile-flags:-Zinline-in-all-cgus
#![allow(dead_code)]
#![crate_type="rlib"]
#![crate_type = "rlib"]
mod inline {
//~ MONO_ITEM fn inline::inlined_function @@ local_transitive_inlining-indirect_user[Internal]
#[inline(always)]
pub fn inlined_function()
{
}
pub fn inlined_function() {}
}
mod direct_user {
@ -38,7 +35,5 @@ pub mod indirect_user {
pub mod non_user {
//~ MONO_ITEM fn non_user::baz @@ local_transitive_inlining-non_user[External]
pub fn baz() {
}
pub fn baz() {}
}

View File

@ -15,7 +15,7 @@ struct SomeType;
struct SomeGenericType<T1, T2>(T1, T2);
mod mod1 {
use super::{SomeType, SomeGenericType};
use super::{SomeGenericType, SomeType};
// Even though the impl is in `mod1`, the methods should end up in the
// parent module, since that is where their self-type is.
@ -40,8 +40,7 @@ trait Trait {
// We provide an implementation of `Trait` for all types. The corresponding
// monomorphizations should end up in whichever module the concrete `T` is.
impl<T> Trait for T
{
impl<T> Trait for T {
fn foo(&self) {}
}

View File

@ -3,7 +3,7 @@
//@ compile-flags:-Zprint-mono-items=eager
#![allow(dead_code)]
#![crate_type="lib"]
#![crate_type = "lib"]
//~ MONO_ITEM fn foo @@ regular_modules[Internal]
fn foo() {}

View File

@ -4,14 +4,13 @@
//@ incremental
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0
#![crate_type="rlib"]
#![crate_type = "rlib"]
//@ aux-build:shared_generics_aux.rs
extern crate shared_generics_aux;
//~ MONO_ITEM fn foo
pub fn foo() {
//~ MONO_ITEM fn shared_generics_aux::generic_fn::<u16> @@ shared_generics_aux-in-shared_generics.volatile[External]
let _ = shared_generics_aux::generic_fn(0u16, 1u16);

View File

@ -2,7 +2,7 @@
//@ incremental
//@ compile-flags:-Zprint-mono-items=lazy
#![crate_type="rlib"]
#![crate_type = "rlib"]
//~ MONO_ITEM static FOO @@ statics[Internal]
static FOO: u32 = 0;

View File

@ -28,20 +28,24 @@ mod mod1 {
}
impl<T> Trait1Gen<T> for NeedsDrop {
fn do_something(&self, x: T) -> T { x }
fn do_something_else(&self, x: T) -> T { x }
fn do_something(&self, x: T) -> T {
x
}
fn do_something_else(&self, x: T) -> T {
x
}
}
//~ MONO_ITEM fn mod1::id::<i64> @@ vtable_through_const-mod1.volatile[Internal]
fn id<T>(x: T) -> T { x }
fn id<T>(x: T) -> T {
x
}
// These are referenced, so they produce mono-items (see start())
pub const TRAIT1_REF: &'static Trait1 = &NeedsDrop as &Trait1;
pub const TRAIT1_GEN_REF: &'static Trait1Gen<u8> = &NeedsDrop as &Trait1Gen<u8>;
pub const ID_CHAR: fn(char) -> char = id::<char>;
pub trait Trait2 {
fn do_something(&self) {}
fn do_something_else(&self) {}
@ -57,8 +61,12 @@ mod mod1 {
}
impl<T> Trait2Gen<T> for NeedsDrop {
fn do_something(&self, x: T) -> T { x }
fn do_something_else(&self, x: T) -> T { x }
fn do_something(&self, x: T) -> T {
x
}
fn do_something_else(&self, x: T) -> T {
x
}
}
// These are not referenced, so they do not produce mono-items

View File

@ -9,54 +9,51 @@ mod functions {
// Function doesn't have any type parameters to be unused.
pub fn no_parameters() {}
//~ MONO_ITEM fn functions::no_parameters
//~ MONO_ITEM fn functions::no_parameters
// Function has an unused type parameter.
pub fn unused<T>() {
}
pub fn unused<T>() {}
//~ MONO_ITEM fn functions::unused::<T>
//~ MONO_ITEM fn functions::unused::<T>
// Function uses type parameter in value of a binding.
pub fn used_binding_value<T: Default>() {
let _: T = Default::default();
}
//~ MONO_ITEM fn functions::used_binding_value::<u32>
//~ MONO_ITEM fn functions::used_binding_value::<u64>
//~ MONO_ITEM fn functions::used_binding_value::<u32>
//~ MONO_ITEM fn functions::used_binding_value::<u64>
// Function uses type parameter in type of a binding.
pub fn used_binding_type<T>() {
let _: Option<T> = None;
}
//~ MONO_ITEM fn functions::used_binding_type::<u32>
//~ MONO_ITEM fn functions::used_binding_type::<u64>
//~ MONO_ITEM fn functions::used_binding_type::<u32>
//~ MONO_ITEM fn functions::used_binding_type::<u64>
// Function uses type parameter in argument.
pub fn used_argument<T>(_: T) {
}
pub fn used_argument<T>(_: T) {}
//~ MONO_ITEM fn functions::used_argument::<u32>
//~ MONO_ITEM fn functions::used_argument::<u64>
//
//~ MONO_ITEM fn functions::used_argument::<u32>
//~ MONO_ITEM fn functions::used_argument::<u64>
//
// Function uses type parameter in substitutions to another function.
pub fn used_substs<T>() {
unused::<T>()
}
//~ MONO_ITEM fn functions::used_substs::<u32>
//~ MONO_ITEM fn functions::used_substs::<u64>
//~ MONO_ITEM fn functions::used_substs::<u32>
//~ MONO_ITEM fn functions::used_substs::<u64>
}
mod closures {
// Function doesn't have any type parameters to be unused.
pub fn no_parameters() {
let _ = || {};
}
//~ MONO_ITEM fn closures::no_parameters
//~ MONO_ITEM fn closures::no_parameters
// Function has an unused type parameter in parent and closure.
pub fn unused<T>() -> u32 {
@ -64,8 +61,8 @@ mod closures {
add_one(3)
}
//~ MONO_ITEM fn closures::unused::<T>::{closure#0}
//~ MONO_ITEM fn closures::unused::<T>
//~ MONO_ITEM fn closures::unused::<T>::{closure#0}
//~ MONO_ITEM fn closures::unused::<T>
// Function has an unused type parameter in closure, but not in parent.
pub fn used_parent<T: Default>() -> u32 {
@ -74,9 +71,9 @@ mod closures {
add_one(3)
}
//~ MONO_ITEM fn closures::used_parent::<T>::{closure#0}
//~ MONO_ITEM fn closures::used_parent::<u32>
//~ MONO_ITEM fn closures::used_parent::<u64>
//~ MONO_ITEM fn closures::used_parent::<T>::{closure#0}
//~ MONO_ITEM fn closures::used_parent::<u32>
//~ MONO_ITEM fn closures::used_parent::<u64>
// Function uses type parameter in value of a binding in closure.
pub fn used_binding_value<T: Default>() -> T {
@ -88,10 +85,10 @@ mod closures {
x()
}
//~ MONO_ITEM fn closures::used_binding_value::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_binding_value::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_binding_value::<u32>
//~ MONO_ITEM fn closures::used_binding_value::<u64>
//~ MONO_ITEM fn closures::used_binding_value::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_binding_value::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_binding_value::<u32>
//~ MONO_ITEM fn closures::used_binding_value::<u64>
// Function uses type parameter in type of a binding in closure.
pub fn used_binding_type<T>() -> Option<T> {
@ -103,10 +100,10 @@ mod closures {
x()
}
//~ MONO_ITEM fn closures::used_binding_type::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_binding_type::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_binding_type::<u32>
//~ MONO_ITEM fn closures::used_binding_type::<u64>
//~ MONO_ITEM fn closures::used_binding_type::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_binding_type::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_binding_type::<u32>
//~ MONO_ITEM fn closures::used_binding_type::<u64>
// Function and closure uses type parameter in argument.
pub fn used_argument<T>(t: T) -> u32 {
@ -114,10 +111,10 @@ mod closures {
x(t)
}
//~ MONO_ITEM fn closures::used_argument::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_argument::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_argument::<u32>
//~ MONO_ITEM fn closures::used_argument::<u64>
//~ MONO_ITEM fn closures::used_argument::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_argument::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_argument::<u32>
//~ MONO_ITEM fn closures::used_argument::<u64>
// Closure uses type parameter in argument.
pub fn used_argument_closure<T: Default>() -> u32 {
@ -126,10 +123,10 @@ mod closures {
x(t)
}
//~ MONO_ITEM fn closures::used_argument_closure::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_argument_closure::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_argument_closure::<u32>
//~ MONO_ITEM fn closures::used_argument_closure::<u64>
//~ MONO_ITEM fn closures::used_argument_closure::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_argument_closure::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_argument_closure::<u32>
//~ MONO_ITEM fn closures::used_argument_closure::<u64>
// Closure uses type parameter as upvar.
pub fn used_upvar<T: Default>() -> T {
@ -138,10 +135,10 @@ mod closures {
y()
}
//~ MONO_ITEM fn closures::used_upvar::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_upvar::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_upvar::<u32>
//~ MONO_ITEM fn closures::used_upvar::<u64>
//~ MONO_ITEM fn closures::used_upvar::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_upvar::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_upvar::<u32>
//~ MONO_ITEM fn closures::used_upvar::<u64>
// Closure uses type parameter in substitutions to another function.
pub fn used_substs<T>() {
@ -149,10 +146,10 @@ mod closures {
x()
}
//~ MONO_ITEM fn closures::used_substs::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_substs::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_substs::<u32>
//~ MONO_ITEM fn closures::used_substs::<u64>
//~ MONO_ITEM fn closures::used_substs::<u32>::{closure#0}
//~ MONO_ITEM fn closures::used_substs::<u64>::{closure#0}
//~ MONO_ITEM fn closures::used_substs::<u32>
//~ MONO_ITEM fn closures::used_substs::<u64>
}
mod methods {
@ -160,32 +157,30 @@ mod methods {
impl<F: Default> Foo<F> {
// Function has an unused type parameter from impl.
pub fn unused_impl() {
}
pub fn unused_impl() {}
//~ MONO_ITEM fn methods::Foo::<F>::unused_impl
//~ MONO_ITEM fn methods::Foo::<F>::unused_impl
// Function has an unused type parameter from impl and fn.
pub fn unused_both<G: Default>() {
}
pub fn unused_both<G: Default>() {}
//~ MONO_ITEM fn methods::Foo::<F>::unused_both::<G>
//~ MONO_ITEM fn methods::Foo::<F>::unused_both::<G>
// Function uses type parameter from impl.
pub fn used_impl() {
let _: F = Default::default();
}
//~ MONO_ITEM fn methods::Foo::<u32>::used_impl
//~ MONO_ITEM fn methods::Foo::<u64>::used_impl
//~ MONO_ITEM fn methods::Foo::<u32>::used_impl
//~ MONO_ITEM fn methods::Foo::<u64>::used_impl
// Function uses type parameter from impl.
pub fn used_fn<G: Default>() {
let _: G = Default::default();
}
//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u32>
//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u64>
//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u32>
//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u64>
// Function uses type parameter from impl.
pub fn used_both<G: Default>() {
@ -193,16 +188,16 @@ mod methods {
let _: G = Default::default();
}
//~ MONO_ITEM fn methods::Foo::<u32>::used_both::<u32>
//~ MONO_ITEM fn methods::Foo::<u64>::used_both::<u64>
//~ MONO_ITEM fn methods::Foo::<u32>::used_both::<u32>
//~ MONO_ITEM fn methods::Foo::<u64>::used_both::<u64>
// Function uses type parameter in substitutions to another function.
pub fn used_substs() {
super::functions::unused::<F>()
}
//~ MONO_ITEM fn methods::Foo::<u32>::used_substs
//~ MONO_ITEM fn methods::Foo::<u64>::used_substs
//~ MONO_ITEM fn methods::Foo::<u32>::used_substs
//~ MONO_ITEM fn methods::Foo::<u64>::used_substs
// Function has an unused type parameter from impl and fn.
pub fn closure_unused_all<G: Default>() -> u32 {
@ -210,8 +205,8 @@ mod methods {
add_one(3)
}
//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>
//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>
// Function uses type parameter from impl and fn in closure.
pub fn closure_used_both<G: Default>() -> u32 {
@ -224,10 +219,10 @@ mod methods {
add_one(3)
}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>
// Function uses type parameter from fn in closure.
pub fn closure_used_fn<G: Default>() -> u32 {
@ -239,10 +234,10 @@ mod methods {
add_one(3)
}
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>
// Function uses type parameter from impl in closure.
pub fn closure_used_impl<G: Default>() -> u32 {
@ -254,10 +249,10 @@ mod methods {
add_one(3)
}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>
// Closure uses type parameter in substitutions to another function.
pub fn closure_used_substs() {
@ -265,15 +260,13 @@ mod methods {
x()
}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs::{closure#0}
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs
}
}
fn dispatch<T: Default>() {
functions::no_parameters();
functions::unused::<T>();

View File

@ -12,14 +12,12 @@
#![crate_type = "lib"]
#![no_core]
#[lang="sized"]
trait Sized { }
#[lang="freeze"]
trait Freeze { }
#[lang="copy"]
trait Copy { }
#[lang = "sized"]
trait Sized {}
#[lang = "freeze"]
trait Freeze {}
#[lang = "copy"]
trait Copy {}
// Passed as `[i64 x 2]`, since it's an aggregate with size <= 128 bits, align < 128 bits.
#[repr(C)]
@ -31,7 +29,7 @@ pub struct Align8 {
// repr(transparent), so same as above.
#[repr(transparent)]
pub struct Transparent8 {
a: Align8
a: Align8,
}
// Passed as `[i64 x 2]`, since it's an aggregate with size <= 128 bits, align < 128 bits.
@ -47,8 +45,6 @@ extern "C" {
fn test_8(a: Align8, b: Transparent8, c: Wrapped8);
}
// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits.
// EXCEPT on Linux, where there's a special case to use its unadjusted alignment,
// making it the same as `Align8`, so it's be passed as `[i64 x 2]`.
@ -62,7 +58,7 @@ pub struct Align16 {
// repr(transparent), so same as above.
#[repr(transparent)]
pub struct Transparent16 {
a: Align16
a: Align16,
}
// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits.
@ -79,8 +75,6 @@ extern "C" {
fn test_16(a: Align16, b: Transparent16, c: Wrapped16);
}
// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits.
#[repr(C)]
pub struct I128 {
@ -90,13 +84,13 @@ pub struct I128 {
// repr(transparent), so same as above.
#[repr(transparent)]
pub struct TransparentI128 {
a: I128
a: I128,
}
// Passed as `i128`, since it's an aggregate with size <= 128 bits, align = 128 bits.
#[repr(C)]
pub struct WrappedI128 {
pub a: I128
pub a: I128,
}
extern "C" {
@ -106,8 +100,6 @@ extern "C" {
fn test_i128(a: I128, b: TransparentI128, c: WrappedI128);
}
// Passed as `[2 x i64]`, since it's an aggregate with size <= 128 bits, align < 128 bits.
// Note that the Linux special case does not apply, because packing is not considered "adjustment".
#[repr(C)]
@ -119,13 +111,13 @@ pub struct Packed {
// repr(transparent), so same as above.
#[repr(transparent)]
pub struct TransparentPacked {
a: Packed
a: Packed,
}
// Passed as `[2 x i64]`, since it's an aggregate with size <= 128 bits, align < 128 bits.
#[repr(C)]
pub struct WrappedPacked {
pub a: Packed
pub a: Packed,
}
extern "C" {
@ -135,13 +127,19 @@ extern "C" {
fn test_packed(a: Packed, b: TransparentPacked, c: WrappedPacked);
}
pub unsafe fn main(
a1: Align8, a2: Transparent8, a3: Wrapped8,
b1: Align16, b2: Transparent16, b3: Wrapped16,
c1: I128, c2: TransparentI128, c3: WrappedI128,
d1: Packed, d2: TransparentPacked, d3: WrappedPacked,
a1: Align8,
a2: Transparent8,
a3: Wrapped8,
b1: Align16,
b2: Transparent16,
b3: Wrapped16,
c1: I128,
c2: TransparentI128,
c3: WrappedI128,
d1: Packed,
d2: TransparentPacked,
d3: WrappedPacked,
) {
test_8(a1, a2, a3);
test_16(b1, b2, b3);

View File

@ -17,12 +17,12 @@
#![feature(no_core, lang_items)]
#![no_core]
#[lang="sized"]
trait Sized { }
#[lang="freeze"]
trait Freeze { }
#[lang="copy"]
trait Copy { }
#[lang = "sized"]
trait Sized {}
#[lang = "freeze"]
trait Freeze {}
#[lang = "copy"]
trait Copy {}
//x86_64: define win64cc void @has_efiapi
//i686: define void @has_efiapi

View File

@ -6,8 +6,6 @@
//@[avr] only-avr
//@[msp] only-msp430
fn main() {
}
fn main() {}
// CHECK: define i16 @main(i16, i8**)

View File

@ -6,7 +6,6 @@
//@ ignore-avr
//@ ignore-wasi wasi codegens the main symbol differently
fn main() {
}
fn main() {}
// CHECK: define{{( hidden| noundef)*}} i32 @main(i32{{( %0)?}}, ptr{{( %1)?}})

View File

@ -24,14 +24,17 @@
#![no_std]
#![no_core]
#[lang="sized"] trait Sized { }
#[lang="freeze"] trait Freeze { }
#[lang="copy"] trait Copy { }
#[lang = "sized"]
trait Sized {}
#[lang = "freeze"]
trait Freeze {}
#[lang = "copy"]
trait Copy {}
#[repr(i8)]
pub enum Type {
Type1 = 0,
Type2 = 1
Type2 = 1,
}
// To accommodate rust#97800, one might consider writing the below as:
@ -50,7 +53,6 @@ pub enum Type {
// riscv-SAME: signext
// CHECK-SAME: i8 @test()
#[no_mangle]
pub extern "C" fn test() -> Type {
Type::Type1

View File

@ -5,25 +5,25 @@
#![crate_type = "lib"]
pub struct S24 {
a: i8,
b: i8,
c: i8,
a: i8,
b: i8,
c: i8,
}
pub struct S48 {
a: i16,
b: i16,
c: i8,
a: i16,
b: i16,
c: i8,
}
// CHECK: i24 @struct_24_bits(i24
#[no_mangle]
pub extern "sysv64" fn struct_24_bits(a: S24) -> S24 {
a
a
}
// CHECK: i48 @struct_48_bits(i48
#[no_mangle]
pub extern "sysv64" fn struct_48_bits(a: S48) -> S48 {
a
a
}

View File

@ -5,17 +5,16 @@
// Hack to get the correct size for the length part in slices
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
#[no_mangle]
pub fn helper(_: usize) {
}
pub fn helper(_: usize) {}
// CHECK-LABEL: @no_op_slice_adjustment
#[no_mangle]
pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
// We used to generate an extra alloca and memcpy for the block's trailing expression value, so
// check that we copy directly to the return value slot
// CHECK: %0 = insertvalue { ptr, [[USIZE]] } poison, ptr %x.0, 0
// CHECK: %1 = insertvalue { ptr, [[USIZE]] } %0, [[USIZE]] %x.1, 1
// CHECK: ret { ptr, [[USIZE]] } %1
// CHECK: %0 = insertvalue { ptr, [[USIZE]] } poison, ptr %x.0, 0
// CHECK: %1 = insertvalue { ptr, [[USIZE]] } %0, [[USIZE]] %x.1, 1
// CHECK: ret { ptr, [[USIZE]] } %1
{ x }
}
@ -24,6 +23,6 @@ pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
pub fn no_op_slice_adjustment2(x: &[u8]) -> &[u8] {
// We used to generate an extra alloca and memcpy for the function's return value, so check
// that there's no memcpy (the slice is written to sret_slot element-wise)
// CHECK-NOT: call void @llvm.memcpy.
// CHECK-NOT: call void @llvm.memcpy.
no_op_slice_adjustment(x)
}

View File

@ -23,9 +23,12 @@
#![no_std]
#![no_core]
#[lang="sized"] trait Sized { }
#[lang="freeze"] trait Freeze { }
#[lang="copy"] trait Copy { }
#[lang = "sized"]
trait Sized {}
#[lang = "freeze"]
trait Freeze {}
#[lang = "copy"]
trait Copy {}
impl Copy for i32 {}
impl Copy for i64 {}
@ -58,7 +61,7 @@ pub struct ForceAlign4 {
pub struct NaturalAlign8 {
a: i64,
b: i64,
c: i64
c: i64,
}
// On i686-windows, this is passed by reference (because alignment is >4 and requested/forced),
@ -68,7 +71,7 @@ pub struct NaturalAlign8 {
pub struct ForceAlign8 {
a: i64,
b: i64,
c: i64
c: i64,
}
// On i686-windows, this is passed on stack, because requested alignment is <=4.
@ -77,28 +80,28 @@ pub struct ForceAlign8 {
pub struct LowerFA8 {
a: i64,
b: i64,
c: i64
c: i64,
}
// On i686-windows, this is passed by reference, because it contains a field with
// requested/forced alignment.
#[repr(C)]
pub struct WrappedFA8 {
a: ForceAlign8
a: ForceAlign8,
}
// On i686-windows, this has the same ABI as ForceAlign8, i.e. passed by reference.
#[repr(transparent)]
pub struct TransparentFA8 {
_0: (),
a: ForceAlign8
a: ForceAlign8,
}
#[repr(C)]
#[repr(align(16))]
pub struct ForceAlign16 {
a: [i32; 16],
b: i8
b: i8,
}
// CHECK-LABEL: @call_na1

View File

@ -18,8 +18,8 @@ pub struct Nested64 {
// CHECK-LABEL: @align64
#[no_mangle]
pub fn align64(a: u32) -> Align64 {
// CHECK: %a64 = alloca [64 x i8], align 64
// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
// CHECK: %a64 = alloca [64 x i8], align 64
// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
let a64 = Align64::A(a);
a64
}
@ -27,7 +27,7 @@ pub fn align64(a: u32) -> Align64 {
// CHECK-LABEL: @nested64
#[no_mangle]
pub fn nested64(a: u8, b: u32, c: u16) -> Nested64 {
// CHECK: %n64 = alloca [128 x i8], align 64
// CHECK: %n64 = alloca [128 x i8], align 64
let n64 = Nested64 { a, b: Align64::B(b), c };
n64
}

View File

@ -53,7 +53,6 @@ pub fn align_offset_word_slice(slice: &[Align4]) -> usize {
slice.as_ptr().align_offset(32)
}
// CHECK-LABEL: @align_offset_word_ptr(ptr{{.+}}%ptr
#[no_mangle]
pub fn align_offset_word_ptr(ptr: *const Align4) -> usize {

View File

@ -25,9 +25,9 @@ pub enum Enum64 {
// CHECK-LABEL: @align64
#[no_mangle]
pub fn align64(i : i32) -> Align64 {
// CHECK: %a64 = alloca [64 x i8], align 64
// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
pub fn align64(i: i32) -> Align64 {
// CHECK: %a64 = alloca [64 x i8], align 64
// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false)
let a64 = Align64(i);
a64
}
@ -37,14 +37,14 @@ pub fn align64(i : i32) -> Align64 {
// CHECK-LABEL: @align64_load
#[no_mangle]
pub fn align64_load(a: Align64) -> i32 {
// CHECK: {{%.*}} = load i32, ptr {{%.*}}, align 64
// CHECK: {{%.*}} = load i32, ptr {{%.*}}, align 64
a.0
}
// CHECK-LABEL: @nested64
#[no_mangle]
pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 {
// CHECK: %n64 = alloca [128 x i8], align 64
// CHECK: %n64 = alloca [128 x i8], align 64
let n64 = Nested64 { a, b, c, d };
n64
}
@ -52,7 +52,7 @@ pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 {
// CHECK-LABEL: @enum4
#[no_mangle]
pub fn enum4(a: i32) -> Enum4 {
// CHECK: %e4 = alloca [8 x i8], align 4
// CHECK: %e4 = alloca [8 x i8], align 4
let e4 = Enum4::A(a);
e4
}
@ -60,7 +60,7 @@ pub fn enum4(a: i32) -> Enum4 {
// CHECK-LABEL: @enum64
#[no_mangle]
pub fn enum64(a: Align64) -> Enum64 {
// CHECK: %e64 = alloca [128 x i8], align 64
// CHECK: %e64 = alloca [128 x i8], align 64
let e64 = Enum64::A(a);
e64
}

View File

@ -10,9 +10,10 @@
#[no_mangle]
pub fn compare() -> bool {
let bytes = 12.5f32.to_ne_bytes();
bytes == if cfg!(target_endian = "big") {
[0x41, 0x48, 0x00, 0x00]
} else {
[0x00, 0x00, 0x48, 0x41]
}
bytes
== if cfg!(target_endian = "big") {
[0x41, 0x48, 0x00, 0x00]
} else {
[0x00, 0x00, 0x48, 0x41]
}
}

View File

@ -4,8 +4,8 @@
#![crate_type = "rlib"]
#![allow(asm_sub_register)]
use std::mem::MaybeUninit;
use std::arch::asm;
use std::mem::MaybeUninit;
// CHECK-LABEL: @int
#[no_mangle]

View File

@ -21,14 +21,10 @@ trait Copy {}
pub unsafe fn we_escape_dollar_signs() {
// CHECK: call void asm sideeffect alignstack inteldialect "banana$$:"
asm!(
r"banana$:",
)
asm!(r"banana$:",)
}
pub unsafe fn we_escape_escapes_too() {
// CHECK: call void asm sideeffect alignstack inteldialect "banana\{{(\\|5C)}}36:"
asm!(
r"banana\36:",
)
asm!(r"banana\36:",)
}

View File

@ -6,13 +6,12 @@
//@ compile-flags: -O -Cno-prepopulate-passes
#![crate_type = "lib"]
#![feature(strict_provenance)]
#![feature(strict_provenance_atomic_ptr)]
use std::ptr::without_provenance_mut;
use std::sync::atomic::AtomicPtr;
use std::sync::atomic::Ordering::Relaxed;
use std::ptr::without_provenance_mut;
// Portability hack so that we can say [[USIZE]] instead of i64/i32/i16 for usize.
// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1)

View File

@ -5,25 +5,20 @@
// CHECK-LABEL: @auto_vectorize_direct
#[no_mangle]
pub fn auto_vectorize_direct(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
[
a[0] + b[0],
a[1] + b[1],
a[2] + b[2],
a[3] + b[3],
]
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
[a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]]
}
// CHECK-LABEL: @auto_vectorize_loop
#[no_mangle]
pub fn auto_vectorize_loop(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
let mut c = [0.0; 4];
for i in 0..4 {
c[i] = a[i] + b[i];
@ -34,9 +29,9 @@ pub fn auto_vectorize_loop(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
// CHECK-LABEL: @auto_vectorize_array_from_fn
#[no_mangle]
pub fn auto_vectorize_array_from_fn(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
std::array::from_fn(|i| a[i] + b[i])
}

View File

@ -5,7 +5,9 @@
#![crate_type = "lib"]
#[no_mangle]
pub fn extern_fn() -> u8 { unsafe { extern_static } }
pub fn extern_fn() -> u8 {
unsafe { extern_static }
}
#[no_mangle]
pub static mut extern_static: u8 = 71;

View File

@ -1,3 +1,2 @@
#[no_mangle]
pub fn bar() {
}
pub fn bar() {}

View File

@ -14,15 +14,18 @@
#![no_core]
#[lang = "sized"]
pub trait Sized { }
pub trait Sized {}
#[lang = "copy"]
pub trait Copy { }
pub trait Copy {}
#[lang = "receiver"]
pub trait Receiver { }
pub trait Receiver {}
#[lang = "tuple_trait"]
pub trait Tuple { }
pub trait Tuple {}
pub struct Result<T, E> { _a: T, _b: E }
pub struct Result<T, E> {
_a: T,
_b: E,
}
impl Copy for usize {}
impl Copy for &usize {}
@ -39,7 +42,7 @@ pub trait FnOnce<Args: Tuple> {
}
#[lang = "fn_mut"]
pub trait FnMut<Args: Tuple> : FnOnce<Args> {
pub trait FnMut<Args: Tuple>: FnOnce<Args> {
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
}
@ -64,7 +67,7 @@ fn arbitrary_black_box(ptr: &usize, _: &mut u32) -> Result<(), ()> {
#[inline(never)]
#[no_mangle]
fn call_through_fn_trait(a: &mut impl Fn<(), Output=()>) {
fn call_through_fn_trait(a: &mut impl Fn<(), Output = ()>) {
(*a)()
}
@ -110,7 +113,10 @@ pub unsafe fn transmute_fn_ptr_to_data(x: fn()) -> *const () {
transmute(x)
}
pub enum Either<T, U> { A(T), B(U) }
pub enum Either<T, U> {
A(T),
B(U),
}
// Previously, we would codegen this as passing/returning a scalar pair of `{ i8, ptr }`,
// with the `ptr` field representing both `&i32` and `fn()` depending on the variant.

View File

@ -11,11 +11,7 @@ pub fn binary_search_index_no_bounds_check(s: &[u8]) -> u8 {
// CHECK-NOT: slice_start_index_len_fail
// CHECK-NOT: slice_end_index_len_fail
// CHECK-NOT: panic_bounds_check
if let Ok(idx) = s.binary_search(&b'\\') {
s[idx]
} else {
42
}
if let Ok(idx) = s.binary_search(&b'\\') { s[idx] } else { 42 }
}
// Similarly, check that `partition_point` is known to return a valid fencepost.

View File

@ -10,9 +10,9 @@ use std::cmp::Ordering;
// CHECK-LABEL: @cmp_bool
#[no_mangle]
pub fn cmp_bool(a: bool, b: bool) -> Ordering {
// LLVM 10 produces (zext a) + (sext b), but the final lowering is (zext a) - (zext b).
// CHECK: zext i1
// CHECK: {{z|s}}ext i1
// CHECK: {{sub|add}} nsw
// LLVM 10 produces (zext a) + (sext b), but the final lowering is (zext a) - (zext b).
// CHECK: zext i1
// CHECK: {{z|s}}ext i1
// CHECK: {{sub|add}} nsw
a.cmp(&b)
}

View File

@ -12,12 +12,11 @@
#![feature(no_core, lang_items)]
#![no_core]
#[lang="sized"]
trait Sized { }
#[lang = "sized"]
trait Sized {}
// A basic test function.
pub fn test() {
}
pub fn test() {}
// BTI: !"branch-target-enforcement", i32 1
// BTI: !"sign-return-address", i32 0

View File

@ -18,9 +18,12 @@
#![no_std]
#![no_core]
#[lang="sized"] trait Sized { }
#[lang="freeze"] trait Freeze { }
#[lang="copy"] trait Copy { }
#[lang = "sized"]
trait Sized {}
#[lang = "freeze"]
trait Freeze {}
#[lang = "copy"]
trait Copy {}
// This struct will be passed as a single `i64` or `i32`.
// 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 {
// powerpc64: [[RETVAL:%.+]] = alloca [4 x i8], align 2
// powerpc64: call void @returns_twou16s(ptr {{.+}} [[RETVAL]])
// The other targets copy the cast ABI type to an alloca.
// aarch64: [[ABI_ALLOCA:%.+]] = alloca [8 x i8], align [[ABI_ALIGN:8]]
@ -151,7 +153,6 @@ pub unsafe fn return_fiveu16s() -> FiveU16s {
// powerpc64: call void @returns_fiveu16s(ptr {{.+}} [[RET_PTR]])
// The other targets copy the cast ABI type to the sret pointer.
// aarch64: [[ABI_ALLOCA:%.+]] = alloca [16 x i8], align [[ABI_ALIGN:8]]
@ -199,7 +200,6 @@ pub unsafe fn return_doubledouble() -> DoubleDouble {
// powerpc64: [[RETVAL:%.+]] = alloca [16 x i8], align 8
// powerpc64: call void @returns_doubledouble(ptr {{.+}} [[RETVAL]])
// The other targets copy the cast ABI type to an alloca.
// aarch64: [[ABI_ALLOCA:%.+]] = alloca [16 x i8], align [[ABI_ALIGN:8]]
@ -266,7 +266,6 @@ pub unsafe fn return_doublefloat() -> DoubleFloat {
// powerpc64: [[RETVAL:%.+]] = alloca [16 x i8], align 8
// powerpc64: call void @returns_doublefloat(ptr {{.+}} [[RETVAL]])
// The other targets copy the cast ABI type to an alloca.
// aarch64: [[ABI_ALLOCA:%.+]] = alloca [16 x i8], align [[ABI_ALIGN:8]]

View File

@ -13,12 +13,11 @@
#![feature(no_core, lang_items)]
#![no_core]
#[lang="sized"]
trait Sized { }
#[lang = "sized"]
trait Sized {}
// A basic test function.
pub fn test() {
}
pub fn test() {}
// undefined-NOT: !"cf-protection-branch"
// undefined-NOT: !"cf-protection-return"

View File

@ -2,12 +2,15 @@
#![crate_type = "lib"]
#![feature(ffi_const)]
pub fn bar() { unsafe { foo() } }
pub fn bar() {
unsafe { foo() }
}
extern "C" {
// CHECK-LABEL: declare{{.*}}void @foo()
// CHECK-SAME: [[ATTRS:#[0-9]+]]
// The attribute changed from `readnone` to `memory(none)` with LLVM 16.0.
// CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readnone|memory\(none\)}}{{.*}} }
#[ffi_const] pub fn foo();
#[ffi_const]
pub fn foo();
}

View File

@ -13,9 +13,12 @@
#![no_std]
#![no_core]
#[lang="sized"] trait Sized { }
#[lang="freeze"] trait Freeze { }
#[lang="copy"] trait Copy { }
#[lang = "sized"]
trait Sized {}
#[lang = "freeze"]
trait Freeze {}
#[lang = "copy"]
trait Copy {}
#[repr(C)]
struct S {

View File

@ -2,12 +2,15 @@
#![crate_type = "lib"]
#![feature(ffi_pure)]
pub fn bar() { unsafe { foo() } }
pub fn bar() {
unsafe { foo() }
}
extern "C" {
// CHECK-LABEL: declare{{.*}}void @foo()
// CHECK-SAME: [[ATTRS:#[0-9]+]]
// The attribute changed from `readonly` to `memory(read)` with LLVM 16.0.
// CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readonly|memory\(read\)}}{{.*}} }
#[ffi_pure] pub fn foo();
#[ffi_pure]
pub fn foo();
}

View File

@ -4,8 +4,7 @@
#![crate_type = "lib"]
// A basic test function.
pub fn test() {
}
pub fn test() {}
// Ensure the module flag cfguard=2 is present
// CHECK: !"cfguard", i32 2

View File

@ -4,8 +4,7 @@
#![crate_type = "lib"]
// A basic test function.
pub fn test() {
}
pub fn test() {}
// Ensure the module flag cfguard is not present
// CHECK-NOT: !"cfguard"

View File

@ -4,8 +4,7 @@
#![crate_type = "lib"]
// A basic test function.
pub fn test() {
}
pub fn test() {}
// Ensure the module flag cfguard=1 is present
// CHECK: !"cfguard", i32 1

View File

@ -4,8 +4,7 @@
#![crate_type = "lib"]
// A basic test function.
pub fn test() {
}
pub fn test() {}
// Ensure the cfguard module flag is not added for non-MSVC targets.
// CHECK-NOT: !"cfguard"

View File

@ -7,7 +7,7 @@ static X: i32 = 5;
// CHECK-LABEL: @raw_ptr_to_raw_ptr_noop
// CHECK-NOT: alloca
#[no_mangle]
pub fn raw_ptr_to_raw_ptr_noop() -> *const i32{
pub fn raw_ptr_to_raw_ptr_noop() -> *const i32 {
&X as *const i32
}

View File

@ -8,18 +8,10 @@
#[no_mangle]
pub fn if_bool() {
// CHECK: br label %{{.+}}
_ = if true {
0
} else {
1
};
_ = if true { 0 } else { 1 };
// CHECK: br label %{{.+}}
_ = if false {
0
} else {
1
};
_ = if false { 0 } else { 1 };
}
// CHECK-LABEL: @if_constant_int_eq
@ -27,18 +19,10 @@ pub fn if_bool() {
pub fn if_constant_int_eq() {
let val = 0;
// CHECK: br label %{{.+}}
_ = if val == 0 {
0
} else {
1
};
_ = if val == 0 { 0 } else { 1 };
// CHECK: br label %{{.+}}
_ = if val == 1 {
0
} else {
1
};
_ = if val == 1 { 0 } else { 1 };
}
// CHECK-LABEL: @if_constant_match
@ -48,19 +32,19 @@ pub fn if_constant_match() {
_ = match 1 {
1 => 2,
2 => 3,
_ => 4
_ => 4,
};
// CHECK: br label %{{.+}}
_ = match 1 {
2 => 3,
_ => 4
_ => 4,
};
// CHECK: br label %[[MINUS1:.+]]
_ = match -1 {
// CHECK: [[MINUS1]]:
// CHECK: store i32 1
// CHECK: [[MINUS1]]:
// CHECK: store i32 1
-1 => 1,
_ => 0,
}

View File

@ -11,7 +11,8 @@
use std::ops::Coroutine;
fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
#[coroutine] || {
#[coroutine]
|| {
yield 0;
let s = String::from("foo");
yield 1;
@ -23,23 +24,23 @@ fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<coroutine_debug_msvc::coroutine_test::coroutine_env$0>"
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant0", scope: [[GEN]],
// For brevity, we only check the struct name and members of the last variant.
// CHECK-SAME: file: [[FILE:![0-9]*]], line: 14,
// CHECK-SAME: file: [[FILE:![0-9]*]], line: 15,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant1", scope: [[GEN]],
// CHECK-SAME: file: [[FILE]], line: 18,
// CHECK-SAME: file: [[FILE]], line: 19,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant2", scope: [[GEN]],
// CHECK-SAME: file: [[FILE]], line: 18,
// CHECK-SAME: file: [[FILE]], line: 19,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant3", scope: [[GEN]],
// CHECK-SAME: file: [[FILE]], line: 15,
// CHECK-SAME: file: [[FILE]], line: 16,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant4", scope: [[GEN]],
// CHECK-SAME: file: [[FILE]], line: 17,
// CHECK-SAME: file: [[FILE]], line: 18,
// CHECK-SAME: baseType: [[VARIANT_WRAPPER:![0-9]*]]
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )

View File

@ -11,7 +11,8 @@
use std::ops::Coroutine;
fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
#[coroutine] || {
#[coroutine]
|| {
yield 0;
let s = String::from("foo");
yield 1;
@ -26,26 +27,26 @@ fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: discriminator: [[DISC:![0-9]*]]
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "0", scope: [[VARIANT]],
// CHECK-SAME: file: [[FILE:![0-9]*]], line: 14,
// CHECK-SAME: file: [[FILE:![0-9]*]], line: 15,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "Unresumed", scope: [[GEN]],
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "1", scope: [[VARIANT]],
// CHECK-SAME: file: [[FILE]], line: 18,
// CHECK-SAME: file: [[FILE]], line: 19,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "2", scope: [[VARIANT]],
// CHECK-SAME: file: [[FILE]], line: 18,
// CHECK-SAME: file: [[FILE]], line: 19,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "3", scope: [[VARIANT]],
// CHECK-SAME: file: [[FILE]], line: 15,
// CHECK-SAME: file: [[FILE]], line: 16,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "4", scope: [[VARIANT]],
// CHECK-SAME: file: [[FILE]], line: 17,
// CHECK-SAME: file: [[FILE]], line: 18,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: [[S1:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend1", scope: [[GEN]],

View File

@ -1,13 +1,17 @@
//@ compile-flags: -O
#![crate_type="lib"]
#![crate_type = "lib"]
struct A;
impl Drop for A {
fn drop(&mut self) {
extern "C" { fn foo(); }
unsafe { foo(); }
extern "C" {
fn foo();
}
unsafe {
foo();
}
}
}

View File

@ -3,6 +3,7 @@
//@ ignore-windows
//@ compile-flags: -C debuginfo=2
#[rustfmt::skip]
fn main() {
unsafe {
// Column numbers are 1-based. Regression test for #65437.
@ -13,8 +14,8 @@ fn main() {
// CHECK: call void @turtle(){{( #[0-9]+)?}}, !dbg [[B:!.*]]
/* ż */ turtle();
// CHECK: [[A]] = !DILocation(line: 10, column: 9,
// CHECK: [[B]] = !DILocation(line: 14, column: 10,
// CHECK: [[A]] = !DILocation(line: 11, column: 9,
// CHECK: [[B]] = !DILocation(line: 15, column: 10,
}
}

View File

@ -3,7 +3,7 @@
//
// Ensure that we remap the compile unit directory and that we set it to the compilers current
// working directory and not something else.
#![crate_type="rlib"]
#![crate_type = "rlib"]
// CHECK-DAG: [[FILE:![0-9]*]] = !DIFile(filename: "/base/debug-compile-unit-path.rs{{.*}}", directory: "/cwd/")
// CHECK-DAG: {{![0-9]*}} = distinct !DICompileUnit({{.*}}file: [[FILE]]

View File

@ -46,7 +46,6 @@
// NONMSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "{closure_env#0}<debuginfo_generic_closure_env_names::Foo>", scope: ![[function_containing_closure_NAMESPACE]]
// MSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "closure_env$0<debuginfo_generic_closure_env_names::Foo>", scope: ![[function_containing_closure_NAMESPACE]]
#![crate_type = "lib"]
use std::future::Future;
@ -70,11 +69,9 @@ async fn generic_async_function<T: 'static>(x: T) -> T {
x
}
fn generic_async_block<T: 'static>(x: T) -> impl Future<Output=T> {
fn generic_async_block<T: 'static>(x: T) -> impl Future<Output = T> {
static _X: u8 = 0; // Same as above
async move {
x
}
async move { x }
}
pub fn instantiate_generics() {

View File

@ -1,13 +1,13 @@
//@ no-prefer-dynamic
#![crate_type = "rlib"]
#[link(name = "dummy", kind="dylib")]
#[link(name = "dummy", kind = "dylib")]
extern "C" {
pub fn dylib_func2(x: i32) -> i32;
pub static dylib_global2: i32;
}
#[link(name = "dummy", kind="static")]
#[link(name = "dummy", kind = "static")]
extern "C" {
pub fn static_func2(x: i32) -> i32;
pub static static_global2: i32;

View File

@ -1,4 +1,4 @@
// This test is for *-windows-msvc only.
// This test is for *-windows-msvc only.
//@ only-windows
//@ ignore-gnu
@ -20,13 +20,13 @@ extern crate wrapper;
// CHECK: declare noundef i32 @static_func1(i32 noundef)
// CHECK: declare noundef i32 @static_func2(i32 noundef)
#[link(name = "dummy", kind="dylib")]
#[link(name = "dummy", kind = "dylib")]
extern "C" {
pub fn dylib_func1(x: i32) -> i32;
pub static dylib_global1: i32;
}
#[link(name = "dummy", kind="static")]
#[link(name = "dummy", kind = "static")]
extern "C" {
pub fn static_func1(x: i32) -> i32;
pub static static_global1: i32;

View File

@ -3,7 +3,7 @@
// Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`.
// Note that non-Unpin types should not get `noalias`, matching &mut behavior.
#![crate_type="lib"]
#![crate_type = "lib"]
use std::marker::PhantomPinned;

View File

@ -7,28 +7,26 @@ struct SomeUniqueName;
impl Drop for SomeUniqueName {
#[inline(never)]
fn drop(&mut self) {
}
fn drop(&mut self) {}
}
#[inline(never)]
pub fn possibly_unwinding() {
}
pub fn possibly_unwinding() {}
// CHECK-LABEL: @droppy
#[no_mangle]
pub fn droppy() {
// Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
// that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
// regular function exit. We used to have problems with quadratic growths of drop calls in such
// functions.
// FIXME(eddyb) the `void @` forces a match on the instruction, instead of the
// comment, that's `; call core::ptr::drop_in_place::<drop::SomeUniqueName>`
// for the `v0` mangling, should switch to matching on that once `legacy` is gone.
// CHECK-COUNT-6: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
// CHECK-NOT: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
// The next line checks for the } that ends the function definition
// CHECK-LABEL: {{^[}]}}
// Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused,
// so that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for
// the regular function exit. We used to have problems with quadratic growths of drop calls in
// such functions.
// FIXME(eddyb) the `void @` forces a match on the instruction, instead of the
// comment, that's `; call core::ptr::drop_in_place::<drop::SomeUniqueName>`
// for the `v0` mangling, should switch to matching on that once `legacy` is gone.
// CHECK-COUNT-6: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
// CHECK-NOT: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
// The next line checks for the } that ends the function definition
// CHECK-LABEL: {{^[}]}}
let _s = SomeUniqueName;
possibly_unwinding();
let _s = SomeUniqueName;

View File

@ -3,7 +3,6 @@
//@ compile-flags: -C no-prepopulate-passes -Copt-level=0
#![crate_type = "lib"]
#![feature(extern_types)]
use std::ptr::addr_of;
@ -11,8 +10,7 @@ use std::ptr::addr_of;
// Hack to get the correct type for usize
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
#[no_mangle]
pub fn helper(_: usize) {
}
pub fn helper(_: usize) {}
struct Dst<T: ?Sized> {
x: u32,
@ -23,30 +21,31 @@ struct Dst<T: ?Sized> {
// CHECK: @dst_dyn_trait_offset(ptr align {{[0-9]+}} [[DATA_PTR:%.+]], ptr align {{[0-9]+}} [[VTABLE_PTR:%.+]])
#[no_mangle]
pub fn dst_dyn_trait_offset(s: &Dst<dyn Drop>) -> &dyn Drop {
// The alignment of dyn trait is unknown, so we compute the offset based on align from the vtable.
// The alignment of dyn trait is unknown, so we compute the offset based on align from the
// vtable.
// CHECK: [[SIZE_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]]
// CHECK: load [[USIZE]], ptr [[SIZE_PTR]]
// CHECK: [[ALIGN_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]]
// CHECK: load [[USIZE]], ptr [[ALIGN_PTR]]
// CHECK: [[SIZE_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]]
// CHECK: load [[USIZE]], ptr [[SIZE_PTR]]
// CHECK: [[ALIGN_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]]
// CHECK: load [[USIZE]], ptr [[ALIGN_PTR]]
// CHECK: getelementptr inbounds i8, ptr [[DATA_PTR]]
// CHECK-NEXT: insertvalue
// CHECK-NEXT: insertvalue
// CHECK-NEXT: ret
// CHECK: getelementptr inbounds i8, ptr [[DATA_PTR]]
// CHECK-NEXT: insertvalue
// CHECK-NEXT: insertvalue
// CHECK-NEXT: ret
&s.z
}
// CHECK-LABEL: @dst_slice_offset
#[no_mangle]
pub fn dst_slice_offset(s: &Dst<[u16]>) -> &[u16] {
// The alignment of [u16] is known, so we generate a GEP directly.
// The alignment of [u16] is known, so we generate a GEP directly.
// CHECK: start:
// CHECK-NEXT: getelementptr inbounds i8, {{.+}}, [[USIZE]] 6
// CHECK-NEXT: insertvalue
// CHECK-NEXT: insertvalue
// CHECK-NEXT: ret
// CHECK: start:
// CHECK-NEXT: getelementptr inbounds i8, {{.+}}, [[USIZE]] 6
// CHECK-NEXT: insertvalue
// CHECK-NEXT: insertvalue
// CHECK-NEXT: ret
&s.z
}
@ -60,25 +59,25 @@ struct PackedDstSlice {
// CHECK-LABEL: @packed_dst_slice_offset
#[no_mangle]
pub fn packed_dst_slice_offset(s: &PackedDstSlice) -> *const [u16] {
// The alignment of [u16] is known, so we generate a GEP directly.
// The alignment of [u16] is known, so we generate a GEP directly.
// CHECK: start:
// CHECK-NEXT: getelementptr inbounds i8, {{.+}}, [[USIZE]] 5
// CHECK-NEXT: insertvalue
// CHECK-NEXT: insertvalue
// CHECK-NEXT: ret
// CHECK: start:
// CHECK-NEXT: getelementptr inbounds i8, {{.+}}, [[USIZE]] 5
// CHECK-NEXT: insertvalue
// CHECK-NEXT: insertvalue
// CHECK-NEXT: ret
addr_of!(s.z)
}
extern {
extern "C" {
pub type Extern;
}
// CHECK-LABEL: @dst_extern
#[no_mangle]
pub fn dst_extern(s: &Dst<Extern>) -> &Extern {
// Computing the alignment of an extern type is currently unsupported and just panics.
// Computing the alignment of an extern type is currently unsupported and just panics.
// CHECK: call void @{{.+}}panic
// CHECK: call void @{{.+}}panic
&s.z
}

View File

@ -10,9 +10,15 @@ pub trait Trait {
fn f(&self);
}
pub struct WrapperWithAlign1<T: ?Sized> { x: u8, y: T }
pub struct WrapperWithAlign1<T: ?Sized> {
x: u8,
y: T,
}
pub struct WrapperWithAlign2<T: ?Sized> { x: u16, y: T }
pub struct WrapperWithAlign2<T: ?Sized> {
x: u16,
y: T,
}
pub struct Struct<W: ?Sized> {
_field: i8,
@ -22,7 +28,7 @@ pub struct Struct<W: ?Sized> {
// CHECK-LABEL: @eliminates_runtime_check_when_align_1
#[no_mangle]
pub fn eliminates_runtime_check_when_align_1(
x: &Struct<WrapperWithAlign1<dyn Trait>>
x: &Struct<WrapperWithAlign1<dyn Trait>>,
) -> &WrapperWithAlign1<dyn Trait> {
// CHECK: load [[USIZE:i[0-9]+]], {{.+}} !range [[RANGE_META:![0-9]+]]
// CHECK-NOT: llvm.umax
@ -35,7 +41,7 @@ pub fn eliminates_runtime_check_when_align_1(
// CHECK-LABEL: @does_not_eliminate_runtime_check_when_align_2
#[no_mangle]
pub fn does_not_eliminate_runtime_check_when_align_2(
x: &Struct<WrapperWithAlign2<dyn Trait>>
x: &Struct<WrapperWithAlign2<dyn Trait>>,
) -> &WrapperWithAlign2<dyn Trait> {
// CHECK: [[X0:%[0-9]+]] = load [[USIZE]], {{.+}} !range [[RANGE_META]]
// CHECK: {{icmp|llvm.umax}}

View File

@ -3,8 +3,7 @@
#![crate_type = "lib"]
// A basic test function.
pub fn test() {
}
pub fn test() {}
// Ensure the module flag ehcontguard is not present
// CHECK-NOT: !"ehcontguard"

View File

@ -3,8 +3,7 @@
#![crate_type = "lib"]
// A basic test function.
pub fn test() {
}
pub fn test() {}
// Ensure the module flag ehcontguard=1 is present
// CHECK: !"ehcontguard", i32 1

View File

@ -9,18 +9,23 @@
#![no_std]
#![no_core]
#[lang="sized"] trait Sized { }
#[lang="freeze"] trait Freeze { }
#[lang="copy"] trait Copy { }
#[lang = "sized"]
trait Sized {}
#[lang = "freeze"]
trait Freeze {}
#[lang = "copy"]
trait Copy {}
#[rustc_intrinsic]
fn size_of<T>() -> usize { loop {} }
fn size_of<T>() -> usize {
loop {}
}
extern "rust-intrinsic" {
fn catch_unwind(
try_fn: fn(_: *mut u8),
data: *mut u8,
catch_fn: fn(_: *mut u8, _: *mut u8)
catch_fn: fn(_: *mut u8, _: *mut u8),
) -> i32;
}
@ -36,7 +41,7 @@ pub fn ptr_size() -> usize {
pub unsafe fn test_catch_unwind(
try_fn: fn(_: *mut u8),
data: *mut u8,
catch_fn: fn(_: *mut u8, _: *mut u8)
catch_fn: fn(_: *mut u8, _: *mut u8),
) -> i32 {
// CHECK: start:
// CHECK: [[ALLOCA:%.*]] = alloca

View File

@ -2,9 +2,8 @@
//
//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsplit-lto-unit
#![crate_type="lib"]
#![crate_type = "lib"]
pub fn foo() {
}
pub fn foo() {}
// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1}

View File

@ -3,7 +3,8 @@
#![crate_type = "lib"]
pub enum Foo {
A, B
A,
B,
}
// CHECK-LABEL: @lookup
@ -15,7 +16,7 @@ pub fn lookup(buf: &[u8; 2], f: Foo) -> u8 {
pub enum Bar {
A = 2,
B = 3
B = 3,
}
// CHECK-LABEL: @lookup_unmodified

View File

@ -17,7 +17,11 @@
#![allow(unused_variables)]
#![allow(unused_assignments)]
enum E { A, B, C }
enum E {
A,
B,
C,
}
pub fn main() {
let e = E::C;

View File

@ -23,7 +23,12 @@
#![allow(unused_variables)]
#![allow(unused_assignments)]
enum E { A, B, C, D(bool) }
enum E {
A,
B,
C,
D(bool),
}
pub fn main() {
let e = E::D(true);

View File

@ -21,7 +21,10 @@
#![allow(unused_variables)]
#![allow(unused_assignments)]
enum E { A(u32), B(u32) }
enum E {
A(u32),
B(u32),
}
pub fn main() {
let e = E::A(23);

View File

@ -50,6 +50,7 @@ pub fn match1(e: Enum1) -> u8 {
}
// Case 2: Special cases don't apply.
#[rustfmt::skip]
pub enum X {
_2=2, _3, _4, _5, _6, _7, _8, _9, _10, _11,
_12, _13, _14, _15, _16, _17, _18, _19, _20,

Some files were not shown because too many files have changed in this diff Show More