Skip to content

Commit 1078250

Browse files
committed
Continue generating other symbols if an expr is not supported
1 parent 65f0253 commit 1078250

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

compiler/rustc_macros/src/symbols.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum Value {
6060
SameAsName,
6161
String(LitStr),
6262
Env(LitStr),
63+
Unsupported(Expr),
6364
}
6465

6566
impl Parse for Symbol {
@@ -88,13 +89,7 @@ impl Parse for Value {
8889
}
8990
_ => {}
9091
}
91-
Err(syn::Error::new_spanned(
92-
expr,
93-
concat!(
94-
"unsupported expression for symbol value; implement support for this in ",
95-
file!(),
96-
),
97-
))
92+
Ok(Value::Unsupported(expr))
9893
}
9994
}
10095

@@ -223,7 +218,17 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
223218
let value = match &symbol.value {
224219
Value::SameAsName => name.to_string(),
225220
Value::String(lit) => lit.value(),
226-
Value::Env(_) => continue,
221+
Value::Env(_) => continue, // in another loop below
222+
Value::Unsupported(expr) => {
223+
errors.list.push(syn::Error::new_spanned(
224+
expr,
225+
concat!(
226+
"unsupported expression for symbol value; implement support for this in ",
227+
file!(),
228+
),
229+
));
230+
continue;
231+
}
227232
};
228233
let idx = entries.insert(symbol.name.span(), &value, &mut errors);
229234

@@ -249,7 +254,7 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
249254
for symbol in &input.symbols {
250255
let env_var = match &symbol.value {
251256
Value::Env(lit) => lit,
252-
_ => continue,
257+
Value::SameAsName | Value::String(_) | Value::Unsupported(_) => continue,
253258
};
254259

255260
let value = match proc_macro::tracked_env::var(env_var.value()) {

0 commit comments

Comments
 (0)