Skip to content
Myr

Eliminate workaround for pre-1.17 rustc in serde_derive

Before adoption: this commit came in with the history the project adopted, so no landing records it.

The oldest compiler supported by serde_derive by this point is 1.56.

authored by David Tolnay · committed by David Tolnay · parent 91ec1c2 · Browse files · 1 file+3 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−6 removed

  • other:+3 added−6 removed

1 file+3 added−6 removed

modified:serde_derive/src/try.rs+3 added-6 removed
1use proc_macro2::{Punct, Spacing, TokenStream};1use proc_macro2::TokenStream;2use quote::quote;34// None of our generated code requires the `From::from` error conversion5// performed by the standard library's `try!` macro. With this simplified macro6// we see a significant improvement in type checking and borrow checking time of7// the generated code and a slight improvement in binary size.8pub fn replacement() -> TokenStream {9 // Cannot pass `$expr` to `quote!` prior to Rust 1.17.0 so interpolate it.10 let dollar = Punct::new('$', Spacing::Alone);119 quote! {10 #[allow(unused_macros)]11 macro_rules! try {15 (#dollar __expr:expr) => {16 match #dollar __expr {12 ($__expr:expr) => {13 match $__expr {14 _serde::__private::Ok(__val) => __val,15 _serde::__private::Err(__err) => {16 return _serde::__private::Err(__err);17 }
5 unmodified lines