about summary refs log tree commit diff
path: root/src/libregex/parse
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2014-06-03 23:04:59 -0400
committerAndrew Gallant <jamslam@gmail.com>2014-06-03 23:04:59 -0400
commit9d39178f2f60b6076e4bd00e263f2304084f34b4 (patch)
tree79d7933e3f1461c45acb51d1162e7cbcae50dba0 /src/libregex/parse
parentf5ead0dd66ab7c3aaaaabcc34e1726a4acd74b07 (diff)
downloadrust-9d39178f2f60b6076e4bd00e263f2304084f34b4.tar.gz
rust-9d39178f2f60b6076e4bd00e263f2304084f34b4.zip
Fixes #13843.
An empty regex is a valid regex that always matches. This behavior
is consistent with at least Go and Python.

A couple regression tests are included.
Diffstat (limited to 'src/libregex/parse')
-rw-r--r--src/libregex/parse/mod.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libregex/parse/mod.rs b/src/libregex/parse/mod.rs
index bd2e454a9f8..14e34b805a3 100644
--- a/src/libregex/parse/mod.rs
+++ b/src/libregex/parse/mod.rs
@@ -201,6 +201,9 @@ pub fn parse(s: &str) -> Result<Ast, Error> {
 
 impl<'a> Parser<'a> {
     fn parse(&mut self) -> Result<Ast, Error> {
+        if self.chars.len() == 0 {
+            return Ok(Nothing);
+        }
         loop {
             let c = self.cur();
             match c {