diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-07 10:32:47 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-07 10:32:47 +0100 |
commit | faddea935332de3156a5462baa07136bf2e98bf9 (patch) | |
tree | 2bf4b95ff97c0cd9ed8a69ed63808fffffd521f2 /crates/text_edit | |
parent | a184c83535230af39fad3e238b7422b4972d597e (diff) | |
parent | 27798ee575a975a1806ced86aca8aea407897851 (diff) |
Merge #6158
6158: Fix for negative literals in macros r=matklad a=cutsoy
_This pull request fixes #6028._
When writing `-42.0f32` in Rust, it is usually parsed as two different tokens (a minus operator and a float literal).
But a procedural macro can also generate new tokens, including negative [float literals](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.f32_suffixed):
```rust
#[proc_macro]
fn example_verbose(input: TokenStream) -> TokenStream {
let literal = Literal::f32_suffixed(-42.0);
quote! { #literal }
}
```
or even shorter
```rust
#[proc_macro]
fn example(input: TokenStream) -> TokenStream {
let literal = -42.0f32;
quote! { #literal }
}
```
Unfortunately, these currently cause RA to crash:
```
thread '<unnamed>' panicked at 'Fail to convert given literal Literal {
text: "-42.0f32",
id: TokenId(
4294967295,
),
}', crates/mbe/src/subtree_source.rs:161:28
```
This pull request contains both a fix 8cf9362 and a unit test 27798ee. In addition, I installed the patched server with `cargo xtask install --server` and verified in VSCode that it no longer crashes when a procedural macro returns a negative number literal.
Co-authored-by: Tim <[email protected]>
Diffstat (limited to 'crates/text_edit')
0 files changed, 0 insertions, 0 deletions