We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
type_id_of_val
1 parent d7bdd38 commit 30c02f1Copy full SHA for 30c02f1
tests/mir-opt/gvn_type_id_polymorphic.rs
@@ -5,6 +5,12 @@
5
6
fn generic<T>() {}
7
8
+// Since `type_id` contains provenance, we cannot turn it into an integer,
9
+// but for the purposes of this test, it is sufficient to use the length of the
10
+// type name as the first 8 bytes of the `u128` and the first 8 bytes of the type name
11
+// as the rest of the bytes of the `u128`. The main thing being tested is the result of
12
+// calling this function being simple enough that comparisons of it are turned into
13
+// a direct MIR `Eq` bin op.
14
const fn type_id_of_val<T: 'static>(_: &T) -> u128 {
15
let name = std::intrinsics::type_name::<T>();
16
let len = name.len() as u64;
0 commit comments