Skip to content

Commit

Permalink
Show r# in another raw identifier panic
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 20, 2022
1 parent 0de81da commit 3191e5e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ impl Ident {
// successfully converted into an identifier. Try to produce a valid raw
// identifier by running the `TokenStream` parser, and unwrapping the first
// token as an `Ident`.
if let Ok(ts) = format!("r#{}", string).parse::<proc_macro::TokenStream>() {
let raw_prefixed = format!("r#{}", string);
if let Ok(ts) = raw_prefixed.parse::<proc_macro::TokenStream>() {
let mut iter = ts.into_iter();
if let (Some(proc_macro::TokenTree::Ident(mut id)), None) =
(iter.next(), iter.next())
Expand All @@ -712,7 +713,7 @@ impl Ident {
return Ident::Compiler(id);
}
}
panic!("not allowed as a raw identifier: {}", string)
panic!("not allowed as a raw identifier: `{}`", raw_prefixed)
}
Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_raw(string, s)),
}
Expand Down

0 comments on commit 3191e5e

Please sign in to comment.