diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/deriving/deriving-all-codegen.rs | 2 | ||||
-rw-r--r-- | src/test/ui/deriving/deriving-all-codegen.stdout | 137 | ||||
-rw-r--r-- | src/test/ui/deriving/deriving-default-enum.rs | 10 | ||||
-rw-r--r-- | src/test/ui/deriving/deriving-hash.rs | 20 | ||||
-rw-r--r-- | src/test/ui/deriving/issue-103157.rs | 12 | ||||
-rw-r--r-- | src/test/ui/deriving/issue-103157.stderr | 30 | ||||
-rw-r--r-- | src/test/ui/deriving/issue-89188-gat-hrtb.rs | 2 |
7 files changed, 127 insertions, 86 deletions
diff --git a/src/test/ui/deriving/deriving-all-codegen.rs b/src/test/ui/deriving/deriving-all-codegen.rs index aef79ae8a..ba7809413 100644 --- a/src/test/ui/deriving/deriving-all-codegen.rs +++ b/src/test/ui/deriving/deriving-all-codegen.rs @@ -85,7 +85,7 @@ enum Mixed { P, Q, R(u32), - S { d1: u32, d2: u32 }, + S { d1: Option<u32>, d2: Option<i32> }, } // An enum with no fieldless variants. Note that `Default` cannot be derived diff --git a/src/test/ui/deriving/deriving-all-codegen.stdout b/src/test/ui/deriving/deriving-all-codegen.stdout index 21fe663f0..92fce6888 100644 --- a/src/test/ui/deriving/deriving-all-codegen.stdout +++ b/src/test/ui/deriving/deriving-all-codegen.stdout @@ -46,13 +46,15 @@ impl ::core::default::Default for Empty { impl ::core::hash::Hash for Empty { fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {} } -impl ::core::marker::StructuralPartialEq for Empty {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Empty { } #[automatically_derived] impl ::core::cmp::PartialEq for Empty { #[inline] fn eq(&self, other: &Empty) -> bool { true } } -impl ::core::marker::StructuralEq for Empty {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Empty { } #[automatically_derived] impl ::core::cmp::Eq for Empty { #[inline] @@ -115,19 +117,17 @@ impl ::core::hash::Hash for Point { ::core::hash::Hash::hash(&self.y, state) } } -impl ::core::marker::StructuralPartialEq for Point {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Point { } #[automatically_derived] impl ::core::cmp::PartialEq for Point { #[inline] fn eq(&self, other: &Point) -> bool { self.x == other.x && self.y == other.y } - #[inline] - fn ne(&self, other: &Point) -> bool { - self.x != other.x || self.y != other.y - } } -impl ::core::marker::StructuralEq for Point {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Point { } #[automatically_derived] impl ::core::cmp::Eq for Point { #[inline] @@ -229,7 +229,8 @@ impl ::core::hash::Hash for Big { ::core::hash::Hash::hash(&self.b8, state) } } -impl ::core::marker::StructuralPartialEq for Big {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Big { } #[automatically_derived] impl ::core::cmp::PartialEq for Big { #[inline] @@ -239,15 +240,9 @@ impl ::core::cmp::PartialEq for Big { self.b6 == other.b6 && self.b7 == other.b7 && self.b8 == other.b8 } - #[inline] - fn ne(&self, other: &Big) -> bool { - self.b1 != other.b1 || self.b2 != other.b2 || self.b3 != other.b3 || - self.b4 != other.b4 || self.b5 != other.b5 || - self.b6 != other.b6 || self.b7 != other.b7 || - self.b8 != other.b8 - } } -impl ::core::marker::StructuralEq for Big {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Big { } #[automatically_derived] impl ::core::cmp::Eq for Big { #[inline] @@ -356,15 +351,15 @@ impl ::core::hash::Hash for Unsized { ::core::hash::Hash::hash(&self.0, state) } } -impl ::core::marker::StructuralPartialEq for Unsized {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Unsized { } #[automatically_derived] impl ::core::cmp::PartialEq for Unsized { #[inline] fn eq(&self, other: &Unsized) -> bool { self.0 == other.0 } - #[inline] - fn ne(&self, other: &Unsized) -> bool { self.0 != other.0 } } -impl ::core::marker::StructuralEq for Unsized {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Unsized { } #[automatically_derived] impl ::core::cmp::Eq for Unsized { #[inline] @@ -423,15 +418,15 @@ impl ::core::hash::Hash for PackedCopy { ::core::hash::Hash::hash(&{ self.0 }, state) } } -impl ::core::marker::StructuralPartialEq for PackedCopy {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for PackedCopy { } #[automatically_derived] impl ::core::cmp::PartialEq for PackedCopy { #[inline] fn eq(&self, other: &PackedCopy) -> bool { { self.0 } == { other.0 } } - #[inline] - fn ne(&self, other: &PackedCopy) -> bool { { self.0 } != { other.0 } } } -impl ::core::marker::StructuralEq for PackedCopy {} +#[automatically_derived] +impl ::core::marker::StructuralEq for PackedCopy { } #[automatically_derived] impl ::core::cmp::Eq for PackedCopy { #[inline] @@ -494,7 +489,8 @@ impl ::core::hash::Hash for PackedNonCopy { ::core::hash::Hash::hash(__self_0_0, state) } } -impl ::core::marker::StructuralPartialEq for PackedNonCopy {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for PackedNonCopy { } #[automatically_derived] impl ::core::cmp::PartialEq for PackedNonCopy { #[inline] @@ -503,14 +499,9 @@ impl ::core::cmp::PartialEq for PackedNonCopy { let Self(ref __self_1_0) = *other; *__self_0_0 == *__self_1_0 } - #[inline] - fn ne(&self, other: &PackedNonCopy) -> bool { - let Self(ref __self_0_0) = *self; - let Self(ref __self_1_0) = *other; - *__self_0_0 != *__self_1_0 - } } -impl ::core::marker::StructuralEq for PackedNonCopy {} +#[automatically_derived] +impl ::core::marker::StructuralEq for PackedNonCopy { } #[automatically_derived] impl ::core::cmp::Eq for PackedNonCopy { #[inline] @@ -561,7 +552,8 @@ impl ::core::hash::Hash for Enum0 { unsafe { ::core::intrinsics::unreachable() } } } -impl ::core::marker::StructuralPartialEq for Enum0 {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Enum0 { } #[automatically_derived] impl ::core::cmp::PartialEq for Enum0 { #[inline] @@ -569,7 +561,8 @@ impl ::core::cmp::PartialEq for Enum0 { unsafe { ::core::intrinsics::unreachable() } } } -impl ::core::marker::StructuralEq for Enum0 {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Enum0 { } #[automatically_derived] impl ::core::cmp::Eq for Enum0 { #[inline] @@ -628,7 +621,8 @@ impl ::core::hash::Hash for Enum1 { } } } -impl ::core::marker::StructuralPartialEq for Enum1 {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Enum1 { } #[automatically_derived] impl ::core::cmp::PartialEq for Enum1 { #[inline] @@ -638,15 +632,9 @@ impl ::core::cmp::PartialEq for Enum1 { *__self_0 == *__arg1_0, } } - #[inline] - fn ne(&self, other: &Enum1) -> bool { - match (self, other) { - (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => - *__self_0 != *__arg1_0, - } - } } -impl ::core::marker::StructuralEq for Enum1 {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Enum1 { } #[automatically_derived] impl ::core::cmp::Eq for Enum1 { #[inline] @@ -704,13 +692,15 @@ impl ::core::default::Default for Fieldless1 { impl ::core::hash::Hash for Fieldless1 { fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {} } -impl ::core::marker::StructuralPartialEq for Fieldless1 {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Fieldless1 { } #[automatically_derived] impl ::core::cmp::PartialEq for Fieldless1 { #[inline] fn eq(&self, other: &Fieldless1) -> bool { true } } -impl ::core::marker::StructuralEq for Fieldless1 {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Fieldless1 { } #[automatically_derived] impl ::core::cmp::Eq for Fieldless1 { #[inline] @@ -771,7 +761,8 @@ impl ::core::hash::Hash for Fieldless { ::core::hash::Hash::hash(&__self_tag, state) } } -impl ::core::marker::StructuralPartialEq for Fieldless {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Fieldless { } #[automatically_derived] impl ::core::cmp::PartialEq for Fieldless { #[inline] @@ -781,7 +772,8 @@ impl ::core::cmp::PartialEq for Fieldless { __self_tag == __arg1_tag } } -impl ::core::marker::StructuralEq for Fieldless {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Fieldless { } #[automatically_derived] impl ::core::cmp::Eq for Fieldless { #[inline] @@ -817,8 +809,8 @@ enum Mixed { Q, R(u32), S { - d1: u32, - d2: u32, + d1: Option<u32>, + d2: Option<i32>, }, } #[automatically_derived] @@ -826,6 +818,8 @@ impl ::core::clone::Clone for Mixed { #[inline] fn clone(&self) -> Mixed { let _: ::core::clone::AssertParamIsClone<u32>; + let _: ::core::clone::AssertParamIsClone<Option<u32>>; + let _: ::core::clone::AssertParamIsClone<Option<i32>>; *self } } @@ -866,7 +860,8 @@ impl ::core::hash::Hash for Mixed { } } } -impl ::core::marker::StructuralPartialEq for Mixed {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Mixed { } #[automatically_derived] impl ::core::cmp::PartialEq for Mixed { #[inline] @@ -883,22 +878,9 @@ impl ::core::cmp::PartialEq for Mixed { _ => true, } } - #[inline] - fn ne(&self, other: &Mixed) -> bool { - let __self_tag = ::core::intrinsics::discriminant_value(self); - let __arg1_tag = ::core::intrinsics::discriminant_value(other); - __self_tag != __arg1_tag || - match (self, other) { - (Mixed::R(__self_0), Mixed::R(__arg1_0)) => - *__self_0 != *__arg1_0, - (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S { - d1: __arg1_0, d2: __arg1_1 }) => - *__self_0 != *__arg1_0 || *__self_1 != *__arg1_1, - _ => false, - } - } } -impl ::core::marker::StructuralEq for Mixed {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Mixed { } #[automatically_derived] impl ::core::cmp::Eq for Mixed { #[inline] @@ -906,6 +888,8 @@ impl ::core::cmp::Eq for Mixed { #[no_coverage] fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq<u32>; + let _: ::core::cmp::AssertParamIsEq<Option<u32>>; + let _: ::core::cmp::AssertParamIsEq<Option<i32>>; } } #[automatically_derived] @@ -1005,7 +989,8 @@ impl ::core::hash::Hash for Fielded { } } } -impl ::core::marker::StructuralPartialEq for Fielded {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Fielded { } #[automatically_derived] impl ::core::cmp::PartialEq for Fielded { #[inline] @@ -1023,23 +1008,9 @@ impl ::core::cmp::PartialEq for Fielded { _ => unsafe { ::core::intrinsics::unreachable() } } } - #[inline] - fn ne(&self, other: &Fielded) -> bool { - let __self_tag = ::core::intrinsics::discriminant_value(self); - let __arg1_tag = ::core::intrinsics::discriminant_value(other); - __self_tag != __arg1_tag || - match (self, other) { - (Fielded::X(__self_0), Fielded::X(__arg1_0)) => - *__self_0 != *__arg1_0, - (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) => - *__self_0 != *__arg1_0, - (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) => - *__self_0 != *__arg1_0, - _ => unsafe { ::core::intrinsics::unreachable() } - } - } } -impl ::core::marker::StructuralEq for Fielded {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Fielded { } #[automatically_derived] impl ::core::cmp::Eq for Fielded { #[inline] diff --git a/src/test/ui/deriving/deriving-default-enum.rs b/src/test/ui/deriving/deriving-default-enum.rs index d1a81c72c..1c7a501ed 100644 --- a/src/test/ui/deriving/deriving-default-enum.rs +++ b/src/test/ui/deriving/deriving-default-enum.rs @@ -12,6 +12,16 @@ enum Foo { Beta(NotDefault), } +// #[default] on a generic enum does not add `Default` bounds to the type params. +#[derive(Default)] +enum MyOption<T> { + #[default] + None, + #[allow(dead_code)] + Some(T), +} + fn main() { assert_eq!(Foo::default(), Foo::Alpha); + assert!(matches!(MyOption::<NotDefault>::default(), MyOption::None)); } diff --git a/src/test/ui/deriving/deriving-hash.rs b/src/test/ui/deriving/deriving-hash.rs index 8b51370bc..16738ec4a 100644 --- a/src/test/ui/deriving/deriving-hash.rs +++ b/src/test/ui/deriving/deriving-hash.rs @@ -44,6 +44,17 @@ fn fake_hash<A: Hash>(v: &mut Vec<u8>, a: A) { a.hash(&mut FakeHasher(v)); } +struct OnlyOneByteHasher; +impl Hasher for OnlyOneByteHasher { + fn finish(&self) -> u64 { + unreachable!() + } + + fn write(&mut self, bytes: &[u8]) { + assert_eq!(bytes.len(), 1); + } +} + fn main() { let person1 = Person { id: 5, @@ -73,4 +84,13 @@ fn main() { let mut v = vec![]; fake_hash(&mut v, SingleVariantEnum::A(17)); assert_eq!(vec![17], v); + + // issue #39137 + #[repr(u8)] + #[derive(Hash)] + enum E { + A, + B, + } + E::A.hash(&mut OnlyOneByteHasher); } diff --git a/src/test/ui/deriving/issue-103157.rs b/src/test/ui/deriving/issue-103157.rs new file mode 100644 index 000000000..52b4c7898 --- /dev/null +++ b/src/test/ui/deriving/issue-103157.rs @@ -0,0 +1,12 @@ +// check-fail + +#[derive(PartialEq, Eq)] +pub enum Value { + Boolean(Option<bool>), + Float(Option<f64>), //~ ERROR the trait bound `f64: Eq` is not satisfied +} + +fn main() { + let a = Value::Float(Some(f64::NAN)); + assert!(a == a); +} diff --git a/src/test/ui/deriving/issue-103157.stderr b/src/test/ui/deriving/issue-103157.stderr new file mode 100644 index 000000000..ee3528fe1 --- /dev/null +++ b/src/test/ui/deriving/issue-103157.stderr @@ -0,0 +1,30 @@ +error[E0277]: the trait bound `f64: Eq` is not satisfied + --> $DIR/issue-103157.rs:6:11 + | +LL | #[derive(PartialEq, Eq)] + | -- in this derive macro expansion +... +LL | Float(Option<f64>), + | ^^^^^^^^^^^ the trait `Eq` is not implemented for `f64` + | + = help: the following other types implement trait `Eq`: + i128 + i16 + i32 + i64 + i8 + isize + u128 + u16 + and 4 others + = note: required for `Option<f64>` to implement `Eq` +note: required by a bound in `AssertParamIsEq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq<T: Eq + ?Sized> { + | ^^ required by this bound in `AssertParamIsEq` + = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/deriving/issue-89188-gat-hrtb.rs b/src/test/ui/deriving/issue-89188-gat-hrtb.rs index abd85a616..e8118f0c6 100644 --- a/src/test/ui/deriving/issue-89188-gat-hrtb.rs +++ b/src/test/ui/deriving/issue-89188-gat-hrtb.rs @@ -1,7 +1,5 @@ // check-pass -#![feature(generic_associated_types)] - trait CallWithShim: Sized { type Shim<'s> where |