Skip to content

Commit

Permalink
Inline compiler_literal_from_str
Browse files Browse the repository at this point in the history
This function only made sense when compilers older than 1.54 needed to
use a different implementation.
  • Loading branch information
dtolnay committed Jul 16, 2023
1 parent 2d8dd97 commit 346cc05
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -879,18 +879,15 @@ impl FromStr for Literal {

fn from_str(repr: &str) -> Result<Self, Self::Err> {
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))
}
}
}

fn compiler_literal_from_str(repr: &str) -> Result<proc_macro::Literal, LexError> {
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 {
Expand Down

0 comments on commit 346cc05

Please sign in to comment.