Skip to content

Commit

Permalink
Remove #[cfg(test)] related stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
chorman0773 committed Nov 23, 2024
1 parent 3d67fd4 commit 8578ccc
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 57 deletions.
2 changes: 0 additions & 2 deletions tests/ui/layout/aggregate-lang/struct-align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ struct ReprRustStruct {
b: Overaligned,
}

#[cfg_attr(test, test)]
fn test_alignment_contains_all_fields() {
assert!(core::mem::align_of::<ReprRustStruct>() >= core::mem::align_of::<i32>());
assert!(core::mem::align_of::<ReprRustStruct>() >= core::mem::align_of::<[u32; 4]>());
Expand All @@ -25,7 +24,6 @@ fn test_alignment_contains_all_fields() {
assert!(core::mem::align_of::<ReprRustStruct>() >= core::mem::align_of::<Overaligned>());
}

#[cfg(not(test))]
fn main() {
test_alignment_contains_all_fields();
}
23 changes: 4 additions & 19 deletions tests/ui/layout/aggregate-lang/struct-offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ fn test_non_overlapping(a: &(usize, usize), b: &(usize, usize)) {
assert!((a.1 <= b.0) || (b.1 <= a.0));
}

#[cfg_attr(test, test)]
fn test_fields_non_overlapping() {
let fields = [
span_of!(ReprRustStruct, x),
Expand All @@ -62,31 +61,17 @@ fn test_fields_non_overlapping() {
test_non_overlapping(&fields[3], &fields[4]);
}

#[cfg_attr(test, test)]
fn test_fields_aligned() {
assert_eq!(
(core::mem::offset_of!(ReprRustStruct, x) % (core::mem::align_of::<i32>())),
0
);
assert_eq!(
(core::mem::offset_of!(ReprRustStruct, y) % (core::mem::align_of::<[u32; 4]>())),
0
);
assert_eq!(
(core::mem::offset_of!(ReprRustStruct, z) % (core::mem::align_of::<f32>())),
0
);
assert_eq!(
(core::mem::offset_of!(ReprRustStruct, a) % (core::mem::align_of::<u128>())),
0
);
assert_eq!((core::mem::offset_of!(ReprRustStruct, x) % (core::mem::align_of::<i32>())), 0);
assert_eq!((core::mem::offset_of!(ReprRustStruct, y) % (core::mem::align_of::<[u32; 4]>())), 0);
assert_eq!((core::mem::offset_of!(ReprRustStruct, z) % (core::mem::align_of::<f32>())), 0);
assert_eq!((core::mem::offset_of!(ReprRustStruct, a) % (core::mem::align_of::<u128>())), 0);
assert_eq!(
(core::mem::offset_of!(ReprRustStruct, b) % (core::mem::align_of::<Overaligned>())),
0
);
}

#[cfg(not(test))]
fn main() {
test_fields_non_overlapping();
test_fields_aligned();
Expand Down
9 changes: 1 addition & 8 deletions tests/ui/layout/aggregate-lang/struct-size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ struct ReprRustStruct {
a: u128,
}

#[cfg_attr(test, test)]
fn test_size_contains_all_types() {
assert!(
core::mem::size_of::<ReprRustStruct>()
Expand All @@ -21,7 +20,6 @@ fn test_size_contains_all_types() {
);
}

#[cfg_attr(test, test)]
fn test_size_contains_all_fields() {
assert!(
(core::mem::offset_of!(ReprRustStruct, x) + core::mem::size_of::<i32>())
Expand All @@ -41,15 +39,10 @@ fn test_size_contains_all_fields() {
);
}

#[cfg_attr(test, test)]
fn test_size_modulo_align() {
assert_eq!(
core::mem::size_of::<ReprRustStruct>() % core::mem::align_of::<ReprRustStruct>(),
0
);
assert_eq!(core::mem::size_of::<ReprRustStruct>() % core::mem::align_of::<ReprRustStruct>(), 0);
}

#[cfg(not(test))]
fn main() {
test_size_contains_all_fields();
test_size_contains_all_types();
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/layout/aggregate-lang/union-align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ union ReprRustUnion {
b: Overaligned,
}

#[cfg_attr(test, test)]
fn test_alignment_contains_all_fields() {
assert!(core::mem::align_of::<ReprRustUnion>() >= core::mem::align_of::<i32>());
assert!(core::mem::align_of::<ReprRustUnion>() >= core::mem::align_of::<[u32; 4]>());
Expand All @@ -25,7 +24,6 @@ fn test_alignment_contains_all_fields() {
assert!(core::mem::align_of::<ReprRustUnion>() >= core::mem::align_of::<Overaligned>());
}

#[cfg(not(test))]
fn main() {
test_alignment_contains_all_fields();
}
22 changes: 4 additions & 18 deletions tests/ui/layout/aggregate-lang/union-offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,17 @@ union ReprRustUnion {
b: Overaligned,
}

#[cfg_attr(test, test)]
fn test_fields_aligned() {
assert_eq!(
(core::mem::offset_of!(ReprRustUnion, x) % (core::mem::align_of::<i32>())),
0
);
assert_eq!(
(core::mem::offset_of!(ReprRustUnion, y) % (core::mem::align_of::<[u32; 4]>())),
0
);
assert_eq!(
(core::mem::offset_of!(ReprRustUnion, z) % (core::mem::align_of::<f32>())),
0
);
assert_eq!(
(core::mem::offset_of!(ReprRustUnion, a) % (core::mem::align_of::<u128>())),
0
);
assert_eq!((core::mem::offset_of!(ReprRustUnion, x) % (core::mem::align_of::<i32>())), 0);
assert_eq!((core::mem::offset_of!(ReprRustUnion, y) % (core::mem::align_of::<[u32; 4]>())), 0);
assert_eq!((core::mem::offset_of!(ReprRustUnion, z) % (core::mem::align_of::<f32>())), 0);
assert_eq!((core::mem::offset_of!(ReprRustUnion, a) % (core::mem::align_of::<u128>())), 0);
assert_eq!(
(core::mem::offset_of!(ReprRustUnion, b) % (core::mem::align_of::<Overaligned>())),
0
);
}

#[cfg(not(test))]
fn main() {
test_fields_aligned();
}
9 changes: 1 addition & 8 deletions tests/ui/layout/aggregate-lang/union-size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ union ReprRustUnion {
a: u128,
}

#[cfg_attr(test, test)]
fn test_size_contains_each_type() {
assert!(core::mem::size_of::<i32>() <= core::mem::size_of::<ReprRustUnion>());
assert!(core::mem::size_of::<[u32; 4]>() <= core::mem::size_of::<ReprRustUnion>());
assert!(core::mem::size_of::<f32>() <= core::mem::size_of::<ReprRustUnion>());
assert!(core::mem::size_of::<u128>() <= core::mem::size_of::<ReprRustUnion>());
}

#[cfg_attr(test, test)]
fn test_size_contains_all_fields() {
assert!(
(core::mem::offset_of!(ReprRustUnion, x) + core::mem::size_of::<i32>())
Expand All @@ -38,15 +36,10 @@ fn test_size_contains_all_fields() {
);
}

#[cfg_attr(test, test)]
fn test_size_modulo_align() {
assert_eq!(
core::mem::size_of::<ReprRustUnion>() % core::mem::align_of::<ReprRustUnion>(),
0
);
assert_eq!(core::mem::size_of::<ReprRustUnion>() % core::mem::align_of::<ReprRustUnion>(), 0);
}

#[cfg(not(test))]
fn main() {
test_size_contains_each_type();
test_size_contains_all_fields();
Expand Down

0 comments on commit 8578ccc

Please sign in to comment.