Skip to content

Commit

Permalink
Eliminate workaround for pre-1.17 rustc in serde_derive
Browse files Browse the repository at this point in the history
The oldest compiler supported by serde_derive by this point is 1.56.
  • Loading branch information
dtolnay committed Jul 28, 2023
1 parent 91ec1c2 commit db8f064
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions serde_derive/src/try.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
use proc_macro2::{Punct, Spacing, TokenStream};
use proc_macro2::TokenStream;
use quote::quote;

// None of our generated code requires the `From::from` error conversion
// performed by the standard library's `try!` macro. With this simplified macro
// we see a significant improvement in type checking and borrow checking time of
// the generated code and a slight improvement in binary size.
pub fn replacement() -> TokenStream {
// Cannot pass `$expr` to `quote!` prior to Rust 1.17.0 so interpolate it.
let dollar = Punct::new('$', Spacing::Alone);

quote! {
#[allow(unused_macros)]
macro_rules! try {
(#dollar __expr:expr) => {
match #dollar __expr {
($__expr:expr) => {
match $__expr {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
Expand Down

0 comments on commit db8f064

Please sign in to comment.