From 6871d43d4cd1f7df246958af6c552911ef7a8933 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 31 Dec 2020 07:53:54 +0900 Subject: Move parser-related tests --- src/test/ui/parse-assoc-type-lt.rs | 9 ------- src/test/ui/parse-error-correct.rs | 10 ------- src/test/ui/parse-error-correct.stderr | 33 ----------------------- src/test/ui/parse-panic.rs | 8 ------ src/test/ui/parser-recovery-1.rs | 13 --------- src/test/ui/parser-recovery-1.stderr | 35 ------------------------- src/test/ui/parser-recovery-2.rs | 12 --------- src/test/ui/parser-recovery-2.stderr | 30 --------------------- src/test/ui/parser-unicode-whitespace.rs | 12 --------- src/test/ui/parser/parse-assoc-type-lt.rs | 9 +++++++ src/test/ui/parser/parse-error-correct.rs | 10 +++++++ src/test/ui/parser/parse-error-correct.stderr | 33 +++++++++++++++++++++++ src/test/ui/parser/parse-panic.rs | 8 ++++++ src/test/ui/parser/parser-recovery-1.rs | 13 +++++++++ src/test/ui/parser/parser-recovery-1.stderr | 35 +++++++++++++++++++++++++ src/test/ui/parser/parser-recovery-2.rs | 12 +++++++++ src/test/ui/parser/parser-recovery-2.stderr | 30 +++++++++++++++++++++ src/test/ui/parser/parser-unicode-whitespace.rs | 12 +++++++++ 18 files changed, 162 insertions(+), 162 deletions(-) delete mode 100644 src/test/ui/parse-assoc-type-lt.rs delete mode 100644 src/test/ui/parse-error-correct.rs delete mode 100644 src/test/ui/parse-error-correct.stderr delete mode 100644 src/test/ui/parse-panic.rs delete mode 100644 src/test/ui/parser-recovery-1.rs delete mode 100644 src/test/ui/parser-recovery-1.stderr delete mode 100644 src/test/ui/parser-recovery-2.rs delete mode 100644 src/test/ui/parser-recovery-2.stderr delete mode 100644 src/test/ui/parser-unicode-whitespace.rs create mode 100644 src/test/ui/parser/parse-assoc-type-lt.rs create mode 100644 src/test/ui/parser/parse-error-correct.rs create mode 100644 src/test/ui/parser/parse-error-correct.stderr create mode 100644 src/test/ui/parser/parse-panic.rs create mode 100644 src/test/ui/parser/parser-recovery-1.rs create mode 100644 src/test/ui/parser/parser-recovery-1.stderr create mode 100644 src/test/ui/parser/parser-recovery-2.rs create mode 100644 src/test/ui/parser/parser-recovery-2.stderr create mode 100644 src/test/ui/parser/parser-unicode-whitespace.rs (limited to 'src') diff --git a/src/test/ui/parse-assoc-type-lt.rs b/src/test/ui/parse-assoc-type-lt.rs deleted file mode 100644 index d3fe6079a5d..00000000000 --- a/src/test/ui/parse-assoc-type-lt.rs +++ /dev/null @@ -1,9 +0,0 @@ -// run-pass -// pretty-expanded FIXME #23616 - -trait Foo { - type T; - fn foo() -> Box<::T>; -} - -fn main() {} diff --git a/src/test/ui/parse-error-correct.rs b/src/test/ui/parse-error-correct.rs deleted file mode 100644 index 13759a23519..00000000000 --- a/src/test/ui/parse-error-correct.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Test that the parser is error correcting missing idents. Despite a parsing -// error (or two), we still run type checking (and don't get extra errors there). - -fn main() { - let y = 42; - let x = y.; //~ ERROR unexpected token - let x = y.(); //~ ERROR unexpected token - //~^ ERROR expected function, found `{integer}` - let x = y.foo; //~ ERROR `{integer}` is a primitive type and therefore doesn't have fields [E061 -} diff --git a/src/test/ui/parse-error-correct.stderr b/src/test/ui/parse-error-correct.stderr deleted file mode 100644 index c54baf00b27..00000000000 --- a/src/test/ui/parse-error-correct.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error: unexpected token: `;` - --> $DIR/parse-error-correct.rs:6:15 - | -LL | let x = y.; - | ^ - -error: unexpected token: `(` - --> $DIR/parse-error-correct.rs:7:15 - | -LL | let x = y.(); - | ^ - -error[E0618]: expected function, found `{integer}` - --> $DIR/parse-error-correct.rs:7:13 - | -LL | let y = 42; - | - `{integer}` defined here -LL | let x = y.; -LL | let x = y.(); - | ^--- - | | - | call expression requires function - -error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields - --> $DIR/parse-error-correct.rs:9:15 - | -LL | let x = y.foo; - | ^^^ - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0610, E0618. -For more information about an error, try `rustc --explain E0610`. diff --git a/src/test/ui/parse-panic.rs b/src/test/ui/parse-panic.rs deleted file mode 100644 index aeb2ba4faa5..00000000000 --- a/src/test/ui/parse-panic.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-pass - -#![allow(dead_code)] -#![allow(unreachable_code)] - -fn dont_call_me() { panic!(); println!("{}", 1); } - -pub fn main() { } diff --git a/src/test/ui/parser-recovery-1.rs b/src/test/ui/parser-recovery-1.rs deleted file mode 100644 index 7e26b4f2b6a..00000000000 --- a/src/test/ui/parser-recovery-1.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Test that we can recover from missing braces in the parser. - -trait Foo { - fn bar() { - 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 -} //~ ERROR this file contains an unclosed delimiter diff --git a/src/test/ui/parser-recovery-1.stderr b/src/test/ui/parser-recovery-1.stderr deleted file mode 100644 index f56060c3e35..00000000000 --- a/src/test/ui/parser-recovery-1.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error: this file contains an unclosed delimiter - --> $DIR/parser-recovery-1.rs:13:54 - | -LL | trait Foo { - | - unclosed delimiter -LL | fn bar() { - | - this delimiter might not be properly closed... -... -LL | } - | - ...as it matches this but it has different indentation -... -LL | } - | ^ - -error: unexpected token: `;` - --> $DIR/parser-recovery-1.rs:10:15 - | -LL | let x = y.; - | ^ - -error[E0425]: cannot find function `foo` in this scope - --> $DIR/parser-recovery-1.rs:5:17 - | -LL | let x = foo(); - | ^^^ not found in this scope - -error[E0425]: cannot find value `y` in this scope - --> $DIR/parser-recovery-1.rs:10:13 - | -LL | let x = y.; - | ^ not found in this scope - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/parser-recovery-2.rs b/src/test/ui/parser-recovery-2.rs deleted file mode 100644 index 48b22afffe7..00000000000 --- a/src/test/ui/parser-recovery-2.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Test that we can recover from mismatched braces in the parser. - -trait Foo { - fn bar() { - let x = foo(); //~ ERROR cannot find function `foo` in this scope - ) //~ ERROR mismatched closing delimiter: `)` -} - -fn main() { - let x = y.; //~ ERROR unexpected token - //~^ ERROR cannot find value `y` in this scope -} diff --git a/src/test/ui/parser-recovery-2.stderr b/src/test/ui/parser-recovery-2.stderr deleted file mode 100644 index cd3da4c71f0..00000000000 --- a/src/test/ui/parser-recovery-2.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error: unexpected token: `;` - --> $DIR/parser-recovery-2.rs:10:15 - | -LL | let x = y.; - | ^ - -error: mismatched closing delimiter: `)` - --> $DIR/parser-recovery-2.rs:6:5 - | -LL | fn bar() { - | - unclosed delimiter -LL | let x = foo(); -LL | ) - | ^ mismatched closing delimiter - -error[E0425]: cannot find function `foo` in this scope - --> $DIR/parser-recovery-2.rs:5:17 - | -LL | let x = foo(); - | ^^^ not found in this scope - -error[E0425]: cannot find value `y` in this scope - --> $DIR/parser-recovery-2.rs:10:13 - | -LL | let x = y.; - | ^ not found in this scope - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/parser-unicode-whitespace.rs b/src/test/ui/parser-unicode-whitespace.rs deleted file mode 100644 index 2d1fa7dc42e..00000000000 --- a/src/test/ui/parser-unicode-whitespace.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -// Beware editing: it has numerous whitespace characters which are important. -// It contains one ranges from the 'PATTERN_WHITE_SPACE' property outlined in -// http://unicode.org/Public/UNIDATA/PropList.txt -// -// The characters in the first expression of the assertion can be generated -// from: "4\u{0C}+\n\t\r7\t*\u{20}2\u{85}/\u{200E}3\u{200F}*\u{2028}2\u{2029}" -pub fn main() { -assert_eq!(4 + - -7 * 2…/‎3‏*
2
, 4 + 7 * 2 / 3 * 2); -} diff --git a/src/test/ui/parser/parse-assoc-type-lt.rs b/src/test/ui/parser/parse-assoc-type-lt.rs new file mode 100644 index 00000000000..d3fe6079a5d --- /dev/null +++ b/src/test/ui/parser/parse-assoc-type-lt.rs @@ -0,0 +1,9 @@ +// run-pass +// pretty-expanded FIXME #23616 + +trait Foo { + type T; + fn foo() -> Box<::T>; +} + +fn main() {} diff --git a/src/test/ui/parser/parse-error-correct.rs b/src/test/ui/parser/parse-error-correct.rs new file mode 100644 index 00000000000..13759a23519 --- /dev/null +++ b/src/test/ui/parser/parse-error-correct.rs @@ -0,0 +1,10 @@ +// Test that the parser is error correcting missing idents. Despite a parsing +// error (or two), we still run type checking (and don't get extra errors there). + +fn main() { + let y = 42; + let x = y.; //~ ERROR unexpected token + let x = y.(); //~ ERROR unexpected token + //~^ ERROR expected function, found `{integer}` + let x = y.foo; //~ ERROR `{integer}` is a primitive type and therefore doesn't have fields [E061 +} diff --git a/src/test/ui/parser/parse-error-correct.stderr b/src/test/ui/parser/parse-error-correct.stderr new file mode 100644 index 00000000000..c54baf00b27 --- /dev/null +++ b/src/test/ui/parser/parse-error-correct.stderr @@ -0,0 +1,33 @@ +error: unexpected token: `;` + --> $DIR/parse-error-correct.rs:6:15 + | +LL | let x = y.; + | ^ + +error: unexpected token: `(` + --> $DIR/parse-error-correct.rs:7:15 + | +LL | let x = y.(); + | ^ + +error[E0618]: expected function, found `{integer}` + --> $DIR/parse-error-correct.rs:7:13 + | +LL | let y = 42; + | - `{integer}` defined here +LL | let x = y.; +LL | let x = y.(); + | ^--- + | | + | call expression requires function + +error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields + --> $DIR/parse-error-correct.rs:9:15 + | +LL | let x = y.foo; + | ^^^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0610, E0618. +For more information about an error, try `rustc --explain E0610`. diff --git a/src/test/ui/parser/parse-panic.rs b/src/test/ui/parser/parse-panic.rs new file mode 100644 index 00000000000..aeb2ba4faa5 --- /dev/null +++ b/src/test/ui/parser/parse-panic.rs @@ -0,0 +1,8 @@ +// run-pass + +#![allow(dead_code)] +#![allow(unreachable_code)] + +fn dont_call_me() { panic!(); println!("{}", 1); } + +pub fn main() { } diff --git a/src/test/ui/parser/parser-recovery-1.rs b/src/test/ui/parser/parser-recovery-1.rs new file mode 100644 index 00000000000..7e26b4f2b6a --- /dev/null +++ b/src/test/ui/parser/parser-recovery-1.rs @@ -0,0 +1,13 @@ +// Test that we can recover from missing braces in the parser. + +trait Foo { + fn bar() { + 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 +} //~ ERROR this file contains an unclosed delimiter diff --git a/src/test/ui/parser/parser-recovery-1.stderr b/src/test/ui/parser/parser-recovery-1.stderr new file mode 100644 index 00000000000..f56060c3e35 --- /dev/null +++ b/src/test/ui/parser/parser-recovery-1.stderr @@ -0,0 +1,35 @@ +error: this file contains an unclosed delimiter + --> $DIR/parser-recovery-1.rs:13:54 + | +LL | trait Foo { + | - unclosed delimiter +LL | fn bar() { + | - this delimiter might not be properly closed... +... +LL | } + | - ...as it matches this but it has different indentation +... +LL | } + | ^ + +error: unexpected token: `;` + --> $DIR/parser-recovery-1.rs:10:15 + | +LL | let x = y.; + | ^ + +error[E0425]: cannot find function `foo` in this scope + --> $DIR/parser-recovery-1.rs:5:17 + | +LL | let x = foo(); + | ^^^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/parser-recovery-1.rs:10:13 + | +LL | let x = y.; + | ^ not found in this scope + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/parser/parser-recovery-2.rs b/src/test/ui/parser/parser-recovery-2.rs new file mode 100644 index 00000000000..48b22afffe7 --- /dev/null +++ b/src/test/ui/parser/parser-recovery-2.rs @@ -0,0 +1,12 @@ +// Test that we can recover from mismatched braces in the parser. + +trait Foo { + fn bar() { + let x = foo(); //~ ERROR cannot find function `foo` in this scope + ) //~ ERROR mismatched closing delimiter: `)` +} + +fn main() { + let x = y.; //~ ERROR unexpected token + //~^ ERROR cannot find value `y` in this scope +} diff --git a/src/test/ui/parser/parser-recovery-2.stderr b/src/test/ui/parser/parser-recovery-2.stderr new file mode 100644 index 00000000000..cd3da4c71f0 --- /dev/null +++ b/src/test/ui/parser/parser-recovery-2.stderr @@ -0,0 +1,30 @@ +error: unexpected token: `;` + --> $DIR/parser-recovery-2.rs:10:15 + | +LL | let x = y.; + | ^ + +error: mismatched closing delimiter: `)` + --> $DIR/parser-recovery-2.rs:6:5 + | +LL | fn bar() { + | - unclosed delimiter +LL | let x = foo(); +LL | ) + | ^ mismatched closing delimiter + +error[E0425]: cannot find function `foo` in this scope + --> $DIR/parser-recovery-2.rs:5:17 + | +LL | let x = foo(); + | ^^^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/parser-recovery-2.rs:10:13 + | +LL | let x = y.; + | ^ not found in this scope + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/parser/parser-unicode-whitespace.rs b/src/test/ui/parser/parser-unicode-whitespace.rs new file mode 100644 index 00000000000..2d1fa7dc42e --- /dev/null +++ b/src/test/ui/parser/parser-unicode-whitespace.rs @@ -0,0 +1,12 @@ +// run-pass +// Beware editing: it has numerous whitespace characters which are important. +// It contains one ranges from the 'PATTERN_WHITE_SPACE' property outlined in +// http://unicode.org/Public/UNIDATA/PropList.txt +// +// The characters in the first expression of the assertion can be generated +// from: "4\u{0C}+\n\t\r7\t*\u{20}2\u{85}/\u{200E}3\u{200F}*\u{2028}2\u{2029}" +pub fn main() { +assert_eq!(4 + + +7 * 2…/‎3‏*
2
, 4 + 7 * 2 / 3 * 2); +} -- cgit 1.4.1-3-g733a5