diff options
| author | Caio <c410.f3r@gmail.com> | 2021-02-16 21:22:21 -0300 |
|---|---|---|
| committer | Caio <c410.f3r@gmail.com> | 2021-02-16 21:22:21 -0300 |
| commit | e7e93717ce8e6f5cec217ebfcda2d8c8b76f6b49 (patch) | |
| tree | 95e02203894ab5b08fd6c2d6088c56a65549310c /src/test/ui/parser | |
| parent | 097bc6a84f2280a889b9ab4b544f27851a978927 (diff) | |
| download | rust-e7e93717ce8e6f5cec217ebfcda2d8c8b76f6b49.tar.gz rust-e7e93717ce8e6f5cec217ebfcda2d8c8b76f6b49.zip | |
Move some tests to more reasonable directories
Diffstat (limited to 'src/test/ui/parser')
| -rw-r--r-- | src/test/ui/parser/dotdotdot-expr.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/parser/dotdotdot-expr.stderr | 17 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-20616-3.rs | 35 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-20616-3.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-44406.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-44406.stderr | 25 | ||||
| -rw-r--r-- | src/test/ui/parser/old-suffixes-are-really-forbidden.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/parser/old-suffixes-are-really-forbidden.stderr | 18 | ||||
| -rw-r--r-- | src/test/ui/parser/struct-literal-variant-in-if.rs | 25 | ||||
| -rw-r--r-- | src/test/ui/parser/struct-literal-variant-in-if.stderr | 76 |
10 files changed, 222 insertions, 0 deletions
diff --git a/src/test/ui/parser/dotdotdot-expr.rs b/src/test/ui/parser/dotdotdot-expr.rs new file mode 100644 index 00000000000..d842fb6e030 --- /dev/null +++ b/src/test/ui/parser/dotdotdot-expr.rs @@ -0,0 +1,4 @@ +fn main() { + let _redemptive = 1...21; + //~^ ERROR unexpected token +} diff --git a/src/test/ui/parser/dotdotdot-expr.stderr b/src/test/ui/parser/dotdotdot-expr.stderr new file mode 100644 index 00000000000..ec1335cfdb0 --- /dev/null +++ b/src/test/ui/parser/dotdotdot-expr.stderr @@ -0,0 +1,17 @@ +error: unexpected token: `...` + --> $DIR/dotdotdot-expr.rs:2:24 + | +LL | let _redemptive = 1...21; + | ^^^ + | +help: use `..` for an exclusive range + | +LL | let _redemptive = 1..21; + | ^^ +help: or `..=` for an inclusive range + | +LL | let _redemptive = 1..=21; + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-20616-3.rs b/src/test/ui/parser/issue-20616-3.rs new file mode 100644 index 00000000000..b2371051c78 --- /dev/null +++ b/src/test/ui/parser/issue-20616-3.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +type Type_3<T> = Box<T,,>; +//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected ident, found `,` diff --git a/src/test/ui/parser/issue-20616-3.stderr b/src/test/ui/parser/issue-20616-3.stderr new file mode 100644 index 00000000000..b535c7a3267 --- /dev/null +++ b/src/test/ui/parser/issue-20616-3.stderr @@ -0,0 +1,8 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `,` + --> $DIR/issue-20616-3.rs:13:24 + | +LL | type Type_3<T> = Box<T,,>; + | ^ expected one of `>`, a const expression, lifetime, or type + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-44406.rs b/src/test/ui/parser/issue-44406.rs new file mode 100644 index 00000000000..83bbf884a4f --- /dev/null +++ b/src/test/ui/parser/issue-44406.rs @@ -0,0 +1,10 @@ +macro_rules! foo { + ($rest: tt) => { + bar(baz: $rest) + } +} + +fn main() { + foo!(true); //~ ERROR expected type, found keyword + //~^ ERROR expected identifier, found keyword +} diff --git a/src/test/ui/parser/issue-44406.stderr b/src/test/ui/parser/issue-44406.stderr new file mode 100644 index 00000000000..701c32d6236 --- /dev/null +++ b/src/test/ui/parser/issue-44406.stderr @@ -0,0 +1,25 @@ +error: expected identifier, found keyword `true` + --> $DIR/issue-44406.rs:8:10 + | +LL | foo!(true); + | ^^^^ expected identifier, found keyword + | +help: you can escape reserved keywords to use them as identifiers + | +LL | foo!(r#true); + | ^^^^^^ + +error: expected type, found keyword `true` + --> $DIR/issue-44406.rs:8:10 + | +LL | bar(baz: $rest) + | - help: try using a semicolon: `;` +... +LL | foo!(true); + | ^^^^ expected type + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/old-suffixes-are-really-forbidden.rs b/src/test/ui/parser/old-suffixes-are-really-forbidden.rs new file mode 100644 index 00000000000..eea95b7d626 --- /dev/null +++ b/src/test/ui/parser/old-suffixes-are-really-forbidden.rs @@ -0,0 +1,4 @@ +fn main() { + let a = 1_is; //~ ERROR invalid suffix + let b = 2_us; //~ ERROR invalid suffix +} diff --git a/src/test/ui/parser/old-suffixes-are-really-forbidden.stderr b/src/test/ui/parser/old-suffixes-are-really-forbidden.stderr new file mode 100644 index 00000000000..fb309793b34 --- /dev/null +++ b/src/test/ui/parser/old-suffixes-are-really-forbidden.stderr @@ -0,0 +1,18 @@ +error: invalid suffix `is` for number literal + --> $DIR/old-suffixes-are-really-forbidden.rs:2:13 + | +LL | let a = 1_is; + | ^^^^ invalid suffix `is` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: invalid suffix `us` for number literal + --> $DIR/old-suffixes-are-really-forbidden.rs:3:13 + | +LL | let b = 2_us; + | ^^^^ invalid suffix `us` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/struct-literal-variant-in-if.rs b/src/test/ui/parser/struct-literal-variant-in-if.rs new file mode 100644 index 00000000000..4ef8effaf1f --- /dev/null +++ b/src/test/ui/parser/struct-literal-variant-in-if.rs @@ -0,0 +1,25 @@ +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +enum E { + V { field: bool }, + I { field1: bool, field2: usize }, + J { field: isize }, + K { field: &'static str}, +} +fn test_E(x: E) { + let field = true; + if x == E::V { field } {} + //~^ ERROR expected value, found struct variant `E::V` + //~| ERROR mismatched types + if x == E::I { field1: true, field2: 42 } {} + //~^ ERROR struct literals are not allowed here + if x == E::V { field: false } {} + //~^ ERROR struct literals are not allowed here + if x == E::J { field: -42 } {} + //~^ ERROR struct literals are not allowed here + if x == E::K { field: "" } {} + //~^ ERROR struct literals are not allowed here + let y: usize = (); + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/parser/struct-literal-variant-in-if.stderr b/src/test/ui/parser/struct-literal-variant-in-if.stderr new file mode 100644 index 00000000000..a2252d4e4d2 --- /dev/null +++ b/src/test/ui/parser/struct-literal-variant-in-if.stderr @@ -0,0 +1,76 @@ +error: struct literals are not allowed here + --> $DIR/struct-literal-variant-in-if.rs:13:13 + | +LL | if x == E::I { field1: true, field2: 42 } {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: surround the struct literal with parentheses + | +LL | if x == (E::I { field1: true, field2: 42 }) {} + | ^ ^ + +error: struct literals are not allowed here + --> $DIR/struct-literal-variant-in-if.rs:15:13 + | +LL | if x == E::V { field: false } {} + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: surround the struct literal with parentheses + | +LL | if x == (E::V { field: false }) {} + | ^ ^ + +error: struct literals are not allowed here + --> $DIR/struct-literal-variant-in-if.rs:17:13 + | +LL | if x == E::J { field: -42 } {} + | ^^^^^^^^^^^^^^^^^^^ + | +help: surround the struct literal with parentheses + | +LL | if x == (E::J { field: -42 }) {} + | ^ ^ + +error: struct literals are not allowed here + --> $DIR/struct-literal-variant-in-if.rs:19:13 + | +LL | if x == E::K { field: "" } {} + | ^^^^^^^^^^^^^^^^^^ + | +help: surround the struct literal with parentheses + | +LL | if x == (E::K { field: "" }) {} + | ^ ^ + +error[E0423]: expected value, found struct variant `E::V` + --> $DIR/struct-literal-variant-in-if.rs:10:13 + | +LL | if x == E::V { field } {} + | ^^^^ not a value + | +help: surround the struct literal with parentheses + | +LL | if x == (E::V { field }) {} + | ^ ^ + +error[E0308]: mismatched types + --> $DIR/struct-literal-variant-in-if.rs:10:20 + | +LL | if x == E::V { field } {} + | ---------------^^^^^--- help: consider using a semicolon here + | | | + | | expected `()`, found `bool` + | expected this to be `()` + +error[E0308]: mismatched types + --> $DIR/struct-literal-variant-in-if.rs:21:20 + | +LL | let y: usize = (); + | ----- ^^ expected `usize`, found `()` + | | + | expected due to this + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0308, E0423. +For more information about an error, try `rustc --explain E0308`. |
