Skip to content

Commit

Permalink
Rearrange push_ident internals
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 20, 2022
1 parent 1e89973 commit cb2ba9f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree {
}

pub fn push_ident(tokens: &mut TokenStream, s: &str) {
tokens.append(mk_ident(s, None));
let span = Span::call_site();
push_ident_spanned(tokens, span, s);
}

pub fn push_ident_spanned(tokens: &mut TokenStream, span: Span, s: &str) {
tokens.append(mk_ident(s, Some(span)));
tokens.append(ident_maybe_raw(s, span));
}

pub fn push_lifetime(tokens: &mut TokenStream, lifetime: &str) {
Expand Down Expand Up @@ -378,7 +379,10 @@ pub fn push_underscore_spanned(tokens: &mut TokenStream, span: Span) {
// handling `r#` prefixes.
pub fn mk_ident(id: &str, span: Option<Span>) -> Ident {
let span = span.unwrap_or_else(Span::call_site);
ident_maybe_raw(id, span)
}

fn ident_maybe_raw(id: &str, span: Span) -> Ident {
if id.starts_with("r#") {
Ident::new_raw(&id[2..], span)
} else {
Expand Down

0 comments on commit cb2ba9f

Please sign in to comment.