Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid repeated interning of env!("CFG_RELEASE") #117188

Merged
merged 10 commits into from
Oct 27, 2023
Prev Previous commit
Next Next commit
Add a Parse impl for symbol Value
dtolnay committed Oct 26, 2023

Verified

This commit was signed with the committer’s verified signature.
dtolnay David Tolnay
commit 95742ff23cf2283da796f483386367f7fdc06bc6
10 changes: 8 additions & 2 deletions compiler/rustc_macros/src/symbols.rs
Original file line number Diff line number Diff line change
@@ -65,13 +65,19 @@ impl Parse for Symbol {
fn parse(input: ParseStream<'_>) -> Result<Self> {
let name = input.parse()?;
let colon_token: Option<Token![:]> = input.parse()?;
let value =
if colon_token.is_some() { Value::String(input.parse()?) } else { Value::SameAsName };
let value = if colon_token.is_some() { input.parse()? } else { Value::SameAsName };

Ok(Symbol { name, value })
}
}

impl Parse for Value {
fn parse(input: ParseStream<'_>) -> Result<Self> {
let lit: LitStr = input.parse()?;
Ok(Value::String(lit))
}
}

struct Input {
keywords: Punctuated<Keyword, Token![,]>,
symbols: Punctuated<Symbol, Token![,]>,