From dd6e3863e5525cb83ad6c02328bd5800119cdd7a Mon Sep 17 00:00:00 2001 From: mcarton Date: Thu, 8 Sep 2016 01:10:23 +0200 Subject: [PATCH 1/3] Fix ICE test in compiletest fail-tests --- src/tools/compiletest/src/runtest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 228d6ada01d..ddf41872825 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -978,7 +978,7 @@ fn check_error_patterns(&self, fn check_no_compiler_crash(&self, proc_res: &ProcRes) { for line in proc_res.stderr.lines() { - if line.starts_with("error: internal compiler error:") { + if line.contains("error: internal compiler error") { self.fatal_proc_rec("compiler encountered internal error", proc_res); } } From 726c2b6e9b68b61edb6d09a13c67cfca62035027 Mon Sep 17 00:00:00 2001 From: mcarton Date: Tue, 20 Sep 2016 18:05:00 +0200 Subject: [PATCH 2/3] Don't ICE when a float can't be parsed --- src/librustc_const_eval/eval.rs | 16 ++++++++-------- src/test/compile-fail/issue-31109.rs | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 30e5a0cacf5..25fe8b8035a 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -872,7 +872,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, debug!("const call({:?})", call_args); eval_const_expr_partial(tcx, &result, ty_hint, Some(&call_args))? }, - hir::ExprLit(ref lit) => match lit_to_const(&lit.node, tcx, ety, lit.span) { + hir::ExprLit(ref lit) => match lit_to_const(&lit.node, tcx, ety) { Ok(val) => val, Err(err) => signal!(e, err), }, @@ -1208,8 +1208,7 @@ fn cast_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, val: ConstVal, ty: ty::Ty) fn lit_to_const<'a, 'tcx>(lit: &ast::LitKind, tcx: TyCtxt<'a, 'tcx, 'tcx>, - ty_hint: Option>, - span: Span) + ty_hint: Option>) -> Result { use syntax::ast::*; use syntax::ast::LitIntType::*; @@ -1243,21 +1242,22 @@ fn lit_to_const<'a, 'tcx>(lit: &ast::LitKind, }, LitKind::Float(ref n, fty) => { - Ok(Float(parse_float(n, Some(fty), span))) + parse_float(n, Some(fty)).map(Float) } LitKind::FloatUnsuffixed(ref n) => { let fty_hint = match ty_hint.map(|t| &t.sty) { Some(&ty::TyFloat(fty)) => Some(fty), _ => None }; - Ok(Float(parse_float(n, fty_hint, span))) + parse_float(n, fty_hint).map(Float) } LitKind::Bool(b) => Ok(Bool(b)), LitKind::Char(c) => Ok(Char(c)), } } -fn parse_float(num: &str, fty_hint: Option, span: Span) -> ConstFloat { +fn parse_float(num: &str, fty_hint: Option) + -> Result { let val = match fty_hint { Some(ast::FloatTy::F32) => num.parse::().map(F32), Some(ast::FloatTy::F64) => num.parse::().map(F64), @@ -1269,9 +1269,9 @@ fn parse_float(num: &str, fty_hint: Option, span: Span) -> ConstFl }) } }; - val.unwrap_or_else(|_| { + val.map_err(|_| { // FIXME(#31407) this is only necessary because float parsing is buggy - span_bug!(span, "could not evaluate float literal (see issue #31407)"); + UnimplementedConstVal("could not evaluate float literal (see issue #31407)") }) } diff --git a/src/test/compile-fail/issue-31109.rs b/src/test/compile-fail/issue-31109.rs index 63b3d58b823..33047329123 100644 --- a/src/test/compile-fail/issue-31109.rs +++ b/src/test/compile-fail/issue-31109.rs @@ -12,4 +12,5 @@ fn main() { // FIXME(#31407) this error should go away, but in the meantime we test that it // is accompanied by a somewhat useful error message. let _: f64 = 1234567890123456789012345678901234567890e-340; //~ ERROR could not evaluate float + //~ ERROR unimplemented constant expression: could not evaluate float literal } From bfa34332833962e4991f508ac3ab4958fd9b64cd Mon Sep 17 00:00:00 2001 From: mcarton Date: Thu, 22 Sep 2016 18:32:40 +0200 Subject: [PATCH 3/3] Fix compile-fail syntax in error file --- src/test/compile-fail/issue-31109.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/compile-fail/issue-31109.rs b/src/test/compile-fail/issue-31109.rs index 33047329123..e3548d74071 100644 --- a/src/test/compile-fail/issue-31109.rs +++ b/src/test/compile-fail/issue-31109.rs @@ -11,6 +11,7 @@ fn main() { // FIXME(#31407) this error should go away, but in the meantime we test that it // is accompanied by a somewhat useful error message. - let _: f64 = 1234567890123456789012345678901234567890e-340; //~ ERROR could not evaluate float - //~ ERROR unimplemented constant expression: could not evaluate float literal + let _: f64 = 1234567890123456789012345678901234567890e-340; + //~^ ERROR constant evaluation error + //~| unimplemented constant expression: could not evaluate float literal }