1. 26

  2. 9

    I like that the article goes into a lot of detail about the refactoring steps. It is not exciting all the way - that is the reality of refactoring legacy/production software incrementally.

    1. 3

      Be aware that the slide recommends using pointers to enum something {} for opaque types. This is actually UB (you cannot produce those types in Rust and the compiler will reason on those types being uninhabited). I have yet to see actual bugs coming out of this, but it definitely is. The right way is to use enum something { _private: [u8; 0] }, which is an inhabited type that cannot be constructed.

      (Also, we will introduce opaque types for the reason that this is a bit… opaque)

      To be very clear: this does not introduce UB into safe Rust, as these types (and thus pointers to them) cannot be created without unsafe operations.

      https://gitlab.gnome.org/GNOME/librsvg/issues/391 https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs

      1. 2

        How are downstream packagers/maintainers taking the additional Rust dependency, with all the implications that brings when packaging? (i.e: cargo, vendoring, static linking preferences, etc.)

        1. 4

          From my peanut gallery, I noticed there is/was (?) at least some full-blown drama happening in the Debian community (via), and some stir in the Alpine community too (this one seemed much quieter) :]

          1. 2

            I haven’t been able to build the package since the transition to Rust. We’re using the pre-Rust version, even for platforms with Rust support. If someone manages to figure out why it doesn’t build, I guess we’ll keep the old librsvg for non-Rust platforms for as long as possible (we have a lot of those).

            for other rust packages, we have resorted to having every package “vendor” its own crates (as opposed to independent packages), but with an additional wrapper to build into our package system, so that we have a local mirror & checksums as with other fetched artifacts.

            1. 3

              Who is “we”? I.e. what particular downstream dependency are you talking about? Per your submission history, is it maybe netbsd?