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 #485

Open psychon opened 4 years ago

psychon commented 4 years ago

The following diff does not cause make to fail, which means that we can remove two arguments from emit_struct_type:

diff --git a/generator/src/generator/namespace.rs b/generator/src/generator/namespace.rs
index d9881d1..3581a76 100644
--- a/generator/src/generator/namespace.rs
+++ b/generator/src/generator/namespace.rs
@@ -2353,6 +2353,8 @@ impl<'ns, 'c> NamespaceGenerator<'ns, 'c> {
         doc: Option<&xcbdefs::Doc>,
         out: &mut Output,
     ) {
+        assert!(!skip_length_field);
+        assert!(generate_try_parse);
         assert!(!(generate_serialize && !fields_need_serialize));

         let deducible_fields = gather_deducible_fields(fields);

General question: Is there a simple approach to find similar cases in the code generator?

DemiMarie commented 3 years ago

Does Rust have code coverage support?

psychon commented 3 years ago

Honest answer: I don't know. Google found https://blog.rust-lang.org/inside-rust/2020/11/12/source-based-code-coverage.html which says:

Nightly Rust already supports another kind of source code coverage, commonly called gcov, which relies on debug info to map from LLVM IR to lines of source code.

So... I guess this means that there already is support for some nightly-only kind of code coverage. (And this blog post talks about another nightly-only way being added)