about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-05-11 16:03:27 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-05-11 17:06:55 +0300
commit83ed781c017632d48746553bdb2bf3d1633d5ca4 (patch)
tree8c14951d07f5a9e2d3be24e60a87925657003392 /src/libsyntax
parent3f064cae3d9d0d33951a44c30d83696563244572 (diff)
downloadrust-83ed781c017632d48746553bdb2bf3d1633d5ca4.tar.gz
rust-83ed781c017632d48746553bdb2bf3d1633d5ca4.zip
Address comments + Fix tests
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs9
-rw-r--r--src/libsyntax/parse/literal.rs4
2 files changed, 9 insertions, 4 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index a188f1a9368..aa176c89258 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1351,12 +1351,17 @@ pub enum StrStyle {
     Raw(u16),
 }
 
-/// A literal.
+/// An AST literal.
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Lit {
-    pub node: LitKind,
+    /// The original literal token as written in source code.
     pub token: token::Lit,
+    /// The original literal suffix as written in source code.
     pub suffix: Option<Symbol>,
+    /// The "semantic" representation of the literal lowered from the original tokens.
+    /// Strings are unescaped, hexadecimal forms are eliminated, etc.
+    /// FIXME: Remove this and only create the semantic representation during lowering to HIR.
+    pub node: LitKind,
     pub span: Span,
 }
 
diff --git a/src/libsyntax/parse/literal.rs b/src/libsyntax/parse/literal.rs
index 2c7ba13fbef..53195421ddc 100644
--- a/src/libsyntax/parse/literal.rs
+++ b/src/libsyntax/parse/literal.rs
@@ -27,7 +27,7 @@ macro_rules! err {
 
 impl LitKind {
     /// Converts literal token with a suffix into a semantic literal.
-    /// Works speculatively and may return `None` is diagnostic handler is not passed.
+    /// Works speculatively and may return `None` if diagnostic handler is not passed.
     /// If diagnostic handler is passed, always returns `Some`,
     /// possibly after reporting non-fatal errors and recovery.
     fn from_lit_token(
@@ -166,7 +166,7 @@ impl LitKind {
 
 impl Lit {
     /// Converts literal token with a suffix into an AST literal.
-    /// Works speculatively and may return `None` is diagnostic handler is not passed.
+    /// Works speculatively and may return `None` if diagnostic handler is not passed.
     /// If diagnostic handler is passed, may return `Some`,
     /// possibly after reporting non-fatal errors and recovery, or `None` for irrecoverable errors.
     crate fn from_token(