]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #63419 - RalfJung:typeid, r=alexcrichton
authorMazdak Farrokhzad <twingoow@gmail.com>
Sat, 10 Aug 2019 06:13:24 +0000 (08:13 +0200)
committerGitHub <noreply@github.com>
Sat, 10 Aug 2019 06:13:24 +0000 (08:13 +0200)
check against more collisions for TypeId of fn pointer

Cc https://github.com/rust-lang/rfcs/pull/2738#issuecomment-519923318

src/test/ui/typeid-intrinsic.rs

index c2611158e65ef6d29a1c5377967b0bcb8d61dd15..5bc4e0c217f40894c0d406cce38ceeb41cc95f8d 100644 (file)
@@ -78,10 +78,20 @@ pub fn main() {
     assert_eq!(TypeId::of::<other1::U32Iterator>(), other1::id_u32_iterator());
     assert_eq!(other1::id_i32_iterator(), other2::id_i32_iterator());
     assert_eq!(other1::id_u32_iterator(), other2::id_u32_iterator());
-    assert!(other1::id_i32_iterator() != other1::id_u32_iterator());
-    assert!(TypeId::of::<other1::I32Iterator>() != TypeId::of::<other1::U32Iterator>());
+    assert_ne!(other1::id_i32_iterator(), other1::id_u32_iterator());
+    assert_ne!(TypeId::of::<other1::I32Iterator>(), TypeId::of::<other1::U32Iterator>());
 
     // Check fn pointer against collisions
-    assert!(TypeId::of::<fn(fn(A) -> A) -> A>() !=
-            TypeId::of::<fn(fn() -> A, A) -> A>());
+    assert_ne!(
+        TypeId::of::<fn(fn(A) -> A) -> A>(),
+        TypeId::of::<fn(fn() -> A, A) -> A>()
+    );
+    assert_ne!(
+        TypeId::of::<for<'a> fn(&'a i32) -> &'a i32>(),
+        TypeId::of::<for<'a> fn(&'a i32) -> &'static i32>()
+    );
+    assert_ne!(
+        TypeId::of::<for<'a, 'b> fn(&'a i32, &'b i32) -> &'a i32>(),
+        TypeId::of::<for<'a, 'b> fn(&'b i32, &'a i32) -> &'a i32>()
+    );
 }