Fix symbols::tests::test_symbols

---- symbols::tests::test_symbols stdout ----
    thread 'symbols::tests::test_symbols' panicked at library/proc_macro/src/bridge/client.rs:311:17:
    procedural macro API is used outside of a procedural macro
This commit is contained in:
David Tolnay 2023-10-25 14:45:31 -07:00
parent ac4fa3f245
commit c1552dfddd
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 9 additions and 1 deletions

View File

@ -257,6 +257,14 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
Value::SameAsName | Value::String(_) | Value::Unsupported(_) => continue,
};
if !proc_macro::is_available() {
errors.error(
Span::call_site(),
"proc_macro::tracked_env is not available in unit test".to_owned(),
);
break;
}
let value = match proc_macro::tracked_env::var(env_var.value()) {
Ok(value) => value,
Err(err) => {

View File

@ -27,7 +27,7 @@ fn test_symbols() {
let body_tokens = m.mac.tokens.clone();
test_symbols_macro(body_tokens, &[]);
test_symbols_macro(body_tokens, &["proc_macro::tracked_env is not available in unit test"]);
}
fn test_symbols_macro(input: TokenStream, expected_errors: &[&str]) {