bevyengine / bevyengine/bevy

Rust-analyzer shows an error when using negative numeric constants in BSN macros

Open
#24,050 6 comments 5 reactions 0 assignees View on GitHub
A-Scenes C-Bug C-Usability D-Macros D-Straightforward S-Blocked X-Uncontroversial
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version and features

Latest main (https://github.com/bevyengine/bevy/commit/638c5dd29778c9ea718d44996b4832ed600c0169)

## What you did

```rust
#[derive(Component, Clone, Copy, Default)]
pub struct MyComponent(f32);

bsn! {
MyComponent(-0.1)
}
```

## What went wrong

Received a `expected Expr` error from rust-analyzer (but compiles fine).

## Additional information

Using braces around it does work:

```rust
bsn! {
MyComponent({-0.3})
}
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided Component and bsn! snippets in rust-analyzer, comparing the negative numeric constant with the braced form. Trace how BSN macro input is interpreted around MyComponent(-0.1); done means rust-analyzer accepts the unbraced form without an error while the example continues to compile.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.