Skip to content

Commit 292de22

Browse files
committed
Add a struct with an unsized field to the deriving-all-codegen.rs test.
It's an interesting case, requiring the use of `&&` in `Debug::fmt`.
1 parent c6ff90b commit 292de22

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

src/test/ui/deriving/deriving-all-codegen.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ struct Point {
3131
// A large struct.
3232
#[derive(Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
3333
struct Big {
34-
b1: u32, b2: u32, b3: u32, b4: u32, b5: u32, b6: u32, b7: u32, b8:u32,
34+
b1: u32, b2: u32, b3: u32, b4: u32, b5: u32, b6: u32, b7: u32, b8: u32,
3535
}
3636

37+
// A struct with an unsized field. Some derives are not usable in this case.
38+
#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
39+
struct Unsized([u32]);
40+
3741
// A packed tuple struct.
3842
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
3943
#[repr(packed)]

src/test/ui/deriving/deriving-all-codegen.stdout

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,61 @@ impl ::core::cmp::Ord for Big {
367367
}
368368
}
369369

370+
// A struct with an unsized field. Some derives are not usable in this case.
371+
struct Unsized([u32]);
372+
#[automatically_derived]
373+
#[allow(unused_qualifications)]
374+
impl ::core::fmt::Debug for Unsized {
375+
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
376+
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Unsized",
377+
&&self.0)
378+
}
379+
}
380+
#[automatically_derived]
381+
#[allow(unused_qualifications)]
382+
impl ::core::hash::Hash for Unsized {
383+
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
384+
::core::hash::Hash::hash(&self.0, state)
385+
}
386+
}
387+
impl ::core::marker::StructuralPartialEq for Unsized {}
388+
#[automatically_derived]
389+
#[allow(unused_qualifications)]
390+
impl ::core::cmp::PartialEq for Unsized {
391+
#[inline]
392+
fn eq(&self, other: &Unsized) -> bool { self.0 == other.0 }
393+
#[inline]
394+
fn ne(&self, other: &Unsized) -> bool { self.0 != other.0 }
395+
}
396+
impl ::core::marker::StructuralEq for Unsized {}
397+
#[automatically_derived]
398+
#[allow(unused_qualifications)]
399+
impl ::core::cmp::Eq for Unsized {
400+
#[inline]
401+
#[doc(hidden)]
402+
#[no_coverage]
403+
fn assert_receiver_is_total_eq(&self) -> () {
404+
let _: ::core::cmp::AssertParamIsEq<[u32]>;
405+
}
406+
}
407+
#[automatically_derived]
408+
#[allow(unused_qualifications)]
409+
impl ::core::cmp::PartialOrd for Unsized {
410+
#[inline]
411+
fn partial_cmp(&self, other: &Unsized)
412+
-> ::core::option::Option<::core::cmp::Ordering> {
413+
::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
414+
}
415+
}
416+
#[automatically_derived]
417+
#[allow(unused_qualifications)]
418+
impl ::core::cmp::Ord for Unsized {
419+
#[inline]
420+
fn cmp(&self, other: &Unsized) -> ::core::cmp::Ordering {
421+
::core::cmp::Ord::cmp(&self.0, &other.0)
422+
}
423+
}
424+
370425
// A packed tuple struct.
371426
#[repr(packed)]
372427
struct Packed(u32);

0 commit comments

Comments
 (0)