From 346cc0533f0049cd84267f002ac6fc9356c5a170 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 16 Jul 2023 11:44:11 -0700 Subject: [PATCH] Inline compiler_literal_from_str This function only made sense when compilers older than 1.54 needed to use a different implementation. --- src/wrapper.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/wrapper.rs b/src/wrapper.rs index df97670..c898b6c 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -756,7 +756,7 @@ macro_rules! unsuffixed_integers { impl Literal { pub unsafe fn from_str_unchecked(repr: &str) -> Self { if inside_proc_macro() { - Literal::Compiler(compiler_literal_from_str(repr).expect("invalid literal")) + Literal::Compiler(proc_macro::Literal::from_str(repr).expect("invalid literal")) } else { Literal::Fallback(fallback::Literal::from_str_unchecked(repr)) } @@ -879,7 +879,8 @@ impl FromStr for Literal { fn from_str(repr: &str) -> Result { if inside_proc_macro() { - compiler_literal_from_str(repr).map(Literal::Compiler) + let literal = proc_macro::Literal::from_str(repr)?; + Ok(Literal::Compiler(literal)) } else { let literal = fallback::Literal::from_str(repr)?; Ok(Literal::Fallback(literal)) @@ -887,10 +888,6 @@ impl FromStr for Literal { } } -fn compiler_literal_from_str(repr: &str) -> Result { - proc_macro::Literal::from_str(repr).map_err(LexError::Compiler) -} - impl Display for Literal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self {