linebender / druid

A data-first Rust-native UI design toolkit.
https://linebender.org/druid/
Apache License 2.0
9.45k stars 569 forks source link

Update Rust edition to 2021. #2327

Closed xStrom closed 1 year ago

xStrom commented 1 year ago

It seems that we can rather easily upgrade to Rust 2021 and there is currently a direct benefit, so I think we should do it. Specifically clippy 1.67 (beta) is buggy with Rust 2018 as I found out in #2326. Upgrading to Rust 2021 will solve that issue for us.


There is an exception in druid-derive which will remain Rust 2018. We have macros that use syntax which is no longer allowed in Rust 2021.

This is mostly relevant to macros. E.g. quote!{ #a#b } is no longer accepted.

quote! {
    #[doc = #struct_docs]
    #[allow(non_camel_case_types)]
    #[derive(Debug, Copy, Clone)]
    pub struct #field_name#lens_ty_generics(#(#phantom_decls),*); // <- Illegal in Rust 2021

    impl #lens_ty_generics #field_name#lens_ty_generics{ // <- Illegal in Rust 2021
        #[doc = #fn_docs]
        pub const fn new()->Self{
            Self(#(#phantom_inits),*)
        }
    }
}

As druid-derive doesn't have any assert! or debug_assert! usage that clippy complains about, staying at 2018 there isn't an issue for us right now.