Skip to content

Commit

Permalink
fix: use uppercase const name (#1043)
Browse files Browse the repository at this point in the history
### What

This fixes an issue where Rust Analyzer sometimes complains that:

    constant `symbol` should have UPPER_SNAKE_CASE name

### Why

When using `symbol_short!`, as recommended by the Getting Started →
Hello World tutorial, I was getting confusing warnings from Rust
Analyzer:

<img width="957" alt="image"
src="https://github.com/stellar/rs-soroban-sdk/assets/221614/d7a29fcf-6683-4979-b68b-bab4627d7dd7">

### Known limitations

Why not use this instead?

```rs
Ok(_) => quote! {
    #crate_path::Symbol::short(#s)
}
```
  • Loading branch information
chadoh authored Jul 27, 2023
1 parent 0a95f57 commit 4c51299
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions soroban-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ fn _symbol_short(crate_path: &str, s: &LitStr) -> TokenStream {
match Symbol::try_from_small_str(&s.value()) {
Ok(_) => quote! {{
#[allow(deprecated)]
const symbol: #crate_path::Symbol = #crate_path::Symbol::short(#s);
symbol
const SYMBOL: #crate_path::Symbol = #crate_path::Symbol::short(#s);
SYMBOL
}}
.into(),
Err(e) => Error::new(s.span(), format!("{e}"))
Expand Down

0 comments on commit 4c51299

Please sign in to comment.