diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/codegen/atomic-operations-llvm-12.rs | 84 | ||||
| -rw-r--r-- | src/test/codegen/atomic-operations.rs | 26 | ||||
| -rw-r--r-- | src/test/codegen/vec-calloc.rs | 136 | ||||
| -rw-r--r-- | src/test/ui/derives/deriving-with-repr-packed.rs | 38 | ||||
| -rw-r--r-- | src/test/ui/derives/deriving-with-repr-packed.stderr | 68 | ||||
| -rw-r--r-- | src/test/ui/process/nofile-limit.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/super-traits-fail-2.stderr | 24 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr | 24 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/super-traits.rs | 22 |
11 files changed, 394 insertions, 60 deletions
diff --git a/src/test/codegen/atomic-operations-llvm-12.rs b/src/test/codegen/atomic-operations-llvm-12.rs new file mode 100644 index 00000000000..bd4c63dcff1 --- /dev/null +++ b/src/test/codegen/atomic-operations-llvm-12.rs @@ -0,0 +1,84 @@ +// Code generation of atomic operations for LLVM 12 +// ignore-llvm-version: 13 - 99 +// compile-flags: -O +#![crate_type = "lib"] + +use std::sync::atomic::{AtomicI32, Ordering::*}; + +// CHECK-LABEL: @compare_exchange +#[no_mangle] +pub fn compare_exchange(a: &AtomicI32) { + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 10 monotonic monotonic + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 11 acquire acquire + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 12 seq_cst seq_cst + let _ = a.compare_exchange(0, 10, Relaxed, Relaxed); + let _ = a.compare_exchange(0, 11, Relaxed, Acquire); + let _ = a.compare_exchange(0, 12, Relaxed, SeqCst); + + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 20 release monotonic + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 21 acq_rel acquire + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 22 seq_cst seq_cst + let _ = a.compare_exchange(0, 20, Release, Relaxed); + let _ = a.compare_exchange(0, 21, Release, Acquire); + let _ = a.compare_exchange(0, 22, Release, SeqCst); + + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 30 acquire monotonic + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 31 acquire acquire + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 32 seq_cst seq_cst + let _ = a.compare_exchange(0, 30, Acquire, Relaxed); + let _ = a.compare_exchange(0, 31, Acquire, Acquire); + let _ = a.compare_exchange(0, 32, Acquire, SeqCst); + + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 40 acq_rel monotonic + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 41 acq_rel acquire + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 42 seq_cst seq_cst + let _ = a.compare_exchange(0, 40, AcqRel, Relaxed); + let _ = a.compare_exchange(0, 41, AcqRel, Acquire); + let _ = a.compare_exchange(0, 42, AcqRel, SeqCst); + + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 50 seq_cst monotonic + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 51 seq_cst acquire + // CHECK: cmpxchg i32* %{{.*}}, i32 0, i32 52 seq_cst seq_cst + let _ = a.compare_exchange(0, 50, SeqCst, Relaxed); + let _ = a.compare_exchange(0, 51, SeqCst, Acquire); + let _ = a.compare_exchange(0, 52, SeqCst, SeqCst); +} + +// CHECK-LABEL: @compare_exchange_weak +#[no_mangle] +pub fn compare_exchange_weak(w: &AtomicI32) { + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 10 monotonic monotonic + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 11 acquire acquire + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 12 seq_cst seq_cst + let _ = w.compare_exchange_weak(1, 10, Relaxed, Relaxed); + let _ = w.compare_exchange_weak(1, 11, Relaxed, Acquire); + let _ = w.compare_exchange_weak(1, 12, Relaxed, SeqCst); + + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 20 release monotonic + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 21 acq_rel acquire + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 22 seq_cst seq_cst + let _ = w.compare_exchange_weak(1, 20, Release, Relaxed); + let _ = w.compare_exchange_weak(1, 21, Release, Acquire); + let _ = w.compare_exchange_weak(1, 22, Release, SeqCst); + + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 30 acquire monotonic + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 31 acquire acquire + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 32 seq_cst seq_cst + let _ = w.compare_exchange_weak(1, 30, Acquire, Relaxed); + let _ = w.compare_exchange_weak(1, 31, Acquire, Acquire); + let _ = w.compare_exchange_weak(1, 32, Acquire, SeqCst); + + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 40 acq_rel monotonic + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 41 acq_rel acquire + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 42 seq_cst seq_cst + let _ = w.compare_exchange_weak(1, 40, AcqRel, Relaxed); + let _ = w.compare_exchange_weak(1, 41, AcqRel, Acquire); + let _ = w.compare_exchange_weak(1, 42, AcqRel, SeqCst); + + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 50 seq_cst monotonic + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 51 seq_cst acquire + // CHECK: cmpxchg weak i32* %{{.*}}, i32 1, i32 52 seq_cst seq_cst + let _ = w.compare_exchange_weak(1, 50, SeqCst, Relaxed); + let _ = w.compare_exchange_weak(1, 51, SeqCst, Acquire); + let _ = w.compare_exchange_weak(1, 52, SeqCst, SeqCst); +} diff --git a/src/test/codegen/atomic-operations.rs b/src/test/codegen/atomic-operations.rs index a14f63726bb..771cf58725a 100644 --- a/src/test/codegen/atomic-operations.rs +++ b/src/test/codegen/atomic-operations.rs @@ -1,5 +1,5 @@ // Code generation of atomic operations. -// +// min-llvm-version: 13.0 // compile-flags: -O #![crate_type = "lib"] @@ -9,20 +9,32 @@ use std::sync::atomic::{AtomicI32, Ordering::*}; #[no_mangle] pub fn compare_exchange(a: &AtomicI32) { // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 10 monotonic monotonic + // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 11 monotonic acquire + // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 12 monotonic seq_cst let _ = a.compare_exchange(0, 10, Relaxed, Relaxed); + let _ = a.compare_exchange(0, 11, Relaxed, Acquire); + let _ = a.compare_exchange(0, 12, Relaxed, SeqCst); // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 20 release monotonic + // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 21 release acquire + // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 22 release seq_cst let _ = a.compare_exchange(0, 20, Release, Relaxed); + let _ = a.compare_exchange(0, 21, Release, Acquire); + let _ = a.compare_exchange(0, 22, Release, SeqCst); // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 30 acquire monotonic // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 31 acquire acquire + // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 32 acquire seq_cst let _ = a.compare_exchange(0, 30, Acquire, Relaxed); let _ = a.compare_exchange(0, 31, Acquire, Acquire); + let _ = a.compare_exchange(0, 32, Acquire, SeqCst); // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 40 acq_rel monotonic // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 41 acq_rel acquire + // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 42 acq_rel seq_cst let _ = a.compare_exchange(0, 40, AcqRel, Relaxed); let _ = a.compare_exchange(0, 41, AcqRel, Acquire); + let _ = a.compare_exchange(0, 42, AcqRel, SeqCst); // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 50 seq_cst monotonic // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 51 seq_cst acquire @@ -36,20 +48,32 @@ pub fn compare_exchange(a: &AtomicI32) { #[no_mangle] pub fn compare_exchange_weak(w: &AtomicI32) { // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 10 monotonic monotonic + // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 11 monotonic acquire + // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 12 monotonic seq_cst let _ = w.compare_exchange_weak(1, 10, Relaxed, Relaxed); + let _ = w.compare_exchange_weak(1, 11, Relaxed, Acquire); + let _ = w.compare_exchange_weak(1, 12, Relaxed, SeqCst); // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 20 release monotonic + // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 21 release acquire + // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 22 release seq_cst let _ = w.compare_exchange_weak(1, 20, Release, Relaxed); + let _ = w.compare_exchange_weak(1, 21, Release, Acquire); + let _ = w.compare_exchange_weak(1, 22, Release, SeqCst); // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 30 acquire monotonic // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 31 acquire acquire + // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 32 acquire seq_cst let _ = w.compare_exchange_weak(1, 30, Acquire, Relaxed); let _ = w.compare_exchange_weak(1, 31, Acquire, Acquire); + let _ = w.compare_exchange_weak(1, 32, Acquire, SeqCst); // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 40 acq_rel monotonic // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 41 acq_rel acquire + // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 42 acq_rel seq_cst let _ = w.compare_exchange_weak(1, 40, AcqRel, Relaxed); let _ = w.compare_exchange_weak(1, 41, AcqRel, Acquire); + let _ = w.compare_exchange_weak(1, 42, AcqRel, SeqCst); // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 50 seq_cst monotonic // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 51 seq_cst acquire diff --git a/src/test/codegen/vec-calloc.rs b/src/test/codegen/vec-calloc.rs index c616e9f1145..08302796c41 100644 --- a/src/test/codegen/vec-calloc.rs +++ b/src/test/codegen/vec-calloc.rs @@ -4,29 +4,141 @@ #![crate_type = "lib"] +// CHECK-LABEL: @vec_zero_bytes +#[no_mangle] +pub fn vec_zero_bytes(n: usize) -> Vec<u8> { + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + // CHECK-NOT: call {{.*}}llvm.memset + + // CHECK: call {{.*}}__rust_alloc_zeroed( + + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + // CHECK-NOT: call {{.*}}llvm.memset + + // CHECK: ret void + vec![0; n] +} + +// CHECK-LABEL: @vec_one_bytes +#[no_mangle] +pub fn vec_one_bytes(n: usize) -> Vec<u8> { + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( + + // CHECK: call {{.*}}__rust_alloc( + // CHECK: call {{.*}}llvm.memset + + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( + + // CHECK: ret void + vec![1; n] +} + // CHECK-LABEL: @vec_zero_scalar #[no_mangle] pub fn vec_zero_scalar(n: usize) -> Vec<i32> { - // CHECK-NOT: __rust_alloc( - // CHECK: __rust_alloc_zeroed( - // CHECK-NOT: __rust_alloc( + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + + // CHECK: call {{.*}}__rust_alloc_zeroed( + + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + + // CHECK: ret void vec![0; n] } +// CHECK-LABEL: @vec_one_scalar +#[no_mangle] +pub fn vec_one_scalar(n: usize) -> Vec<i32> { + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( + + // CHECK: call {{.*}}__rust_alloc( + + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( + + // CHECK: ret void + vec![1; n] +} + // CHECK-LABEL: @vec_zero_rgb48 #[no_mangle] pub fn vec_zero_rgb48(n: usize) -> Vec<[u16; 3]> { - // CHECK-NOT: __rust_alloc( - // CHECK: __rust_alloc_zeroed( - // CHECK-NOT: __rust_alloc( + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + + // CHECK: call {{.*}}__rust_alloc_zeroed( + + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + + // CHECK: ret void vec![[0, 0, 0]; n] } -// CHECK-LABEL: @vec_zero_array_32 +// CHECK-LABEL: @vec_zero_array_16 +#[no_mangle] +pub fn vec_zero_array_16(n: usize) -> Vec<[i64; 16]> { + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + + // CHECK: call {{.*}}__rust_alloc_zeroed( + + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + + // CHECK: ret void + vec![[0_i64; 16]; n] +} + +// CHECK-LABEL: @vec_zero_tuple +#[no_mangle] +pub fn vec_zero_tuple(n: usize) -> Vec<(i16, u8, char)> { + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + + // CHECK: call {{.*}}__rust_alloc_zeroed( + + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc( + + // CHECK: ret void + vec![(0, 0, '\0'); n] +} + +// CHECK-LABEL: @vec_non_zero_tuple #[no_mangle] -pub fn vec_zero_array_32(n: usize) -> Vec<[i64; 32]> { - // CHECK-NOT: __rust_alloc( - // CHECK: __rust_alloc_zeroed( - // CHECK-NOT: __rust_alloc( - vec![[0_i64; 32]; n] +pub fn vec_non_zero_tuple(n: usize) -> Vec<(i16, u8, char)> { + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( + + // CHECK: call {{.*}}__rust_alloc( + + // CHECK-NOT: call {{.*}}alloc::vec::from_elem + // CHECK-NOT: call {{.*}}reserve + // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( + + // CHECK: ret void + vec![(0, 0, 'A'); n] } diff --git a/src/test/ui/derives/deriving-with-repr-packed.rs b/src/test/ui/derives/deriving-with-repr-packed.rs index b78eeaa9055..3884e397764 100644 --- a/src/test/ui/derives/deriving-with-repr-packed.rs +++ b/src/test/ui/derives/deriving-with-repr-packed.rs @@ -1,29 +1,43 @@ #![deny(unaligned_references)] -// check that derive on a packed struct with non-Copy fields -// correctly. This can't be made to work perfectly because -// we can't just use the field from the struct as it might -// not be aligned. +// Check that deriving certain builtin traits on certain packed structs cause +// errors. This happens when the derived trait would need to use a potentially +// misaligned reference. But there are two cases that are allowed: +// - If all the fields within the struct meet the required alignment: 1 for +// `repr(packed)`, or `N` for `repr(packed(N))`. +// - If `Default` is the only trait derived, because it doesn't involve any +// references. -#[derive(Copy, Clone, PartialEq, Eq)] -//~^ ERROR `#[derive]` can't be used +#[derive(Copy, Clone, Default, PartialEq, Eq)] +//~^ ERROR `Clone` can't be derived on this `#[repr(packed)]` struct with type or const parameters //~| hard error -//~^^^ ERROR `#[derive]` can't be used +//~^^^ ERROR `PartialEq` can't be derived on this `#[repr(packed)]` struct with type or const parameters //~| hard error #[repr(packed)] pub struct Foo<T>(T, T, T); -#[derive(PartialEq, Eq)] -//~^ ERROR `#[derive]` can't be used +#[derive(Default, Hash)] +//~^ ERROR `Hash` can't be derived on this `#[repr(packed)]` struct that does not derive `Copy` //~| hard error #[repr(packed)] pub struct Bar(u32, u32, u32); -#[derive(PartialEq)] +// This one is fine because the field alignment is 1. +#[derive(Default, Hash)] +#[repr(packed)] +pub struct Bar2(u8, i8, bool); + +// This one is fine because the field alignment is 2, matching `packed(2)`. +#[derive(Default, Hash)] +#[repr(packed(2))] +pub struct Bar3(u16, i16, bool); + +// This one is fine because it's not packed. +#[derive(Debug, Default)] struct Y(usize); -#[derive(PartialEq)] -//~^ ERROR `#[derive]` can't be used +#[derive(Debug, Default)] +//~^ ERROR `Debug` can't be derived on this `#[repr(packed)]` struct that does not derive `Copy` //~| hard error #[repr(packed)] struct X(Y); diff --git a/src/test/ui/derives/deriving-with-repr-packed.stderr b/src/test/ui/derives/deriving-with-repr-packed.stderr index 1002b359f60..1f98da5b70e 100644 --- a/src/test/ui/derives/deriving-with-repr-packed.stderr +++ b/src/test/ui/derives/deriving-with-repr-packed.stderr @@ -1,7 +1,7 @@ -error: `#[derive]` can't be used on a `#[repr(packed)]` struct with type or const parameters (error E0133) - --> $DIR/deriving-with-repr-packed.rs:8:16 +error: `Clone` can't be derived on this `#[repr(packed)]` struct with type or const parameters (error E0133) + --> $DIR/deriving-with-repr-packed.rs:11:16 | -LL | #[derive(Copy, Clone, PartialEq, Eq)] +LL | #[derive(Copy, Clone, Default, PartialEq, Eq)] | ^^^^^ | note: the lint level is defined here @@ -13,43 +13,43 @@ LL | #![deny(unaligned_references)] = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `#[derive]` can't be used on a `#[repr(packed)]` struct with type or const parameters (error E0133) - --> $DIR/deriving-with-repr-packed.rs:8:23 +error: `PartialEq` can't be derived on this `#[repr(packed)]` struct with type or const parameters (error E0133) + --> $DIR/deriving-with-repr-packed.rs:11:32 | -LL | #[derive(Copy, Clone, PartialEq, Eq)] - | ^^^^^^^^^ +LL | #[derive(Copy, Clone, Default, PartialEq, Eq)] + | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133) - --> $DIR/deriving-with-repr-packed.rs:16:10 +error: `Hash` can't be derived on this `#[repr(packed)]` struct that does not derive `Copy` (error E0133) + --> $DIR/deriving-with-repr-packed.rs:19:19 | -LL | #[derive(PartialEq, Eq)] - | ^^^^^^^^^ +LL | #[derive(Default, Hash)] + | ^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> - = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133) - --> $DIR/deriving-with-repr-packed.rs:25:10 +error: `Debug` can't be derived on this `#[repr(packed)]` struct that does not derive `Copy` (error E0133) + --> $DIR/deriving-with-repr-packed.rs:39:10 | -LL | #[derive(PartialEq)] - | ^^^^^^^^^ +LL | #[derive(Debug, Default)] + | ^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> - = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors Future incompatibility report: Future breakage diagnostic: -error: `#[derive]` can't be used on a `#[repr(packed)]` struct with type or const parameters (error E0133) - --> $DIR/deriving-with-repr-packed.rs:8:16 +error: `Clone` can't be derived on this `#[repr(packed)]` struct with type or const parameters (error E0133) + --> $DIR/deriving-with-repr-packed.rs:11:16 | -LL | #[derive(Copy, Clone, PartialEq, Eq)] +LL | #[derive(Copy, Clone, Default, PartialEq, Eq)] | ^^^^^ | note: the lint level is defined here @@ -62,11 +62,11 @@ LL | #![deny(unaligned_references)] = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: -error: `#[derive]` can't be used on a `#[repr(packed)]` struct with type or const parameters (error E0133) - --> $DIR/deriving-with-repr-packed.rs:8:23 +error: `PartialEq` can't be derived on this `#[repr(packed)]` struct with type or const parameters (error E0133) + --> $DIR/deriving-with-repr-packed.rs:11:32 | -LL | #[derive(Copy, Clone, PartialEq, Eq)] - | ^^^^^^^^^ +LL | #[derive(Copy, Clone, Default, PartialEq, Eq)] + | ^^^^^^^^^ | note: the lint level is defined here --> $DIR/deriving-with-repr-packed.rs:1:9 @@ -78,11 +78,11 @@ LL | #![deny(unaligned_references)] = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: -error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133) - --> $DIR/deriving-with-repr-packed.rs:16:10 +error: `Hash` can't be derived on this `#[repr(packed)]` struct that does not derive `Copy` (error E0133) + --> $DIR/deriving-with-repr-packed.rs:19:19 | -LL | #[derive(PartialEq, Eq)] - | ^^^^^^^^^ +LL | #[derive(Default, Hash)] + | ^^^^ | note: the lint level is defined here --> $DIR/deriving-with-repr-packed.rs:1:9 @@ -91,14 +91,14 @@ LL | #![deny(unaligned_references)] | ^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> - = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: -error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133) - --> $DIR/deriving-with-repr-packed.rs:25:10 +error: `Debug` can't be derived on this `#[repr(packed)]` struct that does not derive `Copy` (error E0133) + --> $DIR/deriving-with-repr-packed.rs:39:10 | -LL | #[derive(PartialEq)] - | ^^^^^^^^^ +LL | #[derive(Debug, Default)] + | ^^^^^ | note: the lint level is defined here --> $DIR/deriving-with-repr-packed.rs:1:9 @@ -107,5 +107,5 @@ LL | #![deny(unaligned_references)] | ^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> - = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/process/nofile-limit.rs b/src/test/ui/process/nofile-limit.rs index 549135a46cf..3ddf8d6ef24 100644 --- a/src/test/ui/process/nofile-limit.rs +++ b/src/test/ui/process/nofile-limit.rs @@ -6,7 +6,7 @@ // dont-check-compiler-stderr // only-linux // no-prefer-dynamic -// compile-flags: -Ctarget-feature=+crt-static -Crpath=no +// compile-flags: -Ctarget-feature=+crt-static -Crpath=no -Crelocation-model=static #![feature(exit_status_error)] #![feature(rustc_private)] extern crate libc; diff --git a/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs new file mode 100644 index 00000000000..7b38c15afc2 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs @@ -0,0 +1,14 @@ +#![feature(const_trait_impl)] + +trait Foo { + fn a(&self); +} +trait Bar: ~const Foo {} + +const fn foo<T: Bar>(x: &T) { + x.a(); + //~^ ERROR the trait bound + //~| ERROR cannot call +} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail-2.stderr b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail-2.stderr new file mode 100644 index 00000000000..1766cdbee8a --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail-2.stderr @@ -0,0 +1,24 @@ +error[E0277]: the trait bound `T: ~const Foo` is not satisfied + --> $DIR/super-traits-fail-2.rs:9:7 + | +LL | x.a(); + | ^^^ the trait `~const Foo` is not implemented for `T` + | +note: the trait `Foo` is implemented for `T`, but that implementation is not `const` + --> $DIR/super-traits-fail-2.rs:9:7 + | +LL | x.a(); + | ^^^ + +error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions + --> $DIR/super-traits-fail-2.rs:9:7 + | +LL | x.a(); + | ^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.rs b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.rs new file mode 100644 index 00000000000..af465cad3d2 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.rs @@ -0,0 +1,16 @@ +#![feature(const_trait_impl)] + +trait Foo { + fn a(&self); +} +trait Bar: ~const Foo {} + +struct S; +impl Foo for S { + fn a(&self) {} +} + +impl const Bar for S {} +//~^ ERROR the trait bound + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr new file mode 100644 index 00000000000..9e8b8f8c6ba --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr @@ -0,0 +1,24 @@ +error[E0277]: the trait bound `S: ~const Foo` is not satisfied + --> $DIR/super-traits-fail.rs:13:12 + | +LL | impl const Bar for S {} + | ^^^ the trait `~const Foo` is not implemented for `S` + | +note: the trait `Foo` is implemented for `S`, but that implementation is not `const` + --> $DIR/super-traits-fail.rs:13:12 + | +LL | impl const Bar for S {} + | ^^^ +note: required by a bound in `Bar` + --> $DIR/super-traits-fail.rs:6:12 + | +LL | trait Bar: ~const Foo {} + | ^^^^^^^^^^ required by this bound in `Bar` +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | impl const Bar for S where S: ~const Foo {} + | +++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/super-traits.rs b/src/test/ui/rfc-2632-const-trait-impl/super-traits.rs new file mode 100644 index 00000000000..aded4ca9a99 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/super-traits.rs @@ -0,0 +1,22 @@ +// check-pass +#![feature(const_trait_impl)] + +trait Foo { + fn a(&self); +} +trait Bar: ~const Foo {} + +struct S; +impl const Foo for S { + fn a(&self) {} +} + +impl const Bar for S {} + +const fn foo<T: ~const Bar>(t: &T) { + t.a(); +} + +const _: () = foo(&S); + +fn main() {} |
