rust/compiler/rustc_expand/src
bors e91405b9d5 Auto merge of #87262 - dtolnay:negative, r=Aaron1011
Support negative numbers in Literal::from_str

proc_macro::Literal has allowed negative numbers in a single literal token ever since Rust 1.29, using https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.isize_unsuffixed and similar constructors.

```rust
let lit = proc_macro::Literal::isize_unsuffixed(-10);
```

However, the suite of constructors on Literal is not sufficient for all use cases, for example arbitrary precision floats, or custom suffixes in FFI macros.

```rust
let lit = proc_macro::Literal::f64_unsuffixed(0.101001000100001000001000000100000001); // :(
let lit = proc_macro::Literal::i???_suffixed(10ulong); // :(
```

For those, macros construct the literal using from_str instead, which preserves arbitrary precision, custom suffixes, base, and digit grouping.

```rust
let lit = "0.101001000100001000001000000100000001".parse::<Literal>().unwrap();
let lit = "10ulong".parse::<Literal>().unwrap();
let lit = "0b1000_0100_0010_0001".parse::<Literal>().unwrap();
```

However, until this PR it was not possible to construct a literal token that is **both** negative **and** preserving of arbitrary precision etc.

This PR fixes `Literal::from_str` to recognize negative integer and float literals.
2021-08-03 04:50:28 +00:00
..
mbe Only emit lint for local macros 2021-07-27 14:18:46 -05:00
mut_visit Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
parse Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
tokenstream Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
base.rs Auto merge of #87381 - Aaron1011:note-semi-trailing-macro, r=petrochenkov 2021-07-25 04:34:58 +00:00
build.rs Use AttrVec for Arm, FieldDef, and Variant 2021-06-17 08:04:54 +09:00
config.rs Unify rustc and rustdoc parsing of cfg() 2021-05-03 12:49:43 -04:00
expand.rs Auto merge of #87381 - Aaron1011:note-semi-trailing-macro, r=petrochenkov 2021-07-25 04:34:58 +00:00
lib.rs Include macro name in 'local ambiguity' error 2021-06-07 20:17:48 -05:00
mbe.rs fix few typos 2021-04-19 15:57:08 +03:00
module.rs E0583: Include secondary path in error message 2021-05-06 09:40:05 +08:00
placeholders.rs ast/hir: Rename field-related structures 2021-03-16 11:41:24 +03:00
proc_macro.rs rustc_expand: Remove redundant field from proc macro expander structures 2021-07-10 23:22:27 +03:00
proc_macro_server.rs Auto merge of #87262 - dtolnay:negative, r=Aaron1011 2021-08-03 04:50:28 +00:00
tests.rs Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00