psychon / x11rb

X11 bindings for the rust programming language, similar to xcb being the X11 C bindings
Apache License 2.0
372 stars 41 forks source link

Dead code in the code generator #473

Open psychon opened 4 years ago

psychon commented 4 years ago

As far as I can see, there is no fixed size switch anywhere. Put differently, the following patch causes no problems (well, some compiler warnings, but that's it):

diff --git a/generator/src/generator/namespace.rs b/generator/src/generator/namespace.rs
index 0ae83a6..09dd7f7 100644
--- a/generator/src/generator/namespace.rs
+++ b/generator/src/generator/namespace.rs
@@ -2990,6 +2990,7 @@ impl<'ns, 'c> NamespaceGenerator<'ns, 'c> {

         if generate_serialize {
             if let Some(size) = switch.size() {
+                unreachable!();
                 self.emit_fixed_size_switch_serialize(
                     switch,
                     name,

I'm not quite sure what to do with this knowledge. Remove the dead code from the code generator?

eduardosm commented 4 years ago

I think I had added that thinking of https://github.com/psychon/x11rb/issues/369. For example, if ClientMessageData gets replaced by a switch, that switch needs to be handled as a fixed size type because it is inside a non-GE event.