Skip to content

Commit a029ce8

Browse files
authored
Rollup merge of #63419 - RalfJung:typeid, r=alexcrichton
check against more collisions for TypeId of fn pointer Cc rust-lang/rfcs#2738 (comment)
2 parents 9e613c7 + 4dd96d2 commit a029ce8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/test/ui/typeid-intrinsic.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,20 @@ pub fn main() {
7878
assert_eq!(TypeId::of::<other1::U32Iterator>(), other1::id_u32_iterator());
7979
assert_eq!(other1::id_i32_iterator(), other2::id_i32_iterator());
8080
assert_eq!(other1::id_u32_iterator(), other2::id_u32_iterator());
81-
assert!(other1::id_i32_iterator() != other1::id_u32_iterator());
82-
assert!(TypeId::of::<other1::I32Iterator>() != TypeId::of::<other1::U32Iterator>());
81+
assert_ne!(other1::id_i32_iterator(), other1::id_u32_iterator());
82+
assert_ne!(TypeId::of::<other1::I32Iterator>(), TypeId::of::<other1::U32Iterator>());
8383

8484
// Check fn pointer against collisions
85-
assert!(TypeId::of::<fn(fn(A) -> A) -> A>() !=
86-
TypeId::of::<fn(fn() -> A, A) -> A>());
85+
assert_ne!(
86+
TypeId::of::<fn(fn(A) -> A) -> A>(),
87+
TypeId::of::<fn(fn() -> A, A) -> A>()
88+
);
89+
assert_ne!(
90+
TypeId::of::<for<'a> fn(&'a i32) -> &'a i32>(),
91+
TypeId::of::<for<'a> fn(&'a i32) -> &'static i32>()
92+
);
93+
assert_ne!(
94+
TypeId::of::<for<'a, 'b> fn(&'a i32, &'b i32) -> &'a i32>(),
95+
TypeId::of::<for<'a, 'b> fn(&'b i32, &'a i32) -> &'a i32>()
96+
);
8797
}

0 commit comments

Comments
 (0)