Auto merge of #53949 - estebank:unclosed-delim, r=nikomatsakis
Improve messages for un-closed delimiter errors
This commit is contained in:
commit
004bc5a33c
16 changed files with 172 additions and 41 deletions
|
|
@ -10,7 +10,8 @@
|
|||
|
||||
// compile-flags: -Z parse-only
|
||||
|
||||
struct Obj { //~ NOTE: unclosed delimiter
|
||||
struct Obj {
|
||||
//~^ NOTE: un-closed delimiter
|
||||
member: usize
|
||||
)
|
||||
//~^ ERROR incorrect close delimiter
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
error: incorrect close delimiter: `)`
|
||||
--> $DIR/issue-10636-1.rs:15:1
|
||||
--> $DIR/issue-10636-1.rs:16:1
|
||||
|
|
||||
LL | struct Obj { //~ NOTE: unclosed delimiter
|
||||
| - unclosed delimiter
|
||||
LL | member: usize
|
||||
LL | struct Obj {
|
||||
| - un-closed delimiter
|
||||
...
|
||||
LL | )
|
||||
| ^ incorrect close delimiter
|
||||
|
||||
|
|
|
|||
26
src/test/ui/issue-2354.rs
Normal file
26
src/test/ui/issue-2354.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2012 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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z parse-only
|
||||
|
||||
fn foo() { //~ NOTE un-closed delimiter
|
||||
match Some(x) {
|
||||
//~^ NOTE this delimiter might not be properly closed...
|
||||
Some(y) => { panic!(); }
|
||||
None => { panic!(); }
|
||||
}
|
||||
//~^ NOTE ...as it matches this but it has different indentation
|
||||
|
||||
fn bar() {
|
||||
let mut i = 0;
|
||||
while (i < 1000) {}
|
||||
}
|
||||
|
||||
fn main() {} //~ ERROR this file contains an un-closed delimiter
|
||||
16
src/test/ui/issue-2354.stderr
Normal file
16
src/test/ui/issue-2354.stderr
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
error: this file contains an un-closed delimiter
|
||||
--> $DIR/issue-2354.rs:26:66
|
||||
|
|
||||
LL | fn foo() { //~ NOTE un-closed delimiter
|
||||
| - un-closed delimiter
|
||||
LL | match Some(x) {
|
||||
| - this delimiter might not be properly closed...
|
||||
...
|
||||
LL | }
|
||||
| - ...as it matches this but it has different indentation
|
||||
...
|
||||
LL | fn main() {} //~ ERROR this file contains an un-closed delimiter
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -14,11 +14,12 @@
|
|||
|
||||
trait Foo {
|
||||
fn bar() {
|
||||
let x = foo(); //~ ERROR cannot find function `foo` in this scope
|
||||
|
||||
let x = foo();
|
||||
//~^ ERROR cannot find function `foo` in this scope
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = y.; //~ ERROR unexpected token
|
||||
//~^ ERROR cannot find value `y` in this scope
|
||||
let x = y.;
|
||||
//~^ ERROR unexpected token
|
||||
//~| ERROR cannot find value `y` in this scope
|
||||
} //~ ERROR this file contains an un-closed delimiter
|
||||
|
|
|
|||
|
|
@ -1,31 +1,33 @@
|
|||
error: this file contains an un-closed delimiter
|
||||
--> $DIR/parser-recovery-1.rs:24:55
|
||||
|
|
||||
LL | } //~ ERROR this file contains an un-closed delimiter
|
||||
| ^
|
||||
|
|
||||
help: did you mean to close this delimiter?
|
||||
--> $DIR/parser-recovery-1.rs:15:11
|
||||
--> $DIR/parser-recovery-1.rs:25:55
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^
|
||||
| - un-closed delimiter
|
||||
LL | fn bar() {
|
||||
| - this delimiter might not be properly closed...
|
||||
...
|
||||
LL | }
|
||||
| - ...as it matches this but it has different indentation
|
||||
...
|
||||
LL | } //~ ERROR this file contains an un-closed delimiter
|
||||
| ^
|
||||
|
||||
error: unexpected token: `;`
|
||||
--> $DIR/parser-recovery-1.rs:22:15
|
||||
|
|
||||
LL | let x = y.; //~ ERROR unexpected token
|
||||
LL | let x = y.;
|
||||
| ^
|
||||
|
||||
error[E0425]: cannot find function `foo` in this scope
|
||||
--> $DIR/parser-recovery-1.rs:17:17
|
||||
|
|
||||
LL | let x = foo(); //~ ERROR cannot find function `foo` in this scope
|
||||
LL | let x = foo();
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error[E0425]: cannot find value `y` in this scope
|
||||
--> $DIR/parser-recovery-1.rs:22:13
|
||||
|
|
||||
LL | let x = y.; //~ ERROR unexpected token
|
||||
LL | let x = y.;
|
||||
| ^ not found in this scope
|
||||
|
||||
error[E0601]: `main` function not found in crate `parser_recovery_1`
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: incorrect close delimiter: `)`
|
|||
--> $DIR/parser-recovery-2.rs:18:5
|
||||
|
|
||||
LL | fn bar() {
|
||||
| - unclosed delimiter
|
||||
| - un-closed delimiter
|
||||
LL | let x = foo(); //~ ERROR cannot find function `foo` in this scope
|
||||
LL | ) //~ ERROR incorrect close delimiter: `)`
|
||||
| ^ incorrect close delimiter
|
||||
|
|
|
|||
32
src/test/ui/parser/unclosed-braces.rs
Normal file
32
src/test/ui/parser/unclosed-braces.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2018 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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct S {
|
||||
x: [usize; 3],
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
{
|
||||
{
|
||||
println!("hi");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
//~^ NOTE un-closed delimiter
|
||||
{
|
||||
{
|
||||
//~^ NOTE this delimiter might not be properly closed...
|
||||
foo();
|
||||
}
|
||||
//~^ NOTE ...as it matches this but it has different indentation
|
||||
}
|
||||
//~ ERROR this file contains an un-closed delimiter
|
||||
17
src/test/ui/parser/unclosed-braces.stderr
Normal file
17
src/test/ui/parser/unclosed-braces.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error: this file contains an un-closed delimiter
|
||||
--> $DIR/unclosed-braces.rs:32:53
|
||||
|
|
||||
LL | fn main() {
|
||||
| - un-closed delimiter
|
||||
...
|
||||
LL | {
|
||||
| - this delimiter might not be properly closed...
|
||||
...
|
||||
LL | }
|
||||
| - ...as it matches this but it has different indentation
|
||||
...
|
||||
LL | //~ ERROR this file contains an un-closed delimiter
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -2,7 +2,7 @@ error: incorrect close delimiter: `)`
|
|||
--> $DIR/token-error-correct-2.rs:16:5
|
||||
|
|
||||
LL | if foo {
|
||||
| - unclosed delimiter
|
||||
| - un-closed delimiter
|
||||
LL | //~^ ERROR: cannot find value `foo`
|
||||
LL | ) //~ ERROR: incorrect close delimiter: `)`
|
||||
| ^ incorrect close delimiter
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error: incorrect close delimiter: `}`
|
||||
--> $DIR/token-error-correct-3.rs:30:9
|
||||
|
|
||||
LL | if !is_directory(path.as_ref()) { //~ ERROR: cannot find function `is_directory`
|
||||
| - close delimiter possibly meant for this
|
||||
LL | callback(path.as_ref(); //~ ERROR expected one of
|
||||
| - unclosed delimiter
|
||||
| - un-closed delimiter
|
||||
...
|
||||
LL | } else { //~ ERROR: incorrect close delimiter: `}`
|
||||
| ^ incorrect close delimiter
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error: incorrect close delimiter: `}`
|
||||
--> $DIR/token-error-correct.rs:16:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| - close delimiter possibly meant for this
|
||||
LL | foo(bar(;
|
||||
| - unclosed delimiter
|
||||
| - un-closed delimiter
|
||||
LL | //~^ ERROR: expected expression, found `;`
|
||||
LL | }
|
||||
| ^ incorrect close delimiter
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error: incorrect close delimiter: `}`
|
||||
--> $DIR/issue-10636-2.rs:18:1
|
||||
|
|
||||
LL | pub fn trace_option(option: Option<isize>) {
|
||||
| - close delimiter possibly meant for this
|
||||
LL | option.map(|some| 42;
|
||||
| - unclosed delimiter
|
||||
| - un-closed delimiter
|
||||
...
|
||||
LL | } //~ ERROR: incorrect close delimiter
|
||||
| ^ incorrect close delimiter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue