]> git.lizzy.rs Git - rust.git/commitdiff
Re-add a fixme after some investigation into what's going on.
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Fri, 10 Apr 2015 14:26:11 +0000 (16:26 +0200)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Fri, 10 Apr 2015 14:32:31 +0000 (16:32 +0200)
src/libsyntax/ext/deriving/generic/mod.rs

index c3478266db278a34f66ec214adfba3076b9f2f6a..de77baa0ef21fe48620ddf10d6dd8d1ef2107cc7 100644 (file)
@@ -1181,6 +1181,17 @@ fn build_enum_match_tuple(
                     rules: ast::UnsafeBlock(ast::CompilerGenerated),
                     span: sp }));
 
+                // FIXME: This unconditionally casts to `isize`. However:
+                //
+                // 1. On 32-bit platforms, that will truncate 64-bit enums
+                //    that are making use of the upper 32 bits, and
+                //
+                // 2. On all platforms, it will misinterpret the sign bit
+                //    of a 64-bit enum.
+                //
+                // What it should do is lookup whether the enum has an
+                // repr-attribute and cast to that if necessary. But
+                // attributes are not yet available to this function.
                 let target_ty = cx.ty_ident(sp, cx.ident_of("isize"));
                 let variant_disr = cx.expr_cast(sp, variant_value, target_ty);
                 let let_stmt = cx.stmt_let(sp, false, ident, variant_disr);