Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Rust 1.15 Brings Custom Derive

Rust 1.15 Brings Custom Derive

This item in japanese

The Rust core team has released the stable version of 1.15, bringing with it the highly anticipated custom derive, allowing code-generating crates like Serde and Diesel to work ergonomically.

In the notes to RFC 1681 the motivation for custom derive is explained:

Some large projects in the ecosystem today, such as serde and diesel, effectively require the nightly channel of the Rust compiler. Although most projects have an alternative to work on stable Rust, this tends to be far less ergonomic and comes with its own set of downsides, and empirically it has not been enough to push the nightly users to stable as well...

The good news, however, is that this class of projects which require nightly Rust almost all require nightly for the reason of procedural macros. Even better, the full functionality of procedural macros is rarely needed, only custom derive! Even better, custom derive typically doesn't require the features one would expect from a full-on macro system, such as hygiene and modularity, that normal procedural macros typically do.

A Diesel use case is provided in the blog post Announcing Rust 1.15:

// some extern crate and use lines elided here

struct Pet {
    name: String,

fn main() {
    use diesel_demo::schema::pets::dsl::*;

    let connection = establish_connection();
    let results = pets
        .expect("Error loading pets");

    println!("Displaying {} pets", results.len());
    for pet in results {

Aside from custom derive, other improvements in Rust 1.15 include a re-written build system, using Cargo. The Rust team comments:

Given that all Rust development happens on the master branch, we’ve been using it since December of last year, and it’s working well. There is an open PR to remove the Makefiles entirely, landing in Rust 1.17. This will pave the way for rustc to use packages from in the compiler like any other Rust project.

In other areas of significance, with the 1.15 stable release Rust has gained Tier 3 support for i686-unknown-openbsd, MSP430, and ARMv5TE. In the Hacker News discussion around the release, user thenewwazoo commented "WHOA! MSP430 support is HUGE. In case you don't know, that's a well-known very low-power microcontroller... this might be the only current platform that's <32 bits. I know there was some work on supporting the 8-bit AVR architecture, but MSP430 gets rust a lot closer to super-low-power applications."

Other users were equally excited about the release. Dikaiosune said, "This is pretty major. In anticipation of this release, I was able to remove all nightly feature flags from a smallish web backend which makes heavy use of type-driven codegen (serde and diesel). Really, truly, utterly fantastic to have stability promises for custom_derive. So excited!"

Ekidd agreed, adding, "We have a bunch of Rust apps at work, and just one of them was still on nightly, and now we can move that to stable, too. And we can get rid of a bunch of scripts elsewhere, which is always nice."

Detailed release notes for Rust 1.15 are available on GitHub, and the release can be downloaded from here.

Rate this Article