bors[bot] faddea9353
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 <tim@glacyr.com>
2020-10-07 09:32:47 +00:00
..
2020-08-24 13:29:10 +02:00
2020-10-02 21:38:22 +03:00
2020-10-06 19:20:56 +02:00
2020-09-28 11:03:47 +00:00
2020-10-06 18:17:49 +00:00
2020-10-02 21:16:22 +03:00
2020-10-06 17:51:20 +00:00
2020-09-30 15:22:49 -04:00
2020-10-07 09:12:09 +00:00
2020-09-03 13:37:36 +02:00