about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2018-06-28 14:58:54 -0700
committerEsteban Küber <esteban@kuber.com.ar>2018-06-28 14:58:54 -0700
commit23d59d00be7c12a4b8fef68ef663a6d97290c415 (patch)
treeebbbaf28392f3c48b8688e42ce28768477995359 /src/libsyntax
parent5d95db34a472dc09a90737c83ab533b840dcd224 (diff)
Suggest correct comparison against negative literal
When parsing as emplacement syntax (`x<-1`), suggest the correct syntax
for comparison against a negative value (`x< -1`).
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 53465c071f3..07e22b02c55 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1298,6 +1298,16 @@ impl LitKind {
         }
     }
 
+    /// Returns true if this is a numeric literal.
+    pub fn is_numeric(&self) -> bool {
+        match *self {
+            LitKind::Int(..) |
+            LitKind::Float(..) |
+            LitKind::FloatUnsuffixed(..) => true,
+            _ => false,
+        }
+    }
+
     /// Returns true if this literal has no suffix. Note: this will return true
     /// for literals with prefixes such as raw strings and byte strings.
     pub fn is_unsuffixed(&self) -> bool {