about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-03-17 23:22:57 +0000
committerbors <bors@rust-lang.org>2018-03-17 23:22:57 +0000
commitca6a98426192f838cc90a18709f92d425b86029e (patch)
treeaad9717ff8dca9636794c782148b0729b46090e0 /src/libsyntax/print
parentadf2135adc4a65a78ba053f04c29d7fe0468eb87 (diff)
parented5ea5c705ccea7d2eef1558530e87d2dbb88be7 (diff)
downloadrust-ca6a98426192f838cc90a18709f92d425b86029e.tar.gz
rust-ca6a98426192f838cc90a18709f92d425b86029e.zip
Auto merge of #48842 - petrochenkov:under, r=nikomatsakis
syntax: Make `_` a reserved identifier

Why:
- Lexically `_` is an identifier.
- Internally it makes implementation of `use Trait as _;` (https://github.com/rust-lang/rust/issues/48216) and some other things cleaner.
- We prevent the externally observable effect of `_` being accepted by macros expecting `ident` by treating `_` specially in the `ident` matcher:
```rust
macro_rules! m {
    ($i: ident) => { let $i = 10; }
}

m!(_); // Still an error
```
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 1cf2b7a44bc..36698a86374 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -252,7 +252,6 @@ pub fn token_to_string(tok: &Token) -> String {
         /* Name components */
         token::Ident(s)             => s.to_string(),
         token::Lifetime(s)          => s.to_string(),
-        token::Underscore           => "_".to_string(),
 
         /* Other */
         token::DocComment(s)        => s.to_string(),