Skip to content

Commit

Permalink
Delete no_literal_from_str config for rustc older than 1.54
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 16, 2023
1 parent 3f96a77 commit 2d8dd97
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
4 changes: 0 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ fn main() {
println!("cargo:rustc-cfg=span_locations");
}

if version.minor < 54 {
println!("cargo:rustc-cfg=no_literal_from_str");
}

if version.minor < 55 {
println!("cargo:rustc-cfg=no_group_open_close");
}
Expand Down
16 changes: 1 addition & 15 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,21 +888,7 @@ impl FromStr for Literal {
}

fn compiler_literal_from_str(repr: &str) -> Result<proc_macro::Literal, LexError> {
#[cfg(not(no_literal_from_str))]
{
proc_macro::Literal::from_str(repr).map_err(LexError::Compiler)
}
#[cfg(no_literal_from_str)]
{
let tokens = proc_macro_parse(repr)?;
let mut iter = tokens.into_iter();
if let (Some(proc_macro::TokenTree::Literal(literal)), None) = (iter.next(), iter.next()) {
if literal.to_string().len() == repr.len() {
return Ok(literal);
}
}
Err(LexError::call_site())
}
proc_macro::Literal::from_str(repr).map_err(LexError::Compiler)
}

impl Display for Literal {
Expand Down

0 comments on commit 2d8dd97

Please sign in to comment.