]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #49835 - da-x:literal-fragment-pr, r=petrochenkov
authorbors <bors@rust-lang.org>
Sun, 13 May 2018 17:07:38 +0000 (17:07 +0000)
committerbors <bors@rust-lang.org>
Sun, 13 May 2018 17:07:38 +0000 (17:07 +0000)
Macros: Add a 'literal' fragment specifier

See: https://github.com/rust-lang/rust/issues/35625

```rust

macro_rules! test_literal {
    ($l:literal) => {
        println!("literal: {}", $l);
    };
    ($e:expr) => {
        println!("expr: {}", $e);
    };
}

fn main() {
    let a = 1;
    test_literal!(a);
    test_literal!(2);
    test_literal!(-3);
}
```

Output:

```
expr: 1
literal: 2
literal: -3
```

ToDo:

* [x] Feature gate
* [x] Basic tests
* [x] Tests for range patterns
* [x] Tests for attributes
* [x] Documentation
* [x] Fix for `true`/`false`
* [x] Fix for negative number literals


Trivial merge