about summary refs log tree commit diff
path: root/src/librustc/hir
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-03-26 02:47:04 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-03-27 00:07:16 +0300
commita637dd00c8536d86cfbe59d8a3881e29b3e55eeb (patch)
treeca8496d6d87764c81e5db9021e924ef88e5991be /src/librustc/hir
parentab8b961677ac5c74762dcea955aa0ff4d7fe4915 (diff)
downloadrust-a637dd00c8536d86cfbe59d8a3881e29b3e55eeb.tar.gz
rust-a637dd00c8536d86cfbe59d8a3881e29b3e55eeb.zip
Fix pretty-printing for raw identifiers
Diffstat (limited to 'src/librustc/hir')
-rw-r--r--src/librustc/hir/print.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs
index 3d38c0c8ed9..ff501f30c89 100644
--- a/src/librustc/hir/print.rs
+++ b/src/librustc/hir/print.rs
@@ -13,7 +13,7 @@ pub use self::AnnNode::*;
 use syntax::abi::Abi;
 use syntax::ast;
 use syntax::codemap::{CodeMap, Spanned};
-use syntax::parse::ParseSess;
+use syntax::parse::{token, ParseSess};
 use syntax::parse::lexer::comments;
 use syntax::print::pp::{self, Breaks};
 use syntax::print::pp::Breaks::{Consistent, Inconsistent};
@@ -1561,7 +1561,11 @@ impl<'a> State<'a> {
     }
 
     pub fn print_name(&mut self, name: ast::Name) -> io::Result<()> {
-        self.s.word(&name.as_str())?;
+        if token::is_raw_guess(ast::Ident::with_empty_ctxt(name)) {
+            self.s.word(&format!("r#{}", name))?;
+        } else {
+            self.s.word(&name.as_str())?;
+        }
         self.ann.post(self, NodeName(&name))
     }