summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-01 13:37:05 +0000
committerbors <bors@rust-lang.org>2018-07-01 13:37:05 +0000
commitef9a322843fa9f1d6eb6f05b3ba8f9f96ef1de46 (patch)
treebb1b6b5076cf6ce6d0d94b1a77e2734a1c43360d /src/libsyntax
parente100ce4f924138725d092ead2f3f22fd945ae8ac (diff)
parent23d59d00be7c12a4b8fef68ef663a6d97290c415 (diff)
downloadrust-ef9a322843fa9f1d6eb6f05b3ba8f9f96ef1de46.tar.gz
rust-ef9a322843fa9f1d6eb6f05b3ba8f9f96ef1de46.zip
Auto merge of #51883 - estebank:placement-suggestion, r=varkor
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`).

Fix #45651.
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 d767265ead9..71ff9e8058e 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 {