From 1f542cd2640fd969cba328ca3b4059acd6428a83 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 19 Jan 2014 00:00:39 -0800 Subject: [PATCH] Fix a pathological const checking case The included test case would essentially never finish compiling without this patch. It recursies twice at every ExprParen meaning that the branching factor is 2^n The included test case will take so long to parse on the old compiler that it'll surely never let this crop up again. --- src/librustc/middle/check_const.rs | 3 +-- src/test/run-pass/super-fast-paren-parsing.rs | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/super-fast-paren-parsing.rs diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index e13f6f8c537..31a3e6ce8ff 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -177,11 +177,10 @@ pub fn check_expr(v: &mut CheckCrateVisitor, } } } - ExprParen(e) => { check_expr(v, sess, def_map, method_map, - tcx, e, is_const); } ExprVstore(_, ExprVstoreSlice) | ExprVec(_, MutImmutable) | ExprAddrOf(MutImmutable, _) | + ExprParen(..) | ExprField(..) | ExprIndex(..) | ExprTup(..) | diff --git a/src/test/run-pass/super-fast-paren-parsing.rs b/src/test/run-pass/super-fast-paren-parsing.rs new file mode 100644 index 00000000000..759b066c8db --- /dev/null +++ b/src/test/run-pass/super-fast-paren-parsing.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static a: int = +((((((((((((((((((((((((((((((((((((((((((((((((((( +((((((((((((((((((((((((((((((((((((((((((((((((((( +((((((((((((((((((((((((((((((((((((((((((((((((((( +((((((((((((((((((((((((((((((((((((((((((((((((((( +((((((((((((((((((((((((((((((((((((((((((((((((((( +1 +))))))))))))))))))))))))))))))))))))))))))))))))))) +))))))))))))))))))))))))))))))))))))))))))))))))))) +))))))))))))))))))))))))))))))))))))))))))))))))))) +))))))))))))))))))))))))))))))))))))))))))))))))))) +))))))))))))))))))))))))))))))))))))))))))))))))))) +; + +pub fn main() {} -- GitLab