From 23d59d00be7c12a4b8fef68ef663a6d97290c415 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Thu, 28 Jun 2018 14:58:54 -0700 Subject: 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`). --- src/libsyntax/ast.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libsyntax') 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 { -- cgit 1.4.1-3-g733a5