From bed669cba6c20e3bdbe01e87ce4566b60d7bc232 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 7 Oct 2013 15:43:42 -0400 Subject: syntax: Display spans for open delimiters when a file ends prematurely It's more helpful to list the span of each open delimiter seen so far than to print out an error with the span of the last position in the file. Closes #2354 --- src/test/compile-fail/issue-2354-1.rs | 12 ++++++++++++ src/test/compile-fail/issue-2354.rs | 10 ++-------- 2 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 src/test/compile-fail/issue-2354-1.rs (limited to 'src/test') diff --git a/src/test/compile-fail/issue-2354-1.rs b/src/test/compile-fail/issue-2354-1.rs new file mode 100644 index 00000000000..67b5c6becc7 --- /dev/null +++ b/src/test/compile-fail/issue-2354-1.rs @@ -0,0 +1,12 @@ +// Copyright 2013 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 foo: int = 2; } //~ ERROR incorrect close delimiter: + diff --git a/src/test/compile-fail/issue-2354.rs b/src/test/compile-fail/issue-2354.rs index 409e1c1f040..9761bd3317c 100644 --- a/src/test/compile-fail/issue-2354.rs +++ b/src/test/compile-fail/issue-2354.rs @@ -8,13 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test -/* - Ideally, the error about the missing close brace in foo would be reported - near the corresponding open brace. But currently it's reported at the end. - xfailed for now (see Issue #2354) - */ -fn foo() { //~ ERROR this open brace is not closed +fn foo() { //~ NOTE Did you mean to close this delimiter? match Some(x) { Some(y) { fail!(); } None { fail!(); } @@ -25,4 +19,4 @@ fn bar() { while (i < 1000) {} } -fn main() {} +fn main() {} //~ ERROR This file contains an un-closed delimiter -- cgit 1.4.1-3-g733a5