diff options
Diffstat (limited to 'src/test/ui/parser')
579 files changed, 8805 insertions, 29 deletions
diff --git a/src/test/ui/parser/ascii-only-character-escape.rs b/src/test/ui/parser/ascii-only-character-escape.rs new file mode 100644 index 00000000000..a8c40225c30 --- /dev/null +++ b/src/test/ui/parser/ascii-only-character-escape.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +fn main() { + let x = "\x80"; //~ ERROR may only be used + let y = "\xff"; //~ ERROR may only be used + let z = "\xe2"; //~ ERROR may only be used + let a = b"\x00e2"; // ok because byte literal +} diff --git a/src/test/ui/parser/ascii-only-character-escape.stderr b/src/test/ui/parser/ascii-only-character-escape.stderr new file mode 100644 index 00000000000..e09db780880 --- /dev/null +++ b/src/test/ui/parser/ascii-only-character-escape.stderr @@ -0,0 +1,20 @@ +error: this form of character escape may only be used with characters in the range [/x00-/x7f] + --> $DIR/ascii-only-character-escape.rs:14:16 + | +LL | let x = "/x80"; //~ ERROR may only be used + | ^^ + +error: this form of character escape may only be used with characters in the range [/x00-/x7f] + --> $DIR/ascii-only-character-escape.rs:15:16 + | +LL | let y = "/xff"; //~ ERROR may only be used + | ^^ + +error: this form of character escape may only be used with characters in the range [/x00-/x7f] + --> $DIR/ascii-only-character-escape.rs:16:16 + | +LL | let z = "/xe2"; //~ ERROR may only be used + | ^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/parser/assoc-oddities-1.rs b/src/test/ui/parser/assoc-oddities-1.rs new file mode 100644 index 00000000000..63408b76b15 --- /dev/null +++ b/src/test/ui/parser/assoc-oddities-1.rs @@ -0,0 +1,21 @@ +// Copyright 2015 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 that_odd_parse() { + // following lines below parse and must not fail + x = if c { a } else { b }(); + x = if true { 1 } else { 0 } as *mut _; + // however this does not parse and probably should fail to retain compat? + // NB: `..` here is arbitrary, failure happens/should happen ∀ops that aren’t `=` + // see assoc-oddities-2 and assoc-oddities-3 + ..if c { a } else { b }[n]; //~ ERROR expected one of +} diff --git a/src/test/ui/parser/assoc-oddities-1.stderr b/src/test/ui/parser/assoc-oddities-1.stderr new file mode 100644 index 00000000000..2d39546dca8 --- /dev/null +++ b/src/test/ui/parser/assoc-oddities-1.stderr @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or `}`, found `[` + --> $DIR/assoc-oddities-1.rs:20:28 + | +LL | ..if c { a } else { b }[n]; //~ ERROR expected one of + | ^ expected one of `.`, `;`, `?`, or `}` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/assoc-oddities-2.rs b/src/test/ui/parser/assoc-oddities-2.rs new file mode 100644 index 00000000000..5679328edc9 --- /dev/null +++ b/src/test/ui/parser/assoc-oddities-2.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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 that_odd_parse() { + // see assoc-oddities-1 for explanation + x..if c { a } else { b }[n]; //~ ERROR expected one of +} diff --git a/src/test/ui/parser/assoc-oddities-2.stderr b/src/test/ui/parser/assoc-oddities-2.stderr new file mode 100644 index 00000000000..878ef682747 --- /dev/null +++ b/src/test/ui/parser/assoc-oddities-2.stderr @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or `}`, found `[` + --> $DIR/assoc-oddities-2.rs:15:29 + | +LL | x..if c { a } else { b }[n]; //~ ERROR expected one of + | ^ expected one of `.`, `;`, `?`, or `}` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/associated-types-project-from-hrtb-explicit.rs b/src/test/ui/parser/associated-types-project-from-hrtb-explicit.rs new file mode 100644 index 00000000000..70055a10181 --- /dev/null +++ b/src/test/ui/parser/associated-types-project-from-hrtb-explicit.rs @@ -0,0 +1,28 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +// Test you can't use a higher-ranked trait bound inside of a qualified +// path (just won't parse). + +pub trait Foo<T> { + type A; + + fn get(&self, t: T) -> Self::A; +} + +fn foo2<I>(x: <I as for<'x> Foo<&'x isize>>::A) + //~^ ERROR expected identifier, found keyword `for` + //~| ERROR expected one of `::` or `>` +{ +} + +pub fn main() {} diff --git a/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr b/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr new file mode 100644 index 00000000000..59b378c2088 --- /dev/null +++ b/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr @@ -0,0 +1,14 @@ +error: expected identifier, found keyword `for` + --> $DIR/associated-types-project-from-hrtb-explicit.rs:22:21 + | +LL | fn foo2<I>(x: <I as for<'x> Foo<&'x isize>>::A) + | ^^^ expected identifier, found keyword + +error: expected one of `::` or `>`, found `Foo` + --> $DIR/associated-types-project-from-hrtb-explicit.rs:22:29 + | +LL | fn foo2<I>(x: <I as for<'x> Foo<&'x isize>>::A) + | ^^^ expected one of `::` or `>` here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/attr-bad-meta-2.rs b/src/test/ui/parser/attr-bad-meta-2.rs new file mode 100644 index 00000000000..121a0d8eba2 --- /dev/null +++ b/src/test/ui/parser/attr-bad-meta-2.rs @@ -0,0 +1,14 @@ +// 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. + +// compile-flags: -Z parse-only + +#[path =] //~ ERROR unexpected token: `]` +mod m {} diff --git a/src/test/ui/parser/attr-bad-meta-2.stderr b/src/test/ui/parser/attr-bad-meta-2.stderr new file mode 100644 index 00000000000..b869331ca5a --- /dev/null +++ b/src/test/ui/parser/attr-bad-meta-2.stderr @@ -0,0 +1,8 @@ +error: unexpected token: `]` + --> $DIR/attr-bad-meta-2.rs:13:9 + | +LL | #[path =] //~ ERROR unexpected token: `]` + | ^ unexpected token after this + +error: aborting due to previous error + diff --git a/src/test/ui/parser/attr-bad-meta-3.rs b/src/test/ui/parser/attr-bad-meta-3.rs new file mode 100644 index 00000000000..e0558443a36 --- /dev/null +++ b/src/test/ui/parser/attr-bad-meta-3.rs @@ -0,0 +1,14 @@ +// 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. + +// compile-flags: -Z parse-only + +#[path() token] //~ ERROR expected `]`, found `token` +mod m {} diff --git a/src/test/ui/parser/attr-bad-meta-3.stderr b/src/test/ui/parser/attr-bad-meta-3.stderr new file mode 100644 index 00000000000..bef2f423ab9 --- /dev/null +++ b/src/test/ui/parser/attr-bad-meta-3.stderr @@ -0,0 +1,8 @@ +error: expected `]`, found `token` + --> $DIR/attr-bad-meta-3.rs:13:10 + | +LL | #[path() token] //~ ERROR expected `]`, found `token` + | ^^^^^ expected `]` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/attr-bad-meta.rs b/src/test/ui/parser/attr-bad-meta.rs new file mode 100644 index 00000000000..cf9c3f9a35f --- /dev/null +++ b/src/test/ui/parser/attr-bad-meta.rs @@ -0,0 +1,16 @@ +// 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 + +#![feature(unrestricted_attribute_tokens)] + +#[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` +mod m {} diff --git a/src/test/ui/parser/attr-bad-meta.stderr b/src/test/ui/parser/attr-bad-meta.stderr new file mode 100644 index 00000000000..d19fe25bad8 --- /dev/null +++ b/src/test/ui/parser/attr-bad-meta.stderr @@ -0,0 +1,8 @@ +error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` + --> $DIR/attr-bad-meta.rs:15:7 + | +LL | #[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` + | ^ expected one of `(`, `::`, `=`, `[`, `]`, or `{` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/attr-before-eof.rs b/src/test/ui/parser/attr-before-eof.rs new file mode 100644 index 00000000000..c75b0ac122a --- /dev/null +++ b/src/test/ui/parser/attr-before-eof.rs @@ -0,0 +1,13 @@ +// 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 + +#[derive(Debug)] //~ERROR expected item after attributes diff --git a/src/test/ui/parser/attr-before-eof.stderr b/src/test/ui/parser/attr-before-eof.stderr new file mode 100644 index 00000000000..e96b9c4cc3d --- /dev/null +++ b/src/test/ui/parser/attr-before-eof.stderr @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/attr-before-eof.rs:13:16 + | +LL | #[derive(Debug)] //~ERROR expected item after attributes + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/attr-dangling-in-fn.rs b/src/test/ui/parser/attr-dangling-in-fn.rs new file mode 100644 index 00000000000..7b731b6d6de --- /dev/null +++ b/src/test/ui/parser/attr-dangling-in-fn.rs @@ -0,0 +1,20 @@ +// 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 + +// error-pattern:expected statement + +fn f() { + #[foo = "bar"] +} + +fn main() { +} diff --git a/src/test/ui/parser/attr-dangling-in-fn.stderr b/src/test/ui/parser/attr-dangling-in-fn.stderr new file mode 100644 index 00000000000..0f530a2d402 --- /dev/null +++ b/src/test/ui/parser/attr-dangling-in-fn.stderr @@ -0,0 +1,8 @@ +error: expected statement after outer attribute + --> $DIR/attr-dangling-in-fn.rs:17:1 + | +LL | } + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/attr-dangling-in-mod.rs b/src/test/ui/parser/attr-dangling-in-mod.rs new file mode 100644 index 00000000000..79609935f9e --- /dev/null +++ b/src/test/ui/parser/attr-dangling-in-mod.rs @@ -0,0 +1,18 @@ +// 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 + +// error-pattern:expected item + +fn main() { +} + +#[foo = "bar"] diff --git a/src/test/ui/parser/attr-dangling-in-mod.stderr b/src/test/ui/parser/attr-dangling-in-mod.stderr new file mode 100644 index 00000000000..1105e06f93c --- /dev/null +++ b/src/test/ui/parser/attr-dangling-in-mod.stderr @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/attr-dangling-in-mod.rs:18:14 + | +LL | #[foo = "bar"] + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/attr.rs b/src/test/ui/parser/attr.rs new file mode 100644 index 00000000000..1f0a95826fc --- /dev/null +++ b/src/test/ui/parser/attr.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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 + +#![feature(lang_items)] + +fn main() {} + +#![lang(foo)] //~ ERROR an inner attribute is not permitted in this context +fn foo() {} diff --git a/src/test/ui/parser/attr.stderr b/src/test/ui/parser/attr.stderr new file mode 100644 index 00000000000..a977847679a --- /dev/null +++ b/src/test/ui/parser/attr.stderr @@ -0,0 +1,10 @@ +error: an inner attribute is not permitted in this context + --> $DIR/attr.rs:17:3 + | +LL | #![lang(foo)] //~ ERROR an inner attribute is not permitted in this context + | ^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. + +error: aborting due to previous error + diff --git a/src/test/ui/parser/attrs-after-extern-mod.rs b/src/test/ui/parser/attrs-after-extern-mod.rs new file mode 100644 index 00000000000..442eb14116e --- /dev/null +++ b/src/test/ui/parser/attrs-after-extern-mod.rs @@ -0,0 +1,25 @@ +// 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 <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 + +// Constants (static variables) can be used to match in patterns, but mutable +// statics cannot. This ensures that there's some form of error if this is +// attempted. + +extern crate libc; + +extern { + static mut rust_dbg_static_mut: libc::c_int; + pub fn rust_dbg_static_mut_check_four(); + #[cfg(stage37)] //~ ERROR expected item after attributes +} + +pub fn main() {} diff --git a/src/test/ui/parser/attrs-after-extern-mod.stderr b/src/test/ui/parser/attrs-after-extern-mod.stderr new file mode 100644 index 00000000000..70a7afc9060 --- /dev/null +++ b/src/test/ui/parser/attrs-after-extern-mod.stderr @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/attrs-after-extern-mod.rs:22:19 + | +LL | #[cfg(stage37)] //~ ERROR expected item after attributes + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bad-char-literals.rs b/src/test/ui/parser/bad-char-literals.rs new file mode 100644 index 00000000000..821015ece77 --- /dev/null +++ b/src/test/ui/parser/bad-char-literals.rs @@ -0,0 +1,31 @@ +// 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 <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 -Z continue-parse-after-error + +// ignore-tidy-cr +// ignore-tidy-tab +fn main() { + // these literals are just silly. + '''; + //~^ ERROR: character constant must be escaped: ' + + // note that this is a literal "\n" byte + ' +'; + //~^^ ERROR: character constant must be escaped: \n + + // note that this is a literal "\r" byte + ' '; //~ ERROR: character constant must be escaped: \r + + // note that this is a literal tab character here + ' '; + //~^ ERROR: character constant must be escaped: \t +} diff --git a/src/test/ui/parser/bad-char-literals.stderr b/src/test/ui/parser/bad-char-literals.stderr new file mode 100644 index 00000000000..40f96655170 --- /dev/null +++ b/src/test/ui/parser/bad-char-literals.stderr @@ -0,0 +1,28 @@ +error: character constant must be escaped: ' + --> $DIR/bad-char-literals.rs:17:6 + | +LL | '''; + | ^ + +error: character constant must be escaped: /n + --> $DIR/bad-char-literals.rs:21:6 + | +LL | ' + | ______^ +LL | | '; + | |_ + +error: character constant must be escaped: /r + --> $DIR/bad-char-literals.rs:26:6 + | +LL | ' '; //~ ERROR: character constant must be escaped: /r + | ^ + +error: character constant must be escaped: /t + --> $DIR/bad-char-literals.rs:29:6 + | +LL | ' '; + | ^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/parser/bad-lit-suffixes.rs b/src/test/ui/parser/bad-lit-suffixes.rs new file mode 100644 index 00000000000..0811a647024 --- /dev/null +++ b/src/test/ui/parser/bad-lit-suffixes.rs @@ -0,0 +1,39 @@ +// Copyright 2014 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 -Z continue-parse-after-error + + +extern + "C"suffix //~ ERROR ABI spec with a suffix is invalid + fn foo() {} + +extern + "C"suffix //~ ERROR ABI spec with a suffix is invalid +{} + +fn main() { + ""suffix; //~ ERROR string literal with a suffix is invalid + b""suffix; //~ ERROR byte string literal with a suffix is invalid + r#""#suffix; //~ ERROR string literal with a suffix is invalid + br#""#suffix; //~ ERROR byte string literal with a suffix is invalid + 'a'suffix; //~ ERROR char literal with a suffix is invalid + b'a'suffix; //~ ERROR byte literal with a suffix is invalid + + 1234u1024; //~ ERROR invalid width `1024` for integer literal + 1234i1024; //~ ERROR invalid width `1024` for integer literal + 1234f1024; //~ ERROR invalid width `1024` for float literal + 1234.5f1024; //~ ERROR invalid width `1024` for float literal + + 1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal + 0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal + 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal + 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal +} diff --git a/src/test/ui/parser/bad-lit-suffixes.stderr b/src/test/ui/parser/bad-lit-suffixes.stderr new file mode 100644 index 00000000000..bc15c329526 --- /dev/null +++ b/src/test/ui/parser/bad-lit-suffixes.stderr @@ -0,0 +1,114 @@ +error: ABI spec with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:15:5 + | +LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid + | ^^^^^^^^^ + +error: ABI spec with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:19:5 + | +LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid + | ^^^^^^^^^ + +error: string literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:23:5 + | +LL | ""suffix; //~ ERROR string literal with a suffix is invalid + | ^^^^^^^^ + +error: byte string literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:24:5 + | +LL | b""suffix; //~ ERROR byte string literal with a suffix is invalid + | ^^^^^^^^^ + +error: string literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:25:5 + | +LL | r#""#suffix; //~ ERROR string literal with a suffix is invalid + | ^^^^^^^^^^^ + +error: byte string literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:26:5 + | +LL | br#""#suffix; //~ ERROR byte string literal with a suffix is invalid + | ^^^^^^^^^^^^ + +error: char literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:27:5 + | +LL | 'a'suffix; //~ ERROR char literal with a suffix is invalid + | ^^^^^^^^^ + +error: byte literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:28:5 + | +LL | b'a'suffix; //~ ERROR byte literal with a suffix is invalid + | ^^^^^^^^^^ + +error: invalid width `1024` for integer literal + --> $DIR/bad-lit-suffixes.rs:30:5 + | +LL | 1234u1024; //~ ERROR invalid width `1024` for integer literal + | ^^^^^^^^^ + | + = help: valid widths are 8, 16, 32, 64 and 128 + +error: invalid width `1024` for integer literal + --> $DIR/bad-lit-suffixes.rs:31:5 + | +LL | 1234i1024; //~ ERROR invalid width `1024` for integer literal + | ^^^^^^^^^ + | + = help: valid widths are 8, 16, 32, 64 and 128 + +error: invalid width `1024` for float literal + --> $DIR/bad-lit-suffixes.rs:32:5 + | +LL | 1234f1024; //~ ERROR invalid width `1024` for float literal + | ^^^^^^^^^ + | + = help: valid widths are 32 and 64 + +error: invalid width `1024` for float literal + --> $DIR/bad-lit-suffixes.rs:33:5 + | +LL | 1234.5f1024; //~ ERROR invalid width `1024` for float literal + | ^^^^^^^^^^^ + | + = help: valid widths are 32 and 64 + +error: invalid suffix `suffix` for numeric literal + --> $DIR/bad-lit-suffixes.rs:35:5 + | +LL | 1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal + | ^^^^^^^^^^ + | + = help: the suffix must be one of the integral types (`u32`, `isize`, etc) + +error: invalid suffix `suffix` for numeric literal + --> $DIR/bad-lit-suffixes.rs:36:5 + | +LL | 0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal + | ^^^^^^^^^^^ + | + = help: the suffix must be one of the integral types (`u32`, `isize`, etc) + +error: invalid suffix `suffix` for float literal + --> $DIR/bad-lit-suffixes.rs:37:5 + | +LL | 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal + | ^^^^^^^^^ + | + = help: valid suffixes are `f32` and `f64` + +error: invalid suffix `suffix` for float literal + --> $DIR/bad-lit-suffixes.rs:38:5 + | +LL | 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal + | ^^^^^^^^^^^^ + | + = help: valid suffixes are `f32` and `f64` + +error: aborting due to 16 previous errors + diff --git a/src/test/ui/parser/bad-match.rs b/src/test/ui/parser/bad-match.rs new file mode 100644 index 00000000000..b42c04f3ce2 --- /dev/null +++ b/src/test/ui/parser/bad-match.rs @@ -0,0 +1,21 @@ +// Copyright 2014 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 + +// error-pattern: expected + +fn main() { + let isize x = 5; + match x; +} + +fn main() { +} diff --git a/src/test/ui/parser/bad-match.stderr b/src/test/ui/parser/bad-match.stderr new file mode 100644 index 00000000000..7927a3d6138 --- /dev/null +++ b/src/test/ui/parser/bad-match.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `x` + --> $DIR/bad-match.rs:16:13 + | +LL | let isize x = 5; + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bad-name.rs b/src/test/ui/parser/bad-name.rs new file mode 100644 index 00000000000..201e6ced2f9 --- /dev/null +++ b/src/test/ui/parser/bad-name.rs @@ -0,0 +1,17 @@ +// 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 + +// error-pattern: expected + +fn main() { + let x.y::<isize>.z foo; +} diff --git a/src/test/ui/parser/bad-name.stderr b/src/test/ui/parser/bad-name.stderr new file mode 100644 index 00000000000..c4ab3e18c9b --- /dev/null +++ b/src/test/ui/parser/bad-name.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `.` + --> $DIR/bad-name.rs:16:8 + | +LL | let x.y::<isize>.z foo; + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bad-pointer-type.rs b/src/test/ui/parser/bad-pointer-type.rs new file mode 100644 index 00000000000..cdb4d16fed2 --- /dev/null +++ b/src/test/ui/parser/bad-pointer-type.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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(_: *()) { + //~^ expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate) +} diff --git a/src/test/ui/parser/bad-pointer-type.stderr b/src/test/ui/parser/bad-pointer-type.stderr new file mode 100644 index 00000000000..d41bbb3475b --- /dev/null +++ b/src/test/ui/parser/bad-pointer-type.stderr @@ -0,0 +1,8 @@ +error: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate) + --> $DIR/bad-pointer-type.rs:13:11 + | +LL | fn foo(_: *()) { + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bad-value-ident-false.rs b/src/test/ui/parser/bad-value-ident-false.rs new file mode 100644 index 00000000000..96325a2abb4 --- /dev/null +++ b/src/test/ui/parser/bad-value-ident-false.rs @@ -0,0 +1,14 @@ +// 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 false() { } //~ ERROR expected identifier, found keyword `false` +fn main() { } diff --git a/src/test/ui/parser/bad-value-ident-false.stderr b/src/test/ui/parser/bad-value-ident-false.stderr new file mode 100644 index 00000000000..ac5fe784a9a --- /dev/null +++ b/src/test/ui/parser/bad-value-ident-false.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found keyword `false` + --> $DIR/bad-value-ident-false.rs:13:4 + | +LL | fn false() { } //~ ERROR expected identifier, found keyword `false` + | ^^^^^ expected identifier, found keyword + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bad-value-ident-true.rs b/src/test/ui/parser/bad-value-ident-true.rs new file mode 100644 index 00000000000..7ff16b80373 --- /dev/null +++ b/src/test/ui/parser/bad-value-ident-true.rs @@ -0,0 +1,14 @@ +// 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 true() { } //~ ERROR expected identifier, found keyword `true` +fn main() { } diff --git a/src/test/ui/parser/bad-value-ident-true.stderr b/src/test/ui/parser/bad-value-ident-true.stderr new file mode 100644 index 00000000000..34d02374d57 --- /dev/null +++ b/src/test/ui/parser/bad-value-ident-true.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found keyword `true` + --> $DIR/bad-value-ident-true.rs:13:4 + | +LL | fn true() { } //~ ERROR expected identifier, found keyword `true` + | ^^^^ expected identifier, found keyword + +error: aborting due to previous error + diff --git a/src/test/ui/parser/better-expected.rs b/src/test/ui/parser/better-expected.rs new file mode 100644 index 00000000000..b60201c251d --- /dev/null +++ b/src/test/ui/parser/better-expected.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 main() { + let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` +} diff --git a/src/test/ui/parser/better-expected.stderr b/src/test/ui/parser/better-expected.stderr new file mode 100644 index 00000000000..028858c34e9 --- /dev/null +++ b/src/test/ui/parser/better-expected.stderr @@ -0,0 +1,10 @@ +error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` + --> $DIR/better-expected.rs:14:19 + | +LL | let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` + | - ^ expected one of 7 possible tokens here + | | + | while parsing the type for `x` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bind-struct-early-modifiers.rs b/src/test/ui/parser/bind-struct-early-modifiers.rs new file mode 100644 index 00000000000..e9e76af11a5 --- /dev/null +++ b/src/test/ui/parser/bind-struct-early-modifiers.rs @@ -0,0 +1,19 @@ +// 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 <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 main() { + struct Foo { x: isize } + match (Foo { x: 10 }) { + Foo { ref x: ref x } => {}, //~ ERROR expected `,` + _ => {} + } +} diff --git a/src/test/ui/parser/bind-struct-early-modifiers.stderr b/src/test/ui/parser/bind-struct-early-modifiers.stderr new file mode 100644 index 00000000000..14ff1b73767 --- /dev/null +++ b/src/test/ui/parser/bind-struct-early-modifiers.stderr @@ -0,0 +1,8 @@ +error: expected `,` + --> $DIR/bind-struct-early-modifiers.rs:16:19 + | +LL | Foo { ref x: ref x } => {}, //~ ERROR expected `,` + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bound-single-question-mark.rs b/src/test/ui/parser/bound-single-question-mark.rs new file mode 100644 index 00000000000..9dde5268c08 --- /dev/null +++ b/src/test/ui/parser/bound-single-question-mark.rs @@ -0,0 +1,13 @@ +// Copyright 2017 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 f<T: ?>() {} //~ ERROR expected identifier, found `>` diff --git a/src/test/ui/parser/bound-single-question-mark.stderr b/src/test/ui/parser/bound-single-question-mark.stderr new file mode 100644 index 00000000000..e3522cef8d4 --- /dev/null +++ b/src/test/ui/parser/bound-single-question-mark.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `>` + --> $DIR/bound-single-question-mark.rs:13:10 + | +LL | fn f<T: ?>() {} //~ ERROR expected identifier, found `>` + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bounds-lifetime-1.rs b/src/test/ui/parser/bounds-lifetime-1.rs new file mode 100644 index 00000000000..824d243d5f8 --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime-1.rs @@ -0,0 +1,15 @@ +// Copyright 2017 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 + +type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b` + +fn main() {} diff --git a/src/test/ui/parser/bounds-lifetime-1.stderr b/src/test/ui/parser/bounds-lifetime-1.stderr new file mode 100644 index 00000000000..910092fba40 --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime-1.stderr @@ -0,0 +1,8 @@ +error: expected one of `,`, `:`, or `>`, found `'b` + --> $DIR/bounds-lifetime-1.rs:13:17 + | +LL | type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b` + | ^^ expected one of `,`, `:`, or `>` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bounds-lifetime-2.rs b/src/test/ui/parser/bounds-lifetime-2.rs new file mode 100644 index 00000000000..3c67dda70f5 --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime-2.rs @@ -0,0 +1,15 @@ +// Copyright 2017 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 + +type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+` + +fn main() {} diff --git a/src/test/ui/parser/bounds-lifetime-2.stderr b/src/test/ui/parser/bounds-lifetime-2.stderr new file mode 100644 index 00000000000..b84f5e6990a --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime-2.stderr @@ -0,0 +1,8 @@ +error: expected one of `,`, `:`, or `>`, found `+` + --> $DIR/bounds-lifetime-2.rs:13:17 + | +LL | type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+` + | ^ expected one of `,`, `:`, or `>` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bounds-lifetime-where-1.rs b/src/test/ui/parser/bounds-lifetime-where-1.rs new file mode 100644 index 00000000000..aae9d729987 --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime-where-1.rs @@ -0,0 +1,15 @@ +// Copyright 2017 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 + +type A where 'a; //~ ERROR expected `:`, found `;` + +fn main() {} diff --git a/src/test/ui/parser/bounds-lifetime-where-1.stderr b/src/test/ui/parser/bounds-lifetime-where-1.stderr new file mode 100644 index 00000000000..5bcb8962e0f --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime-where-1.stderr @@ -0,0 +1,8 @@ +error: expected `:`, found `;` + --> $DIR/bounds-lifetime-where-1.rs:13:16 + | +LL | type A where 'a; //~ ERROR expected `:`, found `;` + | ^ expected `:` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bounds-lifetime-where.rs b/src/test/ui/parser/bounds-lifetime-where.rs new file mode 100644 index 00000000000..0a30818bc96 --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime-where.rs @@ -0,0 +1,22 @@ +// Copyright 2017 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 + +type A where 'a: 'b + 'c = u8; // OK +type A where 'a: 'b, = u8; // OK +type A where 'a: = u8; // OK +type A where 'a:, = u8; // OK +type A where 'a: 'b + 'c = u8; // OK +type A where = u8; // OK +type A where 'a: 'b + = u8; // OK +type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,` + +fn main() {} diff --git a/src/test/ui/parser/bounds-lifetime-where.stderr b/src/test/ui/parser/bounds-lifetime-where.stderr new file mode 100644 index 00000000000..ef4ba9499c3 --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime-where.stderr @@ -0,0 +1,8 @@ +error: expected one of `=`, lifetime, or type, found `,` + --> $DIR/bounds-lifetime-where.rs:20:14 + | +LL | type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,` + | ^ expected one of `=`, lifetime, or type here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bounds-lifetime.rs b/src/test/ui/parser/bounds-lifetime.rs new file mode 100644 index 00000000000..88db205310c --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime.rs @@ -0,0 +1,23 @@ +// Copyright 2017 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 + +type A = for<'a:> fn(); // OK +type A = for<'a:,> fn(); // OK +type A = for<'a> fn(); // OK +type A = for<> fn(); // OK +type A = for<'a: 'b + 'c> fn(); // OK (rejected later by ast_validation) +type A = for<'a: 'b,> fn(); // OK(rejected later by ast_validation) +type A = for<'a: 'b +> fn(); // OK (rejected later by ast_validation) +type A = for<'a, T> fn(); // OK (rejected later by ast_validation) +type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,` + +fn main() {} diff --git a/src/test/ui/parser/bounds-lifetime.stderr b/src/test/ui/parser/bounds-lifetime.stderr new file mode 100644 index 00000000000..2850af5193a --- /dev/null +++ b/src/test/ui/parser/bounds-lifetime.stderr @@ -0,0 +1,8 @@ +error: expected one of `>`, identifier, or lifetime, found `,` + --> $DIR/bounds-lifetime.rs:21:14 + | +LL | type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,` + | ^ expected one of `>`, identifier, or lifetime here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bounds-obj-parens.rs b/src/test/ui/parser/bounds-obj-parens.rs new file mode 100644 index 00000000000..7b47bbd951e --- /dev/null +++ b/src/test/ui/parser/bounds-obj-parens.rs @@ -0,0 +1,14 @@ +// Copyright 2017 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-pass +// compile-flags: -Z parse-only + +type A = Box<(Fn(D::Error) -> E) + 'static + Send + Sync>; // OK (but see #39318) diff --git a/src/test/ui/parser/bounds-type-where.rs b/src/test/ui/parser/bounds-type-where.rs new file mode 100644 index 00000000000..9dc5d827744 --- /dev/null +++ b/src/test/ui/parser/bounds-type-where.rs @@ -0,0 +1,23 @@ +// Copyright 2017 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 + +type A where for<'a> for<'b> Trait1 + ?Trait2: 'a + Trait = u8; // OK +type A where T: Trait, = u8; // OK +type A where T: = u8; // OK +type A where T:, = u8; // OK +type A where T: Trait + Trait = u8; // OK +type A where = u8; // OK +type A where T: Trait + = u8; // OK +type A where T, = u8; +//~^ ERROR expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,` + +fn main() {} diff --git a/src/test/ui/parser/bounds-type-where.stderr b/src/test/ui/parser/bounds-type-where.stderr new file mode 100644 index 00000000000..b6a184f54fc --- /dev/null +++ b/src/test/ui/parser/bounds-type-where.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,` + --> $DIR/bounds-type-where.rs:20:15 + | +LL | type A where T, = u8; + | ^ expected one of 8 possible tokens here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/bounds-type.rs b/src/test/ui/parser/bounds-type.rs new file mode 100644 index 00000000000..0ebe7fde0a6 --- /dev/null +++ b/src/test/ui/parser/bounds-type.rs @@ -0,0 +1,23 @@ +// Copyright 2017 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 -Z continue-parse-after-error + +struct S< + T: 'a + Tr, // OK + T: Tr + 'a, // OK + T: 'a, // OK + T:, // OK + T: ?for<'a> Trait, // OK + T: Tr +, // OK + T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds +>; + +fn main() {} diff --git a/src/test/ui/parser/bounds-type.stderr b/src/test/ui/parser/bounds-type.stderr new file mode 100644 index 00000000000..c4c3d2ae065 --- /dev/null +++ b/src/test/ui/parser/bounds-type.stderr @@ -0,0 +1,8 @@ +error: `?` may only modify trait bounds, not lifetime bounds + --> $DIR/bounds-type.rs:20:8 + | +LL | T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/brace-after-qualified-path-in-match.rs b/src/test/ui/parser/brace-after-qualified-path-in-match.rs new file mode 100644 index 00000000000..ff434d87e1f --- /dev/null +++ b/src/test/ui/parser/brace-after-qualified-path-in-match.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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() { + match x { + <T as Trait>::Type{key: value} => (), + //~^ ERROR unexpected `{` after qualified path + _ => (), + } +} diff --git a/src/test/ui/parser/brace-after-qualified-path-in-match.stderr b/src/test/ui/parser/brace-after-qualified-path-in-match.stderr new file mode 100644 index 00000000000..c66b3ed75e8 --- /dev/null +++ b/src/test/ui/parser/brace-after-qualified-path-in-match.stderr @@ -0,0 +1,8 @@ +error: unexpected `{` after qualified path + --> $DIR/brace-after-qualified-path-in-match.rs:15:27 + | +LL | <T as Trait>::Type{key: value} => (), + | ^ unexpected `{` after qualified path + +error: aborting due to previous error + diff --git a/src/test/ui/parser/byte-literals.rs b/src/test/ui/parser/byte-literals.rs new file mode 100644 index 00000000000..3ecd7780afd --- /dev/null +++ b/src/test/ui/parser/byte-literals.rs @@ -0,0 +1,25 @@ +// Copyright 2014 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 -Z continue-parse-after-error + + +// ignore-tidy-tab + +static FOO: u8 = b'\f'; //~ ERROR unknown byte escape + +pub fn main() { + b'\f'; //~ ERROR unknown byte escape + b'\x0Z'; //~ ERROR invalid character in numeric character escape: Z + b' '; //~ ERROR byte constant must be escaped + b'''; //~ ERROR byte constant must be escaped + b'é'; //~ ERROR byte constant must be ASCII + b'a //~ ERROR unterminated byte constant +} diff --git a/src/test/ui/parser/byte-literals.stderr b/src/test/ui/parser/byte-literals.stderr new file mode 100644 index 00000000000..7b4f22134c4 --- /dev/null +++ b/src/test/ui/parser/byte-literals.stderr @@ -0,0 +1,44 @@ +error: unknown byte escape: f + --> $DIR/byte-literals.rs:16:21 + | +LL | static FOO: u8 = b'/f'; //~ ERROR unknown byte escape + | ^ + +error: unknown byte escape: f + --> $DIR/byte-literals.rs:19:8 + | +LL | b'/f'; //~ ERROR unknown byte escape + | ^ + +error: invalid character in numeric character escape: Z + --> $DIR/byte-literals.rs:20:10 + | +LL | b'/x0Z'; //~ ERROR invalid character in numeric character escape: Z + | ^ + +error: byte constant must be escaped: /t + --> $DIR/byte-literals.rs:21:7 + | +LL | b' '; //~ ERROR byte constant must be escaped + | ^^^^ + +error: byte constant must be escaped: ' + --> $DIR/byte-literals.rs:22:7 + | +LL | b'''; //~ ERROR byte constant must be escaped + | ^ + +error: byte constant must be ASCII. Use a /xHH escape for a non-ASCII byte + --> $DIR/byte-literals.rs:23:7 + | +LL | b'é'; //~ ERROR byte constant must be ASCII + | ^ + +error: unterminated byte constant: b'a + --> $DIR/byte-literals.rs:24:5 + | +LL | b'a //~ ERROR unterminated byte constant + | ^^^ + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/parser/byte-string-literals.rs b/src/test/ui/parser/byte-string-literals.rs new file mode 100644 index 00000000000..4eba9e91ca5 --- /dev/null +++ b/src/test/ui/parser/byte-string-literals.rs @@ -0,0 +1,23 @@ +// Copyright 2014 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 -Z continue-parse-after-error + + +// ignore-tidy-tab + +static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape + +pub fn main() { + b"\f"; //~ ERROR unknown byte escape + b"\x0Z"; //~ ERROR invalid character in numeric character escape: Z + b"é"; //~ ERROR byte constant must be ASCII + b"a //~ ERROR unterminated double quote byte string +} diff --git a/src/test/ui/parser/byte-string-literals.stderr b/src/test/ui/parser/byte-string-literals.stderr new file mode 100644 index 00000000000..856d1956c05 --- /dev/null +++ b/src/test/ui/parser/byte-string-literals.stderr @@ -0,0 +1,34 @@ +error: unknown byte escape: f + --> $DIR/byte-string-literals.rs:16:32 + | +LL | static FOO: &'static [u8] = b"/f"; //~ ERROR unknown byte escape + | ^ + +error: unknown byte escape: f + --> $DIR/byte-string-literals.rs:19:8 + | +LL | b"/f"; //~ ERROR unknown byte escape + | ^ + +error: invalid character in numeric character escape: Z + --> $DIR/byte-string-literals.rs:20:10 + | +LL | b"/x0Z"; //~ ERROR invalid character in numeric character escape: Z + | ^ + +error: byte constant must be ASCII. Use a /xHH escape for a non-ASCII byte + --> $DIR/byte-string-literals.rs:21:7 + | +LL | b"é"; //~ ERROR byte constant must be ASCII + | ^ + +error: unterminated double quote byte string + --> $DIR/byte-string-literals.rs:22:7 + | +LL | b"a //~ ERROR unterminated double quote byte string + | _______^ +LL | | } + | |__^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/parser/circular_modules_hello.rs b/src/test/ui/parser/circular_modules_hello.rs new file mode 100644 index 00000000000..94770aa875b --- /dev/null +++ b/src/test/ui/parser/circular_modules_hello.rs @@ -0,0 +1,20 @@ +// Copyright 2013-2014 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 + +// ignore-test: this is an auxiliary file for circular-modules-main.rs + +#[path = "circular_modules_main.rs"] +mod circular_modules_main; + +pub fn say_hello() { + println!("{}", circular_modules_main::hi_str()); +} diff --git a/src/test/ui/parser/circular_modules_main.rs b/src/test/ui/parser/circular_modules_main.rs new file mode 100644 index 00000000000..861d4cd12ab --- /dev/null +++ b/src/test/ui/parser/circular_modules_main.rs @@ -0,0 +1,22 @@ +// 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 <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 + +#[path = "circular_modules_hello.rs"] +mod circular_modules_hello; //~ ERROR: circular modules + +pub fn hi_str() -> String { + "Hi!".to_string() +} + +fn main() { + circular_modules_hello::say_hello(); +} diff --git a/src/test/ui/parser/circular_modules_main.stderr b/src/test/ui/parser/circular_modules_main.stderr new file mode 100644 index 00000000000..48cb3976c6d --- /dev/null +++ b/src/test/ui/parser/circular_modules_main.stderr @@ -0,0 +1,8 @@ +error: circular modules: $DIR/circular_modules_hello.rs -> $DIR/circular_modules_main.rs -> $DIR/circular_modules_hello.rs + --> $DIR/circular_modules_main.rs:14:5 + | +LL | mod circular_modules_hello; //~ ERROR: circular modules + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/class-implements-bad-trait.rs b/src/test/ui/parser/class-implements-bad-trait.rs new file mode 100644 index 00000000000..ea263d938d4 --- /dev/null +++ b/src/test/ui/parser/class-implements-bad-trait.rs @@ -0,0 +1,21 @@ +// 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 + +// error-pattern:nonexistent +class cat : nonexistent { + let meows: usize; + new(in_x : usize) { self.meows = in_x; } +} + +fn main() { + let nyan = cat(0); +} diff --git a/src/test/ui/parser/class-implements-bad-trait.stderr b/src/test/ui/parser/class-implements-bad-trait.stderr new file mode 100644 index 00000000000..d28750d188a --- /dev/null +++ b/src/test/ui/parser/class-implements-bad-trait.stderr @@ -0,0 +1,8 @@ +error: expected one of `!` or `::`, found `cat` + --> $DIR/class-implements-bad-trait.rs:14:7 + | +LL | class cat : nonexistent { + | ^^^ expected one of `!` or `::` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/closure-return-syntax.rs b/src/test/ui/parser/closure-return-syntax.rs new file mode 100644 index 00000000000..29b6a70b6d7 --- /dev/null +++ b/src/test/ui/parser/closure-return-syntax.rs @@ -0,0 +1,19 @@ +// Copyright 2014 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. + +// Test that we cannot parse a closure with an explicit return type +// unless it uses braces. + +// compile-flags: -Z parse-only + +fn main() { + let x = || -> i32 22; + //~^ ERROR expected one of `!`, `(`, `+`, `::`, `<`, or `{`, found `22` +} diff --git a/src/test/ui/parser/closure-return-syntax.stderr b/src/test/ui/parser/closure-return-syntax.stderr new file mode 100644 index 00000000000..1e505e5ac9b --- /dev/null +++ b/src/test/ui/parser/closure-return-syntax.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `<`, or `{`, found `22` + --> $DIR/closure-return-syntax.rs:17:23 + | +LL | let x = || -> i32 22; + | ^^ expected one of `!`, `(`, `+`, `::`, `<`, or `{` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/column-offset-1-based.rs b/src/test/ui/parser/column-offset-1-based.rs new file mode 100644 index 00000000000..8caf2e0c0a4 --- /dev/null +++ b/src/test/ui/parser/column-offset-1-based.rs @@ -0,0 +1,13 @@ +// Copyright 2014 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 + +# //~ ERROR 13:1: 13:2: expected `[`, found `<eof>` diff --git a/src/test/ui/parser/column-offset-1-based.stderr b/src/test/ui/parser/column-offset-1-based.stderr new file mode 100644 index 00000000000..452e65603c9 --- /dev/null +++ b/src/test/ui/parser/column-offset-1-based.stderr @@ -0,0 +1,8 @@ +error: expected `[`, found `<eof>` + --> $DIR/column-offset-1-based.rs:13:1 + | +LL | # //~ ERROR 13:1: 13:2: expected `[`, found `<eof>` + | ^ expected `[` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/default.rs b/src/test/ui/parser/default.rs new file mode 100644 index 00000000000..6c3bc45d34a --- /dev/null +++ b/src/test/ui/parser/default.rs @@ -0,0 +1,35 @@ +// Copyright 2015 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 + +// Test successful and unsuccessful parsing of the `default` contextual keyword + +trait Foo { + fn foo<T: Default>() -> T; +} + +impl Foo for u8 { + default fn foo<T: Default>() -> T { + T::default() + } +} + +impl Foo for u16 { + pub default fn foo<T: Default>() -> T { + T::default() + } +} + +impl Foo for u32 { + default pub fn foo<T: Default>() -> T { T::default() } //~ ERROR expected one of +} + +fn main() {} diff --git a/src/test/ui/parser/default.stderr b/src/test/ui/parser/default.stderr new file mode 100644 index 00000000000..0a5c6e80df5 --- /dev/null +++ b/src/test/ui/parser/default.stderr @@ -0,0 +1,8 @@ +error: expected one of `async`, `const`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `pub` + --> $DIR/default.rs:32:13 + | +LL | default pub fn foo<T: Default>() -> T { T::default() } //~ ERROR expected one of + | ^^^ expected one of 7 possible tokens here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/do-catch-suggests-try.rs b/src/test/ui/parser/do-catch-suggests-try.rs new file mode 100644 index 00000000000..449135e69c3 --- /dev/null +++ b/src/test/ui/parser/do-catch-suggests-try.rs @@ -0,0 +1,17 @@ +// 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. + +// compile-flags: -Z parse-only + +fn main() { + let _: Option<()> = do catch {}; + //~^ ERROR found removed `do catch` syntax + //~^^ HELP Following RFC #2388, the new non-placeholder syntax is `try` +} diff --git a/src/test/ui/parser/do-catch-suggests-try.stderr b/src/test/ui/parser/do-catch-suggests-try.stderr new file mode 100644 index 00000000000..c1ea802b8be --- /dev/null +++ b/src/test/ui/parser/do-catch-suggests-try.stderr @@ -0,0 +1,10 @@ +error: found removed `do catch` syntax + --> $DIR/do-catch-suggests-try.rs:14:25 + | +LL | let _: Option<()> = do catch {}; + | ^^ + | + = help: Following RFC #2388, the new non-placeholder syntax is `try` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/doc-after-struct-field.rs b/src/test/ui/parser/doc-after-struct-field.rs new file mode 100644 index 00000000000..11feeae8d81 --- /dev/null +++ b/src/test/ui/parser/doc-after-struct-field.rs @@ -0,0 +1,28 @@ +// Copyright 2015 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 -Z continue-parse-after-error + +struct X { + a: u8 /** document a */, + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} + +struct Y { + a: u8 /// document a + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} + +fn main() { + let x = X { a: 1 }; + let y = Y { a: 1 }; +} diff --git a/src/test/ui/parser/doc-after-struct-field.stderr b/src/test/ui/parser/doc-after-struct-field.stderr new file mode 100644 index 00000000000..17250004292 --- /dev/null +++ b/src/test/ui/parser/doc-after-struct-field.stderr @@ -0,0 +1,19 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-after-struct-field.rs:14:11 + | +LL | a: u8 /** document a */, + | ^^^^^^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-after-struct-field.rs:20:11 + | +LL | a: u8 /// document a + | ^^^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0585`. diff --git a/src/test/ui/parser/doc-before-attr.rs b/src/test/ui/parser/doc-before-attr.rs new file mode 100644 index 00000000000..4548cebd0a8 --- /dev/null +++ b/src/test/ui/parser/doc-before-attr.rs @@ -0,0 +1,14 @@ +// 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 + +/// hi +#[derive(Debug)] //~ERROR expected item after attributes diff --git a/src/test/ui/parser/doc-before-attr.stderr b/src/test/ui/parser/doc-before-attr.stderr new file mode 100644 index 00000000000..f52bf60b263 --- /dev/null +++ b/src/test/ui/parser/doc-before-attr.stderr @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/doc-before-attr.rs:14:16 + | +LL | #[derive(Debug)] //~ERROR expected item after attributes + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/doc-before-eof.rs b/src/test/ui/parser/doc-before-eof.rs new file mode 100644 index 00000000000..728972eca62 --- /dev/null +++ b/src/test/ui/parser/doc-before-eof.rs @@ -0,0 +1,13 @@ +// 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 + +/// hi //~ERROR expected item after doc comment diff --git a/src/test/ui/parser/doc-before-eof.stderr b/src/test/ui/parser/doc-before-eof.stderr new file mode 100644 index 00000000000..9fd3db73577 --- /dev/null +++ b/src/test/ui/parser/doc-before-eof.stderr @@ -0,0 +1,8 @@ +error: expected item after doc comment + --> $DIR/doc-before-eof.rs:13:1 + | +LL | /// hi //~ERROR expected item after doc comment + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/doc-before-extern-rbrace.rs b/src/test/ui/parser/doc-before-extern-rbrace.rs new file mode 100644 index 00000000000..70da47ba9b4 --- /dev/null +++ b/src/test/ui/parser/doc-before-extern-rbrace.rs @@ -0,0 +1,16 @@ +// 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 + +extern { + /// hi + //~^ ERROR expected item after doc comment +} diff --git a/src/test/ui/parser/doc-before-extern-rbrace.stderr b/src/test/ui/parser/doc-before-extern-rbrace.stderr new file mode 100644 index 00000000000..3936412cf98 --- /dev/null +++ b/src/test/ui/parser/doc-before-extern-rbrace.stderr @@ -0,0 +1,8 @@ +error: expected item after doc comment + --> $DIR/doc-before-extern-rbrace.rs:14:5 + | +LL | /// hi + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/doc-before-fn-rbrace.rs b/src/test/ui/parser/doc-before-fn-rbrace.rs new file mode 100644 index 00000000000..ad9a73626ac --- /dev/null +++ b/src/test/ui/parser/doc-before-fn-rbrace.rs @@ -0,0 +1,17 @@ +// Copyright 2015 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 -Z continue-parse-after-error + +fn main() { + /// document + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} diff --git a/src/test/ui/parser/doc-before-fn-rbrace.stderr b/src/test/ui/parser/doc-before-fn-rbrace.stderr new file mode 100644 index 00000000000..e74817e1fd2 --- /dev/null +++ b/src/test/ui/parser/doc-before-fn-rbrace.stderr @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-fn-rbrace.rs:14:5 + | +LL | /// document + | ^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff --git a/src/test/ui/parser/doc-before-identifier.rs b/src/test/ui/parser/doc-before-identifier.rs new file mode 100644 index 00000000000..a321d0e29b2 --- /dev/null +++ b/src/test/ui/parser/doc-before-identifier.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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 -Z continue-parse-after-error + +fn /// document +foo() {} +//~^^ ERROR expected identifier, found doc comment `/// document` + +fn main() { + foo(); +} diff --git a/src/test/ui/parser/doc-before-identifier.stderr b/src/test/ui/parser/doc-before-identifier.stderr new file mode 100644 index 00000000000..73b169ce8e5 --- /dev/null +++ b/src/test/ui/parser/doc-before-identifier.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found doc comment `/// document` + --> $DIR/doc-before-identifier.rs:13:4 + | +LL | fn /// document + | ^^^^^^^^^^^^ expected identifier, found doc comment + +error: aborting due to previous error + diff --git a/src/test/ui/parser/doc-before-mod-rbrace.rs b/src/test/ui/parser/doc-before-mod-rbrace.rs new file mode 100644 index 00000000000..d18ebdc5b1e --- /dev/null +++ b/src/test/ui/parser/doc-before-mod-rbrace.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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 -Z continue-parse-after-error + +mod Foo { + /// document + //~^ ERROR expected item after doc comment +} diff --git a/src/test/ui/parser/doc-before-mod-rbrace.stderr b/src/test/ui/parser/doc-before-mod-rbrace.stderr new file mode 100644 index 00000000000..807530302af --- /dev/null +++ b/src/test/ui/parser/doc-before-mod-rbrace.stderr @@ -0,0 +1,8 @@ +error: expected item after doc comment + --> $DIR/doc-before-mod-rbrace.rs:14:5 + | +LL | /// document + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/doc-before-rbrace.rs b/src/test/ui/parser/doc-before-rbrace.rs new file mode 100644 index 00000000000..48ea2b5aea1 --- /dev/null +++ b/src/test/ui/parser/doc-before-rbrace.rs @@ -0,0 +1,17 @@ +// 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 main() { + println!("Hi"); /// hi + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} diff --git a/src/test/ui/parser/doc-before-rbrace.stderr b/src/test/ui/parser/doc-before-rbrace.stderr new file mode 100644 index 00000000000..15e9c3dfd62 --- /dev/null +++ b/src/test/ui/parser/doc-before-rbrace.stderr @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-rbrace.rs:14:21 + | +LL | println!("Hi"); /// hi + | ^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff --git a/src/test/ui/parser/doc-before-semi.rs b/src/test/ui/parser/doc-before-semi.rs new file mode 100644 index 00000000000..71104b8caae --- /dev/null +++ b/src/test/ui/parser/doc-before-semi.rs @@ -0,0 +1,18 @@ +// 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 main() { + /// hi + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended + ; +} diff --git a/src/test/ui/parser/doc-before-semi.stderr b/src/test/ui/parser/doc-before-semi.stderr new file mode 100644 index 00000000000..a174d6f7053 --- /dev/null +++ b/src/test/ui/parser/doc-before-semi.stderr @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-semi.rs:14:5 + | +LL | /// hi + | ^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff --git a/src/test/ui/parser/doc-before-struct-rbrace-1.rs b/src/test/ui/parser/doc-before-struct-rbrace-1.rs new file mode 100644 index 00000000000..b0cae467863 --- /dev/null +++ b/src/test/ui/parser/doc-before-struct-rbrace-1.rs @@ -0,0 +1,22 @@ +// Copyright 2015 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 -Z continue-parse-after-error + +struct X { + a: u8, + /// document + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} + +fn main() { + let y = X {a: 1}; +} diff --git a/src/test/ui/parser/doc-before-struct-rbrace-1.stderr b/src/test/ui/parser/doc-before-struct-rbrace-1.stderr new file mode 100644 index 00000000000..9909bb250d1 --- /dev/null +++ b/src/test/ui/parser/doc-before-struct-rbrace-1.stderr @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-struct-rbrace-1.rs:15:5 + | +LL | /// document + | ^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff --git a/src/test/ui/parser/doc-before-struct-rbrace-2.rs b/src/test/ui/parser/doc-before-struct-rbrace-2.rs new file mode 100644 index 00000000000..cd5fd2d7a7f --- /dev/null +++ b/src/test/ui/parser/doc-before-struct-rbrace-2.rs @@ -0,0 +1,21 @@ +// Copyright 2015 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 -Z continue-parse-after-error + +struct X { + a: u8 /// document + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} + +fn main() { + let y = X {a: 1}; +} diff --git a/src/test/ui/parser/doc-before-struct-rbrace-2.stderr b/src/test/ui/parser/doc-before-struct-rbrace-2.stderr new file mode 100644 index 00000000000..b69720dd867 --- /dev/null +++ b/src/test/ui/parser/doc-before-struct-rbrace-2.stderr @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-struct-rbrace-2.rs:14:11 + | +LL | a: u8 /// document + | ^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff --git a/src/test/ui/parser/doc-comment-in-if-statement.rs b/src/test/ui/parser/doc-comment-in-if-statement.rs new file mode 100644 index 00000000000..c85fe25a7d0 --- /dev/null +++ b/src/test/ui/parser/doc-comment-in-if-statement.rs @@ -0,0 +1,4 @@ +fn main() { + if true /*!*/ {} + //~^ ERROR expected `{`, found doc comment `/*!*/` +} diff --git a/src/test/ui/parser/doc-comment-in-if-statement.stderr b/src/test/ui/parser/doc-comment-in-if-statement.stderr new file mode 100644 index 00000000000..6bcb77385d7 --- /dev/null +++ b/src/test/ui/parser/doc-comment-in-if-statement.stderr @@ -0,0 +1,10 @@ +error: expected `{`, found doc comment `/*!*/` + --> $DIR/doc-comment-in-if-statement.rs:2:13 + | +LL | if true /*!*/ {} + | -- ^^^^^ expected `{` + | | + | this `if` statement has a condition, but no block + +error: aborting due to previous error + diff --git a/src/test/ui/parser/duplicate-visibility.rs b/src/test/ui/parser/duplicate-visibility.rs new file mode 100644 index 00000000000..cc3286fe705 --- /dev/null +++ b/src/test/ui/parser/duplicate-visibility.rs @@ -0,0 +1,16 @@ +// 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 + +// error-pattern:expected one of `(`, `fn`, `static`, or `type` +extern { + pub pub fn foo(); +} diff --git a/src/test/ui/parser/duplicate-visibility.stderr b/src/test/ui/parser/duplicate-visibility.stderr new file mode 100644 index 00000000000..a0a5b66215e --- /dev/null +++ b/src/test/ui/parser/duplicate-visibility.stderr @@ -0,0 +1,8 @@ +error: expected one of `(`, `fn`, `static`, or `type`, found `pub` + --> $DIR/duplicate-visibility.rs:15:9 + | +LL | pub pub fn foo(); + | ^^^ expected one of `(`, `fn`, `static`, or `type` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/empty-impl-semicolon.rs b/src/test/ui/parser/empty-impl-semicolon.rs new file mode 100644 index 00000000000..9939f1e36ea --- /dev/null +++ b/src/test/ui/parser/empty-impl-semicolon.rs @@ -0,0 +1,13 @@ +// 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 <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 + +impl Foo; //~ ERROR expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;` diff --git a/src/test/ui/parser/empty-impl-semicolon.stderr b/src/test/ui/parser/empty-impl-semicolon.stderr new file mode 100644 index 00000000000..fef4b882355 --- /dev/null +++ b/src/test/ui/parser/empty-impl-semicolon.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;` + --> $DIR/empty-impl-semicolon.rs:13:9 + | +LL | impl Foo; //~ ERROR expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;` + | ^ expected one of 8 possible tokens here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/expected-comma-found-token.stderr b/src/test/ui/parser/expected-comma-found-token.stderr deleted file mode 100644 index 9a564bb872e..00000000000 --- a/src/test/ui/parser/expected-comma-found-token.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: expected one of `)` or `,`, found `label` - --> $DIR/expected-comma-found-token.rs:19:5 - | -LL | message="the message" - | - expected one of `)` or `,` here -LL | label="the label" - | ^^^^^ unexpected token - -error: aborting due to previous error - diff --git a/src/test/ui/parser/extern-crate-unexpected-token.rs b/src/test/ui/parser/extern-crate-unexpected-token.rs new file mode 100644 index 00000000000..619b88a6ab8 --- /dev/null +++ b/src/test/ui/parser/extern-crate-unexpected-token.rs @@ -0,0 +1,13 @@ +// Copyright 2015 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 + +extern crte foo; //~ ERROR expected one of `crate`, `fn`, or `{`, found `crte` diff --git a/src/test/ui/parser/extern-crate-unexpected-token.stderr b/src/test/ui/parser/extern-crate-unexpected-token.stderr new file mode 100644 index 00000000000..c359a3704bf --- /dev/null +++ b/src/test/ui/parser/extern-crate-unexpected-token.stderr @@ -0,0 +1,8 @@ +error: expected one of `crate`, `fn`, or `{`, found `crte` + --> $DIR/extern-crate-unexpected-token.rs:13:8 + | +LL | extern crte foo; //~ ERROR expected one of `crate`, `fn`, or `{`, found `crte` + | ^^^^ expected one of `crate`, `fn`, or `{` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/extern-expected-fn-or-brace.rs b/src/test/ui/parser/extern-expected-fn-or-brace.rs new file mode 100644 index 00000000000..21cca129658 --- /dev/null +++ b/src/test/ui/parser/extern-expected-fn-or-brace.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 + +// Verifies that the expected token errors for `extern crate` are +// raised + +extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found `mod` diff --git a/src/test/ui/parser/extern-expected-fn-or-brace.stderr b/src/test/ui/parser/extern-expected-fn-or-brace.stderr new file mode 100644 index 00000000000..54ab5b87d49 --- /dev/null +++ b/src/test/ui/parser/extern-expected-fn-or-brace.stderr @@ -0,0 +1,8 @@ +error: expected one of `fn` or `{`, found `mod` + --> $DIR/extern-expected-fn-or-brace.rs:16:12 + | +LL | extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found `mod` + | ^^^ expected one of `fn` or `{` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/extern-foreign-crate.rs b/src/test/ui/parser/extern-foreign-crate.rs new file mode 100644 index 00000000000..9adbd871409 --- /dev/null +++ b/src/test/ui/parser/extern-foreign-crate.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 + +// Verifies that the expected token errors for `extern crate` are +// raised + +extern crate foo {} //~ERROR expected one of `;` or `as`, found `{` diff --git a/src/test/ui/parser/extern-foreign-crate.stderr b/src/test/ui/parser/extern-foreign-crate.stderr new file mode 100644 index 00000000000..93eb9fd8de3 --- /dev/null +++ b/src/test/ui/parser/extern-foreign-crate.stderr @@ -0,0 +1,8 @@ +error: expected one of `;` or `as`, found `{` + --> $DIR/extern-foreign-crate.rs:16:18 + | +LL | extern crate foo {} //~ERROR expected one of `;` or `as`, found `{` + | ^ expected one of `;` or `as` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/extern-no-fn.rs b/src/test/ui/parser/extern-no-fn.rs new file mode 100644 index 00000000000..aa0dbd4d4fc --- /dev/null +++ b/src/test/ui/parser/extern-no-fn.rs @@ -0,0 +1,18 @@ +// 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 + +extern { //~ ERROR missing `fn`, `type`, or `static` for extern-item declaration + f(); +} + +fn main() { +} diff --git a/src/test/ui/parser/extern-no-fn.stderr b/src/test/ui/parser/extern-no-fn.stderr new file mode 100644 index 00000000000..29a7691f82b --- /dev/null +++ b/src/test/ui/parser/extern-no-fn.stderr @@ -0,0 +1,10 @@ +error: missing `fn`, `type`, or `static` for extern-item declaration + --> $DIR/extern-no-fn.rs:13:9 + | +LL | extern { //~ ERROR missing `fn`, `type`, or `static` for extern-item declaration + | _________^ +LL | | f(); + | |____^ missing `fn`, `type`, or `static` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/fn-arg-doc-comment.rs b/src/test/ui/parser/fn-arg-doc-comment.rs new file mode 100644 index 00000000000..22af94b6284 --- /dev/null +++ b/src/test/ui/parser/fn-arg-doc-comment.rs @@ -0,0 +1,37 @@ +pub fn f( + /// Comment + //~^ ERROR documentation comments cannot be applied to method arguments + //~| NOTE doc comments are not allowed here + id: u8, + /// Other + //~^ ERROR documentation comments cannot be applied to method arguments + //~| NOTE doc comments are not allowed here + a: u8, +) {} + +fn foo(#[allow(dead_code)] id: i32) {} +//~^ ERROR attributes cannot be applied to method arguments +//~| NOTE attributes are not allowed here + +fn bar(id: #[allow(dead_code)] i32) {} +//~^ ERROR attributes cannot be applied to a method argument's type +//~| NOTE attributes are not allowed here + +fn main() { + // verify that the parser recovered and properly typechecked the args + f("", ""); + //~^ ERROR mismatched types + //~| NOTE expected u8, found reference + //~| NOTE expected + //~| ERROR mismatched types + //~| NOTE expected u8, found reference + //~| NOTE expected + foo(""); + //~^ ERROR mismatched types + //~| NOTE expected i32, found reference + //~| NOTE expected + bar(""); + //~^ ERROR mismatched types + //~| NOTE expected i32, found reference + //~| NOTE expected +} diff --git a/src/test/ui/parser/fn-arg-doc-comment.stderr b/src/test/ui/parser/fn-arg-doc-comment.stderr new file mode 100644 index 00000000000..73a24eebb3f --- /dev/null +++ b/src/test/ui/parser/fn-arg-doc-comment.stderr @@ -0,0 +1,63 @@ +error: documentation comments cannot be applied to method arguments + --> $DIR/fn-arg-doc-comment.rs:2:5 + | +LL | /// Comment + | ^^^^^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to method arguments + --> $DIR/fn-arg-doc-comment.rs:6:5 + | +LL | /// Other + | ^^^^^^^^^ doc comments are not allowed here + +error: attributes cannot be applied to method arguments + --> $DIR/fn-arg-doc-comment.rs:12:8 + | +LL | fn foo(#[allow(dead_code)] id: i32) {} + | ^^^^^^^^^^^^^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to a method argument's type + --> $DIR/fn-arg-doc-comment.rs:16:12 + | +LL | fn bar(id: #[allow(dead_code)] i32) {} + | ^^^^^^^^^^^^^^^^^^^ attributes are not allowed here + +error[E0308]: mismatched types + --> $DIR/fn-arg-doc-comment.rs:22:7 + | +LL | f("", ""); + | ^^ expected u8, found reference + | + = note: expected type `u8` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/fn-arg-doc-comment.rs:22:11 + | +LL | f("", ""); + | ^^ expected u8, found reference + | + = note: expected type `u8` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/fn-arg-doc-comment.rs:29:9 + | +LL | foo(""); + | ^^ expected i32, found reference + | + = note: expected type `i32` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/fn-arg-doc-comment.rs:33:9 + | +LL | bar(""); + | ^^ expected i32, found reference + | + = note: expected type `i32` + found type `&'static str` + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/parser/if-in-in.rs b/src/test/ui/parser/if-in-in.rs index 9bc9aaff298..735d571938a 100644 --- a/src/test/ui/parser/if-in-in.rs +++ b/src/test/ui/parser/if-in-in.rs @@ -1,3 +1,5 @@ +// compile-flags: -Z parse-only + fn main() { for i in in 1..2 { println!("{}", i); diff --git a/src/test/ui/parser/if-in-in.stderr b/src/test/ui/parser/if-in-in.stderr index 9926fcc0858..65da252fc12 100644 --- a/src/test/ui/parser/if-in-in.stderr +++ b/src/test/ui/parser/if-in-in.stderr @@ -1,5 +1,5 @@ error: expected iterable, found keyword `in` - --> $DIR/if-in-in.rs:2:14 + --> $DIR/if-in-in.rs:4:14 | LL | for i in in 1..2 { | ---^^ diff --git a/src/test/ui/parser/impl-parsing.rs b/src/test/ui/parser/impl-parsing.rs new file mode 100644 index 00000000000..064e3c3ac48 --- /dev/null +++ b/src/test/ui/parser/impl-parsing.rs @@ -0,0 +1,21 @@ +// Copyright 2017 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 -Z continue-parse-after-error + +impl ! {} // OK +impl ! where u8: Copy {} // OK + +impl Trait Type {} //~ ERROR missing `for` in a trait impl +impl Trait .. {} //~ ERROR missing `for` in a trait impl +impl ?Sized for Type {} //~ ERROR expected a trait, found type +impl ?Sized for .. {} //~ ERROR expected a trait, found type + +default unsafe FAIL //~ ERROR expected `impl`, found `FAIL` diff --git a/src/test/ui/parser/impl-parsing.stderr b/src/test/ui/parser/impl-parsing.stderr new file mode 100644 index 00000000000..3cfcf7b7683 --- /dev/null +++ b/src/test/ui/parser/impl-parsing.stderr @@ -0,0 +1,32 @@ +error: missing `for` in a trait impl + --> $DIR/impl-parsing.rs:16:11 + | +LL | impl Trait Type {} //~ ERROR missing `for` in a trait impl + | ^ + +error: missing `for` in a trait impl + --> $DIR/impl-parsing.rs:17:11 + | +LL | impl Trait .. {} //~ ERROR missing `for` in a trait impl + | ^ + +error: expected a trait, found type + --> $DIR/impl-parsing.rs:18:6 + | +LL | impl ?Sized for Type {} //~ ERROR expected a trait, found type + | ^^^^^^ + +error: expected a trait, found type + --> $DIR/impl-parsing.rs:19:6 + | +LL | impl ?Sized for .. {} //~ ERROR expected a trait, found type + | ^^^^^^ + +error: expected `impl`, found `FAIL` + --> $DIR/impl-parsing.rs:21:16 + | +LL | default unsafe FAIL //~ ERROR expected `impl`, found `FAIL` + | ^^^^ expected `impl` here + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/parser/impl-qpath.rs b/src/test/ui/parser/impl-qpath.rs new file mode 100644 index 00000000000..5dced73c90d --- /dev/null +++ b/src/test/ui/parser/impl-qpath.rs @@ -0,0 +1,17 @@ +// Copyright 2017 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-pass +// compile-flags: -Z parse-only + +impl <*const u8>::AssocTy {} // OK +impl <Type as Trait>::AssocTy {} // OK +impl <'a + Trait>::AssocTy {} // OK +impl <<Type>::AssocTy>::AssocTy {} // OK diff --git a/src/test/ui/parser/import-from-path.rs b/src/test/ui/parser/import-from-path.rs new file mode 100644 index 00000000000..fbd59d200a0 --- /dev/null +++ b/src/test/ui/parser/import-from-path.rs @@ -0,0 +1,14 @@ +// 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 + +// error-pattern:expected +use foo::{bar}::baz diff --git a/src/test/ui/parser/import-from-path.stderr b/src/test/ui/parser/import-from-path.stderr new file mode 100644 index 00000000000..1628c120945 --- /dev/null +++ b/src/test/ui/parser/import-from-path.stderr @@ -0,0 +1,8 @@ +error: expected `;`, found `::` + --> $DIR/import-from-path.rs:14:15 + | +LL | use foo::{bar}::baz + | ^^ expected `;` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/import-from-rename.rs b/src/test/ui/parser/import-from-rename.rs new file mode 100644 index 00000000000..c4d8ba2086d --- /dev/null +++ b/src/test/ui/parser/import-from-rename.rs @@ -0,0 +1,22 @@ +// 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 + +// error-pattern:expected + +use foo::{bar} as baz; + +mod foo { + pub fn bar() {} +} + +fn main() { +} diff --git a/src/test/ui/parser/import-from-rename.stderr b/src/test/ui/parser/import-from-rename.stderr new file mode 100644 index 00000000000..f00bfcb45b1 --- /dev/null +++ b/src/test/ui/parser/import-from-rename.stderr @@ -0,0 +1,8 @@ +error: expected `;`, found keyword `as` + --> $DIR/import-from-rename.rs:15:16 + | +LL | use foo::{bar} as baz; + | ^^ expected `;` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/import-glob-path.rs b/src/test/ui/parser/import-glob-path.rs new file mode 100644 index 00000000000..2faf833d4f1 --- /dev/null +++ b/src/test/ui/parser/import-glob-path.rs @@ -0,0 +1,14 @@ +// 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 + +// error-pattern:expected +use foo::*::bar diff --git a/src/test/ui/parser/import-glob-path.stderr b/src/test/ui/parser/import-glob-path.stderr new file mode 100644 index 00000000000..af7d0ee0c02 --- /dev/null +++ b/src/test/ui/parser/import-glob-path.stderr @@ -0,0 +1,8 @@ +error: expected `;`, found `::` + --> $DIR/import-glob-path.rs:14:11 + | +LL | use foo::*::bar + | ^^ expected `;` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/import-glob-rename.rs b/src/test/ui/parser/import-glob-rename.rs new file mode 100644 index 00000000000..7e17e1f1d6c --- /dev/null +++ b/src/test/ui/parser/import-glob-rename.rs @@ -0,0 +1,22 @@ +// 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 + +// error-pattern:expected + +use foo::* as baz; + +mod foo { + pub fn bar() {} +} + +fn main() { +} diff --git a/src/test/ui/parser/import-glob-rename.stderr b/src/test/ui/parser/import-glob-rename.stderr new file mode 100644 index 00000000000..0b124a32df3 --- /dev/null +++ b/src/test/ui/parser/import-glob-rename.stderr @@ -0,0 +1,8 @@ +error: expected `;`, found keyword `as` + --> $DIR/import-glob-rename.rs:15:12 + | +LL | use foo::* as baz; + | ^^ expected `;` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/inner-attr-after-doc-comment.rs b/src/test/ui/parser/inner-attr-after-doc-comment.rs new file mode 100644 index 00000000000..ed8342d9f5a --- /dev/null +++ b/src/test/ui/parser/inner-attr-after-doc-comment.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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 + +#![feature(lang_items)] +/** + * My module + */ + +#![recursion_limit="100"] +//~^ ERROR an inner attribute is not permitted following an outer doc comment +fn main() {} diff --git a/src/test/ui/parser/inner-attr-after-doc-comment.stderr b/src/test/ui/parser/inner-attr-after-doc-comment.stderr new file mode 100644 index 00000000000..af050e662a2 --- /dev/null +++ b/src/test/ui/parser/inner-attr-after-doc-comment.stderr @@ -0,0 +1,10 @@ +error: an inner attribute is not permitted following an outer doc comment + --> $DIR/inner-attr-after-doc-comment.rs:18:3 + | +LL | #![recursion_limit="100"] + | ^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. + +error: aborting due to previous error + diff --git a/src/test/ui/parser/inner-attr.rs b/src/test/ui/parser/inner-attr.rs new file mode 100644 index 00000000000..8cebda66445 --- /dev/null +++ b/src/test/ui/parser/inner-attr.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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 + +#[feature(lang_items)] + +#![recursion_limit="100"] //~ ERROR an inner attribute is not permitted following an outer attribute +fn main() {} diff --git a/src/test/ui/parser/inner-attr.stderr b/src/test/ui/parser/inner-attr.stderr new file mode 100644 index 00000000000..89fb5cfad5e --- /dev/null +++ b/src/test/ui/parser/inner-attr.stderr @@ -0,0 +1,10 @@ +error: an inner attribute is not permitted following an outer attribute + --> $DIR/inner-attr.rs:15:3 + | +LL | #![recursion_limit="100"] //~ ERROR an inner attribute is not permitted following an outer attribute + | ^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. + +error: aborting due to previous error + diff --git a/src/test/ui/parser/int-literal-too-large-span.rs b/src/test/ui/parser/int-literal-too-large-span.rs new file mode 100644 index 00000000000..1af8df7d2f6 --- /dev/null +++ b/src/test/ui/parser/int-literal-too-large-span.rs @@ -0,0 +1,19 @@ +// Copyright 2014 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 + +// issue #17123 + +fn main() { + 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + //~^ ERROR int literal is too large + ; // the span shouldn't point to this. +} diff --git a/src/test/ui/parser/int-literal-too-large-span.stderr b/src/test/ui/parser/int-literal-too-large-span.stderr new file mode 100644 index 00000000000..391cb52fd40 --- /dev/null +++ b/src/test/ui/parser/int-literal-too-large-span.stderr @@ -0,0 +1,8 @@ +error: int literal is too large + --> $DIR/int-literal-too-large-span.rs:16:5 + | +LL | 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/inverted-parameters.rs b/src/test/ui/parser/inverted-parameters.rs index a100debbf12..c08a309e11e 100644 --- a/src/test/ui/parser/inverted-parameters.rs +++ b/src/test/ui/parser/inverted-parameters.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z parse-only + struct S; impl S { diff --git a/src/test/ui/parser/inverted-parameters.stderr b/src/test/ui/parser/inverted-parameters.stderr index 3f4f0615bc8..63cd36f00c0 100644 --- a/src/test/ui/parser/inverted-parameters.stderr +++ b/src/test/ui/parser/inverted-parameters.stderr @@ -1,5 +1,5 @@ error: expected one of `:` or `@`, found `bar` - --> $DIR/inverted-parameters.rs:14:24 + --> $DIR/inverted-parameters.rs:16:24 | LL | fn foo(&self, &str bar) {} | -----^^^ @@ -8,7 +8,7 @@ LL | fn foo(&self, &str bar) {} | help: declare the type after the parameter binding: `<identifier>: <type>` error: expected one of `:` or `@`, found `quux` - --> $DIR/inverted-parameters.rs:20:10 + --> $DIR/inverted-parameters.rs:22:10 | LL | fn baz(S quux, xyzzy: i32) {} | --^^^^ @@ -17,25 +17,25 @@ LL | fn baz(S quux, xyzzy: i32) {} | help: declare the type after the parameter binding: `<identifier>: <type>` error: expected one of `:` or `@`, found `a` - --> $DIR/inverted-parameters.rs:25:12 + --> $DIR/inverted-parameters.rs:27:12 | LL | fn one(i32 a b) {} | ^ expected one of `:` or `@` here error: expected `:`, found `(` - --> $DIR/inverted-parameters.rs:28:23 + --> $DIR/inverted-parameters.rs:30:23 | LL | fn pattern((i32, i32) (a, b)) {} | ^ expected `:` error: expected one of `:` or `@`, found `)` - --> $DIR/inverted-parameters.rs:31:12 + --> $DIR/inverted-parameters.rs:33:12 | LL | fn fizz(i32) {} | ^ expected one of `:` or `@` here error: expected one of `:` or `@`, found `S` - --> $DIR/inverted-parameters.rs:34:23 + --> $DIR/inverted-parameters.rs:36:23 | LL | fn missing_colon(quux S) {} | -----^ diff --git a/src/test/ui/parser/issue-10392-2.rs b/src/test/ui/parser/issue-10392-2.rs new file mode 100644 index 00000000000..2817912666e --- /dev/null +++ b/src/test/ui/parser/issue-10392-2.rs @@ -0,0 +1,19 @@ +// Copyright 2012-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 <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 + +struct A { foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { .., } = a(); //~ ERROR: expected `}` +} diff --git a/src/test/ui/parser/issue-10392-2.stderr b/src/test/ui/parser/issue-10392-2.stderr new file mode 100644 index 00000000000..41548ed4a2f --- /dev/null +++ b/src/test/ui/parser/issue-10392-2.stderr @@ -0,0 +1,12 @@ +error: expected `}`, found `,` + --> $DIR/issue-10392-2.rs:18:15 + | +LL | let A { .., } = a(); //~ ERROR: expected `}` + | --^ + | | | + | | expected `}` + | | help: remove this comma + | `..` must be at the end and cannot have a trailing comma + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-10392.rs b/src/test/ui/parser/issue-10392.rs new file mode 100644 index 00000000000..9c67575bcc1 --- /dev/null +++ b/src/test/ui/parser/issue-10392.rs @@ -0,0 +1,19 @@ +// Copyright 2012-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 <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 + +struct A { foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { , } = a(); //~ ERROR: expected ident +} diff --git a/src/test/ui/parser/issue-10392.stderr b/src/test/ui/parser/issue-10392.stderr new file mode 100644 index 00000000000..0401fe05cf8 --- /dev/null +++ b/src/test/ui/parser/issue-10392.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `,` + --> $DIR/issue-10392.rs:18:13 + | +LL | let A { , } = a(); //~ ERROR: expected ident + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-10636-1.rs b/src/test/ui/parser/issue-10636-1.rs new file mode 100644 index 00000000000..375b951ee15 --- /dev/null +++ b/src/test/ui/parser/issue-10636-1.rs @@ -0,0 +1,20 @@ +// 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 <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 + +struct Obj { + //~^ NOTE: un-closed delimiter + member: usize +) +//~^ ERROR incorrect close delimiter +//~| NOTE incorrect close delimiter + +fn main() {} diff --git a/src/test/ui/parser/issue-10636-1.stderr b/src/test/ui/parser/issue-10636-1.stderr new file mode 100644 index 00000000000..49b6d08aff5 --- /dev/null +++ b/src/test/ui/parser/issue-10636-1.stderr @@ -0,0 +1,11 @@ +error: incorrect close delimiter: `)` + --> $DIR/issue-10636-1.rs:16:1 + | +LL | struct Obj { + | - un-closed delimiter +... +LL | ) + | ^ incorrect close delimiter + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-10636-2.rs b/src/test/ui/parser/issue-10636-2.rs new file mode 100644 index 00000000000..c96834fe4cf --- /dev/null +++ b/src/test/ui/parser/issue-10636-2.rs @@ -0,0 +1,23 @@ +// Copyright 2013-2016 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. + +// FIXME(31528) we emit a bunch of silly errors here due to continuing past the +// first one. This would be easy-ish to address by better recovery in tokenisation. + +// compile-flags: -Z parse-only + +pub fn trace_option(option: Option<isize>) { + option.map(|some| 42; + //~^ ERROR: expected one of + +} //~ ERROR: incorrect close delimiter +//~^ ERROR: expected expression, found `)` + +fn main() {} diff --git a/src/test/ui/parser/issue-10636-2.stderr b/src/test/ui/parser/issue-10636-2.stderr new file mode 100644 index 00000000000..8f721a3b5dd --- /dev/null +++ b/src/test/ui/parser/issue-10636-2.stderr @@ -0,0 +1,25 @@ +error: incorrect close delimiter: `}` + --> $DIR/issue-10636-2.rs:20:1 + | +LL | pub fn trace_option(option: Option<isize>) { + | - close delimiter possibly meant for this +LL | option.map(|some| 42; + | - un-closed delimiter +... +LL | } //~ ERROR: incorrect close delimiter + | ^ incorrect close delimiter + +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` + --> $DIR/issue-10636-2.rs:17:25 + | +LL | option.map(|some| 42; + | ^ expected one of `)`, `,`, `.`, `?`, or an operator here + +error: expected expression, found `)` + --> $DIR/issue-10636-2.rs:20:1 + | +LL | } //~ ERROR: incorrect close delimiter + | ^ expected expression + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/parser/issue-14303-enum.rs b/src/test/ui/parser/issue-14303-enum.rs new file mode 100644 index 00000000000..6bcf588b516 --- /dev/null +++ b/src/test/ui/parser/issue-14303-enum.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 + +enum X<'a, T, 'b> { +//~^ ERROR lifetime parameters must be declared prior to type parameters + A(&'a T) +} diff --git a/src/test/ui/parser/issue-14303-enum.stderr b/src/test/ui/parser/issue-14303-enum.stderr new file mode 100644 index 00000000000..7d546cb2180 --- /dev/null +++ b/src/test/ui/parser/issue-14303-enum.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-enum.rs:13:15 + | +LL | enum X<'a, T, 'b> { + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-14303-fn-def.rs b/src/test/ui/parser/issue-14303-fn-def.rs new file mode 100644 index 00000000000..ae8e38c0377 --- /dev/null +++ b/src/test/ui/parser/issue-14303-fn-def.rs @@ -0,0 +1,14 @@ +// Copyright 2014 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<'a, T, 'b>(x: &'a T) {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff --git a/src/test/ui/parser/issue-14303-fn-def.stderr b/src/test/ui/parser/issue-14303-fn-def.stderr new file mode 100644 index 00000000000..c7b57f36376 --- /dev/null +++ b/src/test/ui/parser/issue-14303-fn-def.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-fn-def.rs:13:15 + | +LL | fn foo<'a, T, 'b>(x: &'a T) {} + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-14303-fncall.rs b/src/test/ui/parser/issue-14303-fncall.rs new file mode 100644 index 00000000000..80a9b3d7c0d --- /dev/null +++ b/src/test/ui/parser/issue-14303-fncall.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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 main() { + (0..4) + .map(|x| x * 2) + .collect::<Vec<'a, usize, 'b>>() + //~^ ERROR lifetime parameters must be declared prior to type parameters +} diff --git a/src/test/ui/parser/issue-14303-fncall.stderr b/src/test/ui/parser/issue-14303-fncall.stderr new file mode 100644 index 00000000000..cca23c70279 --- /dev/null +++ b/src/test/ui/parser/issue-14303-fncall.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-fncall.rs:16:31 + | +LL | .collect::<Vec<'a, usize, 'b>>() + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-14303-impl.rs b/src/test/ui/parser/issue-14303-impl.rs new file mode 100644 index 00000000000..f06d5f29e9e --- /dev/null +++ b/src/test/ui/parser/issue-14303-impl.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 + +struct X { x: isize } + +impl<'a, T, 'b> X {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff --git a/src/test/ui/parser/issue-14303-impl.stderr b/src/test/ui/parser/issue-14303-impl.stderr new file mode 100644 index 00000000000..0b7016eb7f7 --- /dev/null +++ b/src/test/ui/parser/issue-14303-impl.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-impl.rs:15:13 + | +LL | impl<'a, T, 'b> X {} + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-14303-path.rs b/src/test/ui/parser/issue-14303-path.rs new file mode 100644 index 00000000000..f0d1feffec8 --- /dev/null +++ b/src/test/ui/parser/issue-14303-path.rs @@ -0,0 +1,14 @@ +// Copyright 2014 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 bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff --git a/src/test/ui/parser/issue-14303-path.stderr b/src/test/ui/parser/issue-14303-path.stderr new file mode 100644 index 00000000000..f0a45998d17 --- /dev/null +++ b/src/test/ui/parser/issue-14303-path.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-path.rs:13:37 + | +LL | fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-14303-struct.rs b/src/test/ui/parser/issue-14303-struct.rs new file mode 100644 index 00000000000..5673e4f2a4c --- /dev/null +++ b/src/test/ui/parser/issue-14303-struct.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 + +struct X<'a, T, 'b> { +//~^ ERROR lifetime parameters must be declared prior to type parameters + x: &'a T +} diff --git a/src/test/ui/parser/issue-14303-struct.stderr b/src/test/ui/parser/issue-14303-struct.stderr new file mode 100644 index 00000000000..4a4b6789194 --- /dev/null +++ b/src/test/ui/parser/issue-14303-struct.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-struct.rs:13:17 + | +LL | struct X<'a, T, 'b> { + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-14303-trait.rs b/src/test/ui/parser/issue-14303-trait.rs new file mode 100644 index 00000000000..8af5af9e933 --- /dev/null +++ b/src/test/ui/parser/issue-14303-trait.rs @@ -0,0 +1,14 @@ +// Copyright 2014 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 + +trait Foo<'a, T, 'b> {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff --git a/src/test/ui/parser/issue-14303-trait.stderr b/src/test/ui/parser/issue-14303-trait.stderr new file mode 100644 index 00000000000..ab5cc5655bb --- /dev/null +++ b/src/test/ui/parser/issue-14303-trait.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-trait.rs:13:18 + | +LL | trait Foo<'a, T, 'b> {} + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-15914.rs b/src/test/ui/parser/issue-15914.rs new file mode 100644 index 00000000000..0b8f0ac221a --- /dev/null +++ b/src/test/ui/parser/issue-15914.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 main() { + let ref + (); //~ ERROR expected identifier, found `(` +} diff --git a/src/test/ui/parser/issue-15914.stderr b/src/test/ui/parser/issue-15914.stderr new file mode 100644 index 00000000000..fbf0ea13c73 --- /dev/null +++ b/src/test/ui/parser/issue-15914.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `(` + --> $DIR/issue-15914.rs:15:9 + | +LL | (); //~ ERROR expected identifier, found `(` + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-15980.rs b/src/test/ui/parser/issue-15980.rs new file mode 100644 index 00000000000..2f11805481d --- /dev/null +++ b/src/test/ui/parser/issue-15980.rs @@ -0,0 +1,29 @@ +// 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. + +// compile-flags: -Z parse-only + +use std::io; + +fn main(){ + let x: io::IoResult<()> = Ok(()); + match x { + Err(ref e) if e.kind == io::EndOfFile { + //~^ NOTE while parsing this struct + return + //~^ ERROR expected identifier, found keyword `return` + //~| NOTE expected identifier, found keyword + } + //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here + _ => {} + //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found `_` + //~| NOTE unexpected token + } +} diff --git a/src/test/ui/parser/issue-15980.stderr b/src/test/ui/parser/issue-15980.stderr new file mode 100644 index 00000000000..1395803e121 --- /dev/null +++ b/src/test/ui/parser/issue-15980.stderr @@ -0,0 +1,20 @@ +error: expected identifier, found keyword `return` + --> $DIR/issue-15980.rs:20:13 + | +LL | Err(ref e) if e.kind == io::EndOfFile { + | ------------- while parsing this struct +LL | //~^ NOTE while parsing this struct +LL | return + | ^^^^^^ expected identifier, found keyword + +error: expected one of `.`, `=>`, `?`, or an operator, found `_` + --> $DIR/issue-15980.rs:25:9 + | +LL | } + | - expected one of `.`, `=>`, `?`, or an operator here +LL | //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here +LL | _ => {} + | ^ unexpected token + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/issue-1655.rs b/src/test/ui/parser/issue-1655.rs new file mode 100644 index 00000000000..a044dff261d --- /dev/null +++ b/src/test/ui/parser/issue-1655.rs @@ -0,0 +1,23 @@ +// 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 + +// error-pattern:expected `[`, found `vec` +mod blade_runner { + #vec[doc( + brief = "Blade Runner is probably the best movie ever", + desc = "I like that in the world of Blade Runner it is always + raining, and that it's always night time. And Aliens + was also a really good movie. + + Alien 3 was crap though." + )] +} diff --git a/src/test/ui/parser/issue-1655.stderr b/src/test/ui/parser/issue-1655.stderr new file mode 100644 index 00000000000..890400acccf --- /dev/null +++ b/src/test/ui/parser/issue-1655.stderr @@ -0,0 +1,8 @@ +error: expected `[`, found `vec` + --> $DIR/issue-1655.rs:15:6 + | +LL | #vec[doc( + | ^^^ expected `[` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-17383.rs b/src/test/ui/parser/issue-17383.rs new file mode 100644 index 00000000000..48f629fd828 --- /dev/null +++ b/src/test/ui/parser/issue-17383.rs @@ -0,0 +1,20 @@ +// Copyright 2014 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 + +enum X { + A = + b'a' //~ ERROR discriminator values can only be used with a field-less enum + , + B(isize) +} + +fn main() {} diff --git a/src/test/ui/parser/issue-17383.stderr b/src/test/ui/parser/issue-17383.stderr new file mode 100644 index 00000000000..321989e5fab --- /dev/null +++ b/src/test/ui/parser/issue-17383.stderr @@ -0,0 +1,8 @@ +error: discriminator values can only be used with a field-less enum + --> $DIR/issue-17383.rs:15:9 + | +LL | b'a' //~ ERROR discriminator values can only be used with a field-less enum + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-17718-const-mut.rs b/src/test/ui/parser/issue-17718-const-mut.rs new file mode 100644 index 00000000000..b450cb25e6b --- /dev/null +++ b/src/test/ui/parser/issue-17718-const-mut.rs @@ -0,0 +1,19 @@ +// Copyright 2014 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 + +const +mut //~ ERROR: const globals cannot be mutable +//~^ HELP did you mean to declare a static? +FOO: usize = 3; + +fn main() { +} diff --git a/src/test/ui/parser/issue-17718-const-mut.stderr b/src/test/ui/parser/issue-17718-const-mut.stderr new file mode 100644 index 00000000000..b294a8572fb --- /dev/null +++ b/src/test/ui/parser/issue-17718-const-mut.stderr @@ -0,0 +1,10 @@ +error: const globals cannot be mutable + --> $DIR/issue-17718-const-mut.rs:14:1 + | +LL | mut //~ ERROR: const globals cannot be mutable + | ^^^ + | + = help: did you mean to declare a static? + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-17904-2.rs b/src/test/ui/parser/issue-17904-2.rs new file mode 100644 index 00000000000..749cb7fcc0b --- /dev/null +++ b/src/test/ui/parser/issue-17904-2.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found keyword `where` + +fn main() {} diff --git a/src/test/ui/parser/issue-17904-2.stderr b/src/test/ui/parser/issue-17904-2.stderr new file mode 100644 index 00000000000..ff9e1215f10 --- /dev/null +++ b/src/test/ui/parser/issue-17904-2.stderr @@ -0,0 +1,8 @@ +error: expected item, found keyword `where` + --> $DIR/issue-17904-2.rs:13:24 + | +LL | struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found keyword `where` + | ^^^^^ expected item + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-17904.rs b/src/test/ui/parser/issue-17904.rs new file mode 100644 index 00000000000..a54d89f48c3 --- /dev/null +++ b/src/test/ui/parser/issue-17904.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +struct Baz<U> where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax. +struct Baz<U> where U: Eq(U) -> R; // Notice this parses as well. +struct Baz<U>(U) where U: Eq; // This rightfully signals no error as well. +struct Foo<T> where T: Copy, (T); //~ ERROR expected one of `:`, `==`, or `=`, found `;` + +fn main() {} diff --git a/src/test/ui/parser/issue-17904.stderr b/src/test/ui/parser/issue-17904.stderr new file mode 100644 index 00000000000..c783d97478c --- /dev/null +++ b/src/test/ui/parser/issue-17904.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `==`, or `=`, found `;` + --> $DIR/issue-17904.rs:16:33 + | +LL | struct Foo<T> where T: Copy, (T); //~ ERROR expected one of `:`, `==`, or `=`, found `;` + | ^ expected one of `:`, `==`, or `=` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-1802-1.rs b/src/test/ui/parser/issue-1802-1.rs new file mode 100644 index 00000000000..fc3d071729f --- /dev/null +++ b/src/test/ui/parser/issue-1802-1.rs @@ -0,0 +1,16 @@ +// 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 + +// error-pattern:no valid digits found for number +fn main() { + log(error, 0b); +} diff --git a/src/test/ui/parser/issue-1802-1.stderr b/src/test/ui/parser/issue-1802-1.stderr new file mode 100644 index 00000000000..b4ce85e784c --- /dev/null +++ b/src/test/ui/parser/issue-1802-1.stderr @@ -0,0 +1,8 @@ +error: no valid digits found for number + --> $DIR/issue-1802-1.rs:15:16 + | +LL | log(error, 0b); + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-1802-2.rs b/src/test/ui/parser/issue-1802-2.rs new file mode 100644 index 00000000000..05c5a4bcb02 --- /dev/null +++ b/src/test/ui/parser/issue-1802-2.rs @@ -0,0 +1,16 @@ +// 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 + +// error-pattern:no valid digits found for number +fn main() { + log(error, 0b_usize); +} diff --git a/src/test/ui/parser/issue-1802-2.stderr b/src/test/ui/parser/issue-1802-2.stderr new file mode 100644 index 00000000000..d8e68529a6d --- /dev/null +++ b/src/test/ui/parser/issue-1802-2.stderr @@ -0,0 +1,8 @@ +error: no valid digits found for number + --> $DIR/issue-1802-2.rs:15:16 + | +LL | log(error, 0b_usize); + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-19096.rs b/src/test/ui/parser/issue-19096.rs new file mode 100644 index 00000000000..6ba0fb5f15b --- /dev/null +++ b/src/test/ui/parser/issue-19096.rs @@ -0,0 +1,16 @@ +// 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 main() { + let t = (42, 42); + t.0::<isize>; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::` +} diff --git a/src/test/ui/parser/issue-19096.stderr b/src/test/ui/parser/issue-19096.stderr new file mode 100644 index 00000000000..0e99f4e125c --- /dev/null +++ b/src/test/ui/parser/issue-19096.stderr @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::` + --> $DIR/issue-19096.rs:15:8 + | +LL | t.0::<isize>; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::` + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-19398.rs b/src/test/ui/parser/issue-19398.rs new file mode 100644 index 00000000000..a91d513b83d --- /dev/null +++ b/src/test/ui/parser/issue-19398.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 + +trait T { + extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found `unsafe` +} + +fn main() {} diff --git a/src/test/ui/parser/issue-19398.stderr b/src/test/ui/parser/issue-19398.stderr new file mode 100644 index 00000000000..08957f2d383 --- /dev/null +++ b/src/test/ui/parser/issue-19398.stderr @@ -0,0 +1,8 @@ +error: expected `fn`, found `unsafe` + --> $DIR/issue-19398.rs:14:19 + | +LL | extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found `unsafe` + | ^^^^^^ expected `fn` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-20711-2.rs b/src/test/ui/parser/issue-20711-2.rs new file mode 100644 index 00000000000..d0836d4af97 --- /dev/null +++ b/src/test/ui/parser/issue-20711-2.rs @@ -0,0 +1,22 @@ +// Copyright 2015 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 +// ignore-tidy-linelength + +struct Foo; + +impl Foo { + fn foo() {} + + #[stable(feature = "rust1", since = "1.0.0")] +} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or + +fn main() {} diff --git a/src/test/ui/parser/issue-20711-2.stderr b/src/test/ui/parser/issue-20711-2.stderr new file mode 100644 index 00000000000..ce6d6cbdc06 --- /dev/null +++ b/src/test/ui/parser/issue-20711-2.stderr @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` + --> $DIR/issue-20711-2.rs:20:1 + | +LL | #[stable(feature = "rust1", since = "1.0.0")] + | - expected one of 10 possible tokens here +LL | } //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or + | ^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-20711.rs b/src/test/ui/parser/issue-20711.rs new file mode 100644 index 00000000000..d9442247988 --- /dev/null +++ b/src/test/ui/parser/issue-20711.rs @@ -0,0 +1,20 @@ +// Copyright 2015 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 +// ignore-tidy-linelength + +struct Foo; + +impl Foo { + #[stable(feature = "rust1", since = "1.0.0")] +} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or + +fn main() {} diff --git a/src/test/ui/parser/issue-20711.stderr b/src/test/ui/parser/issue-20711.stderr new file mode 100644 index 00000000000..b5b56361577 --- /dev/null +++ b/src/test/ui/parser/issue-20711.stderr @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` + --> $DIR/issue-20711.rs:18:1 + | +LL | #[stable(feature = "rust1", since = "1.0.0")] + | - expected one of 10 possible tokens here +LL | } //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or + | ^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-21153.rs b/src/test/ui/parser/issue-21153.rs new file mode 100644 index 00000000000..b6d95ffb911 --- /dev/null +++ b/src/test/ui/parser/issue-21153.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 + +trait MyTrait<T>: Iterator { //~ ERROR missing `fn`, `type`, or `const` + Item = T; +} diff --git a/src/test/ui/parser/issue-21153.stderr b/src/test/ui/parser/issue-21153.stderr new file mode 100644 index 00000000000..47e05f1b360 --- /dev/null +++ b/src/test/ui/parser/issue-21153.stderr @@ -0,0 +1,10 @@ +error: missing `fn`, `type`, or `const` for trait-item declaration + --> $DIR/issue-21153.rs:13:29 + | +LL | trait MyTrait<T>: Iterator { //~ ERROR missing `fn`, `type`, or `const` + | _____________________________^ +LL | | Item = T; + | |____^ missing `fn`, `type`, or `const` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-22647.rs b/src/test/ui/parser/issue-22647.rs new file mode 100644 index 00000000000..0f77ddd70cf --- /dev/null +++ b/src/test/ui/parser/issue-22647.rs @@ -0,0 +1,27 @@ +// Copyright 2015 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 main() { + let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` + where F: Fn() -> i32 + { + let x = f(); + println!("Y {}",x); + return x; + }; + + caller(bar_handler); +} + +fn bar_handler() -> i32 { + 5 +} diff --git a/src/test/ui/parser/issue-22647.stderr b/src/test/ui/parser/issue-22647.stderr new file mode 100644 index 00000000000..fbf078e425b --- /dev/null +++ b/src/test/ui/parser/issue-22647.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `<` + --> $DIR/issue-22647.rs:14:15 + | +LL | let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-22712.rs b/src/test/ui/parser/issue-22712.rs new file mode 100644 index 00000000000..026af652c5e --- /dev/null +++ b/src/test/ui/parser/issue-22712.rs @@ -0,0 +1,21 @@ +// Copyright 2015 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 + +struct Foo<B> { + buffer: B +} + +fn bar() { + let Foo<Vec<u8>> //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` +} + +fn main() {} diff --git a/src/test/ui/parser/issue-22712.stderr b/src/test/ui/parser/issue-22712.stderr new file mode 100644 index 00000000000..8651005ea68 --- /dev/null +++ b/src/test/ui/parser/issue-22712.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `<` + --> $DIR/issue-22712.rs:18:12 + | +LL | let Foo<Vec<u8>> //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-2354-1.rs b/src/test/ui/parser/issue-2354-1.rs new file mode 100644 index 00000000000..f24c5440735 --- /dev/null +++ b/src/test/ui/parser/issue-2354-1.rs @@ -0,0 +1,13 @@ +// 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 <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 + +static foo: isize = 2; } //~ ERROR unexpected close delimiter: diff --git a/src/test/ui/parser/issue-2354-1.stderr b/src/test/ui/parser/issue-2354-1.stderr new file mode 100644 index 00000000000..bcec78a3d9b --- /dev/null +++ b/src/test/ui/parser/issue-2354-1.stderr @@ -0,0 +1,8 @@ +error: unexpected close delimiter: `}` + --> $DIR/issue-2354-1.rs:13:24 + | +LL | static foo: isize = 2; } //~ ERROR unexpected close delimiter: + | ^ unexpected close delimiter + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-2354.rs b/src/test/ui/parser/issue-2354.rs new file mode 100644 index 00000000000..35fddcb0de4 --- /dev/null +++ b/src/test/ui/parser/issue-2354.rs @@ -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 diff --git a/src/test/ui/parser/issue-2354.stderr b/src/test/ui/parser/issue-2354.stderr new file mode 100644 index 00000000000..9cf569b685b --- /dev/null +++ b/src/test/ui/parser/issue-2354.stderr @@ -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 + diff --git a/src/test/ui/parser/issue-23620-invalid-escapes.rs b/src/test/ui/parser/issue-23620-invalid-escapes.rs new file mode 100644 index 00000000000..dfeaae49002 --- /dev/null +++ b/src/test/ui/parser/issue-23620-invalid-escapes.rs @@ -0,0 +1,48 @@ +// Copyright 2015 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 -Z continue-parse-after-error + +fn main() { + let _ = b"\u{a66e}"; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = b'\u{a66e}'; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = b'\u'; + //~^ ERROR incorrect unicode escape sequence + //~^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = b'\x5'; + //~^ ERROR numeric character escape is too short + + let _ = b'\xxy'; + //~^ ERROR invalid character in numeric character escape: x + //~^^ ERROR invalid character in numeric character escape: y + + let _ = '\x5'; + //~^ ERROR numeric character escape is too short + + let _ = '\xxy'; + //~^ ERROR invalid character in numeric character escape: x + //~^^ ERROR invalid character in numeric character escape: y + + let _ = b"\u{a4a4} \xf \u"; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + //~^^ ERROR invalid character in numeric character escape: + //~^^^ ERROR incorrect unicode escape sequence + //~^^^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = "\xf \u"; + //~^ ERROR invalid character in numeric character escape: + //~^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f] + //~^^^ ERROR incorrect unicode escape sequence +} diff --git a/src/test/ui/parser/issue-23620-invalid-escapes.stderr b/src/test/ui/parser/issue-23620-invalid-escapes.stderr new file mode 100644 index 00000000000..a46bcb07200 --- /dev/null +++ b/src/test/ui/parser/issue-23620-invalid-escapes.stderr @@ -0,0 +1,122 @@ +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:14:15 + | +LL | let _ = b"/u{a66e}"; + | ^^^^^^^^ + +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:17:15 + | +LL | let _ = b'/u{a66e}'; + | ^^^^^^^^ + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:20:15 + | +LL | let _ = b'/u'; + | ^^ + | +help: format of unicode escape sequences is `/u{…}` + --> $DIR/issue-23620-invalid-escapes.rs:20:15 + | +LL | let _ = b'/u'; + | ^^ + +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:20:15 + | +LL | let _ = b'/u'; + | ^^ + +error: numeric character escape is too short + --> $DIR/issue-23620-invalid-escapes.rs:24:17 + | +LL | let _ = b'/x5'; + | ^ + +error: invalid character in numeric character escape: x + --> $DIR/issue-23620-invalid-escapes.rs:27:17 + | +LL | let _ = b'/xxy'; + | ^ + +error: invalid character in numeric character escape: y + --> $DIR/issue-23620-invalid-escapes.rs:27:18 + | +LL | let _ = b'/xxy'; + | ^ + +error: numeric character escape is too short + --> $DIR/issue-23620-invalid-escapes.rs:31:16 + | +LL | let _ = '/x5'; + | ^ + +error: invalid character in numeric character escape: x + --> $DIR/issue-23620-invalid-escapes.rs:34:16 + | +LL | let _ = '/xxy'; + | ^ + +error: invalid character in numeric character escape: y + --> $DIR/issue-23620-invalid-escapes.rs:34:17 + | +LL | let _ = '/xxy'; + | ^ + +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:38:15 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^^^^^^^^ + +error: invalid character in numeric character escape: + --> $DIR/issue-23620-invalid-escapes.rs:38:27 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^ + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:38:28 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^^ + | +help: format of unicode escape sequences is `/u{…}` + --> $DIR/issue-23620-invalid-escapes.rs:38:28 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^^ + +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:38:28 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^^ + +error: invalid character in numeric character escape: + --> $DIR/issue-23620-invalid-escapes.rs:44:17 + | +LL | let _ = "/xf /u"; + | ^ + +error: this form of character escape may only be used with characters in the range [/x00-/x7f] + --> $DIR/issue-23620-invalid-escapes.rs:44:16 + | +LL | let _ = "/xf /u"; + | ^^ + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:44:18 + | +LL | let _ = "/xf /u"; + | ^^ + | +help: format of unicode escape sequences is `/u{…}` + --> $DIR/issue-23620-invalid-escapes.rs:44:18 + | +LL | let _ = "/xf /u"; + | ^^ + +error: aborting due to 17 previous errors + diff --git a/src/test/ui/parser/issue-24197.rs b/src/test/ui/parser/issue-24197.rs new file mode 100644 index 00000000000..8e098655a52 --- /dev/null +++ b/src/test/ui/parser/issue-24197.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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 main() { + let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` +} diff --git a/src/test/ui/parser/issue-24197.stderr b/src/test/ui/parser/issue-24197.stderr new file mode 100644 index 00000000000..567c4f1f21b --- /dev/null +++ b/src/test/ui/parser/issue-24197.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `[` + --> $DIR/issue-24197.rs:14:12 + | +LL | let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-24375.rs b/src/test/ui/parser/issue-24375.rs new file mode 100644 index 00000000000..aca50fdaf10 --- /dev/null +++ b/src/test/ui/parser/issue-24375.rs @@ -0,0 +1,21 @@ +// Copyright 2015 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 + +static tmp : [&'static str; 2] = ["hello", "he"]; + +fn main() { + let z = "hello"; + match z { + tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[` + _ => {} + } +} diff --git a/src/test/ui/parser/issue-24375.stderr b/src/test/ui/parser/issue-24375.stderr new file mode 100644 index 00000000000..0a9be6f4d2a --- /dev/null +++ b/src/test/ui/parser/issue-24375.stderr @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `[` + --> $DIR/issue-24375.rs:18:12 + | +LL | tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[` + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-24780.rs b/src/test/ui/parser/issue-24780.rs new file mode 100644 index 00000000000..6fd4ee38a4d --- /dev/null +++ b/src/test/ui/parser/issue-24780.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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. + +// Verify that '>' is not both expected and found at the same time, as it used +// to happen in #24780. For example, following should be an error: +// expected one of ..., `>`, ... found `>` +// +// compile-flags: -Z parse-only + +fn foo() -> Vec<usize>> { + //~^ ERROR expected one of `!`, `+`, `::`, `where`, or `{`, found `>` + Vec::new() +} diff --git a/src/test/ui/parser/issue-24780.stderr b/src/test/ui/parser/issue-24780.stderr new file mode 100644 index 00000000000..01f110e3d24 --- /dev/null +++ b/src/test/ui/parser/issue-24780.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `+`, `::`, `where`, or `{`, found `>` + --> $DIR/issue-24780.rs:17:23 + | +LL | fn foo() -> Vec<usize>> { + | ^ expected one of `!`, `+`, `::`, `where`, or `{` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-27255.rs b/src/test/ui/parser/issue-27255.rs new file mode 100644 index 00000000000..a751c4af494 --- /dev/null +++ b/src/test/ui/parser/issue-27255.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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 + +impl A .. {} //~ ERROR + +fn main() {} diff --git a/src/test/ui/parser/issue-27255.stderr b/src/test/ui/parser/issue-27255.stderr new file mode 100644 index 00000000000..9caa6087420 --- /dev/null +++ b/src/test/ui/parser/issue-27255.stderr @@ -0,0 +1,8 @@ +error: missing `for` in a trait impl + --> $DIR/issue-27255.rs:13:7 + | +LL | impl A .. {} //~ ERROR + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-30318.rs b/src/test/ui/parser/issue-30318.rs new file mode 100644 index 00000000000..9ea0bb78283 --- /dev/null +++ b/src/test/ui/parser/issue-30318.rs @@ -0,0 +1,19 @@ +// Copyright 2016 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() { } + +//! Misplaced comment... +//~^ ERROR expected outer doc comment +//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items + +fn main() { } diff --git a/src/test/ui/parser/issue-30318.stderr b/src/test/ui/parser/issue-30318.stderr new file mode 100644 index 00000000000..778a58463f7 --- /dev/null +++ b/src/test/ui/parser/issue-30318.stderr @@ -0,0 +1,10 @@ +error: expected outer doc comment + --> $DIR/issue-30318.rs:15:1 + | +LL | //! Misplaced comment... + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-3036.rs b/src/test/ui/parser/issue-3036.rs new file mode 100644 index 00000000000..229b12136fc --- /dev/null +++ b/src/test/ui/parser/issue-3036.rs @@ -0,0 +1,18 @@ +// 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 + +// Testing that semicolon tokens are printed correctly in errors + +fn main() +{ + let x = 3 +} //~ ERROR: expected one of `.`, `;`, `?`, or an operator, found `}` diff --git a/src/test/ui/parser/issue-3036.stderr b/src/test/ui/parser/issue-3036.stderr new file mode 100644 index 00000000000..e0e398381b7 --- /dev/null +++ b/src/test/ui/parser/issue-3036.stderr @@ -0,0 +1,10 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `}` + --> $DIR/issue-3036.rs:18:1 + | +LL | let x = 3 + | - expected one of `.`, `;`, `?`, or an operator here +LL | } //~ ERROR: expected one of `.`, `;`, `?`, or an operator, found `}` + | ^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-32214.rs b/src/test/ui/parser/issue-32214.rs new file mode 100644 index 00000000000..9e200094093 --- /dev/null +++ b/src/test/ui/parser/issue-32214.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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 -Z continue-parse-after-error + +pub fn test<W, I: Iterator<Item=(), W> >() {} +//~^ ERROR type parameters must be declared prior to associated type bindings + +fn main() { } diff --git a/src/test/ui/parser/issue-32214.stderr b/src/test/ui/parser/issue-32214.stderr new file mode 100644 index 00000000000..cce6cf6ede2 --- /dev/null +++ b/src/test/ui/parser/issue-32214.stderr @@ -0,0 +1,8 @@ +error: type parameters must be declared prior to associated type bindings + --> $DIR/issue-32214.rs:13:37 + | +LL | pub fn test<W, I: Iterator<Item=(), W> >() {} + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-32446.rs b/src/test/ui/parser/issue-32446.rs new file mode 100644 index 00000000000..90b9a4aae8b --- /dev/null +++ b/src/test/ui/parser/issue-32446.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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 main() {} + +// This used to end up in an infite loop trying to bump past EOF. +trait T { ... } //~ ERROR diff --git a/src/test/ui/parser/issue-32446.stderr b/src/test/ui/parser/issue-32446.stderr new file mode 100644 index 00000000000..608a9a6e6e0 --- /dev/null +++ b/src/test/ui/parser/issue-32446.stderr @@ -0,0 +1,8 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `...` + --> $DIR/issue-32446.rs:16:11 + | +LL | trait T { ... } //~ ERROR + | ^^^ expected one of 7 possible tokens here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-32501.rs b/src/test/ui/parser/issue-32501.rs new file mode 100644 index 00000000000..21db2f50517 --- /dev/null +++ b/src/test/ui/parser/issue-32501.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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 main() { + let a = 0; + let _b = 0; + let _ = 0; + let mut b = 0; + let mut _b = 0; + let mut _ = 0; //~ ERROR expected identifier, found reserved identifier `_` +} diff --git a/src/test/ui/parser/issue-32501.stderr b/src/test/ui/parser/issue-32501.stderr new file mode 100644 index 00000000000..6836509ebba --- /dev/null +++ b/src/test/ui/parser/issue-32501.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-32501.rs:19:13 + | +LL | let mut _ = 0; //~ ERROR expected identifier, found reserved identifier `_` + | ^ expected identifier, found reserved identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-32505.rs b/src/test/ui/parser/issue-32505.rs new file mode 100644 index 00000000000..246941ff259 --- /dev/null +++ b/src/test/ui/parser/issue-32505.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +pub fn test() { + foo(|_|) //~ ERROR expected expression, found `)` +} + +fn main() { } diff --git a/src/test/ui/parser/issue-32505.stderr b/src/test/ui/parser/issue-32505.stderr new file mode 100644 index 00000000000..e89c907a3b7 --- /dev/null +++ b/src/test/ui/parser/issue-32505.stderr @@ -0,0 +1,8 @@ +error: expected expression, found `)` + --> $DIR/issue-32505.rs:14:12 + | +LL | foo(|_|) //~ ERROR expected expression, found `)` + | ^ expected expression + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-33262.rs b/src/test/ui/parser/issue-33262.rs new file mode 100644 index 00000000000..d6bbfdc59f5 --- /dev/null +++ b/src/test/ui/parser/issue-33262.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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 + +// Issue #33262 + +pub fn main() { + for i in 0..a as { } + //~^ ERROR expected type, found `{` +} diff --git a/src/test/ui/parser/issue-33262.stderr b/src/test/ui/parser/issue-33262.stderr new file mode 100644 index 00000000000..184dacdaca4 --- /dev/null +++ b/src/test/ui/parser/issue-33262.stderr @@ -0,0 +1,8 @@ +error: expected type, found `{` + --> $DIR/issue-33262.rs:16:22 + | +LL | for i in 0..a as { } + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-33413.rs b/src/test/ui/parser/issue-33413.rs new file mode 100644 index 00000000000..7c3b84a5185 --- /dev/null +++ b/src/test/ui/parser/issue-33413.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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 + +impl S { + fn f(*, a: u8) -> u8 {} + //~^ ERROR expected argument name, found `*` +} diff --git a/src/test/ui/parser/issue-33413.stderr b/src/test/ui/parser/issue-33413.stderr new file mode 100644 index 00000000000..e0d69e596f2 --- /dev/null +++ b/src/test/ui/parser/issue-33413.stderr @@ -0,0 +1,8 @@ +error: expected argument name, found `*` + --> $DIR/issue-33413.rs:14:10 + | +LL | fn f(*, a: u8) -> u8 {} + | ^ expected argument name + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-33455.rs b/src/test/ui/parser/issue-33455.rs new file mode 100644 index 00000000000..6a9d03cdd91 --- /dev/null +++ b/src/test/ui/parser/issue-33455.rs @@ -0,0 +1,13 @@ +// Copyright 2016 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 + +use foo.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.` diff --git a/src/test/ui/parser/issue-33455.stderr b/src/test/ui/parser/issue-33455.stderr new file mode 100644 index 00000000000..cc9bb2d7c93 --- /dev/null +++ b/src/test/ui/parser/issue-33455.stderr @@ -0,0 +1,8 @@ +error: expected one of `::`, `;`, or `as`, found `.` + --> $DIR/issue-33455.rs:13:8 + | +LL | use foo.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.` + | ^ expected one of `::`, `;`, or `as` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-41155.rs b/src/test/ui/parser/issue-41155.rs new file mode 100644 index 00000000000..3d234dc378a --- /dev/null +++ b/src/test/ui/parser/issue-41155.rs @@ -0,0 +1,17 @@ +// Copyright 2017 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 + +impl S { + pub +} //~ ERROR expected one of + +fn main() {} diff --git a/src/test/ui/parser/issue-41155.stderr b/src/test/ui/parser/issue-41155.stderr new file mode 100644 index 00000000000..34b78fca3bd --- /dev/null +++ b/src/test/ui/parser/issue-41155.stderr @@ -0,0 +1,10 @@ +error: expected one of `(`, `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `}` + --> $DIR/issue-41155.rs:15:1 + | +LL | pub + | - expected one of 9 possible tokens here +LL | } //~ ERROR expected one of + | ^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-43692.rs b/src/test/ui/parser/issue-43692.rs new file mode 100644 index 00000000000..eb5d050e102 --- /dev/null +++ b/src/test/ui/parser/issue-43692.rs @@ -0,0 +1,15 @@ +// Copyright 2017 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 main() { + '\u{_10FFFF}'; //~ ERROR invalid start of unicode escape +} diff --git a/src/test/ui/parser/issue-43692.stderr b/src/test/ui/parser/issue-43692.stderr new file mode 100644 index 00000000000..c5ea50be487 --- /dev/null +++ b/src/test/ui/parser/issue-43692.stderr @@ -0,0 +1,8 @@ +error: invalid start of unicode escape + --> $DIR/issue-43692.rs:14:9 + | +LL | '/u{_10FFFF}'; //~ ERROR invalid start of unicode escape + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-5544-a.rs b/src/test/ui/parser/issue-5544-a.rs new file mode 100644 index 00000000000..cf1500e34d8 --- /dev/null +++ b/src/test/ui/parser/issue-5544-a.rs @@ -0,0 +1,16 @@ +// 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 <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 main() { + let __isize = 340282366920938463463374607431768211456; // 2^128 + //~^ ERROR int literal is too large +} diff --git a/src/test/ui/parser/issue-5544-a.stderr b/src/test/ui/parser/issue-5544-a.stderr new file mode 100644 index 00000000000..7fd3bc9d6ea --- /dev/null +++ b/src/test/ui/parser/issue-5544-a.stderr @@ -0,0 +1,8 @@ +error: int literal is too large + --> $DIR/issue-5544-a.rs:14:19 + | +LL | let __isize = 340282366920938463463374607431768211456; // 2^128 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-5544-b.rs b/src/test/ui/parser/issue-5544-b.rs new file mode 100644 index 00000000000..8c0b6741cb8 --- /dev/null +++ b/src/test/ui/parser/issue-5544-b.rs @@ -0,0 +1,16 @@ +// 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 <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 main() { + let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff; + //~^ ERROR int literal is too large +} diff --git a/src/test/ui/parser/issue-5544-b.stderr b/src/test/ui/parser/issue-5544-b.stderr new file mode 100644 index 00000000000..338b39b85b1 --- /dev/null +++ b/src/test/ui/parser/issue-5544-b.stderr @@ -0,0 +1,8 @@ +error: int literal is too large + --> $DIR/issue-5544-b.rs:14:19 + | +LL | let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-5806.rs b/src/test/ui/parser/issue-5806.rs new file mode 100644 index 00000000000..3622d59a514 --- /dev/null +++ b/src/test/ui/parser/issue-5806.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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 +// normalize-stderr-test: "parser:.*\(" -> "parser: $$ACCESS_DENIED_MSG (" +// normalize-stderr-test: "os error \d+" -> "os error $$ACCESS_DENIED_CODE" + +#[path = "../parser"] +mod foo; //~ ERROR couldn't read + +fn main() {} diff --git a/src/test/ui/parser/issue-5806.stderr b/src/test/ui/parser/issue-5806.stderr new file mode 100644 index 00000000000..63beed2873f --- /dev/null +++ b/src/test/ui/parser/issue-5806.stderr @@ -0,0 +1,8 @@ +error: couldn't read $DIR/../parser: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE) + --> $DIR/issue-5806.rs:16:5 + | +LL | mod foo; //~ ERROR couldn't read + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-6610.rs b/src/test/ui/parser/issue-6610.rs new file mode 100644 index 00000000000..f5113efad1c --- /dev/null +++ b/src/test/ui/parser/issue-6610.rs @@ -0,0 +1,15 @@ +// 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 <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 + +trait Foo { fn a() } //~ ERROR expected `;` or `{`, found `}` + +fn main() {} diff --git a/src/test/ui/parser/issue-6610.stderr b/src/test/ui/parser/issue-6610.stderr new file mode 100644 index 00000000000..d6013b32c96 --- /dev/null +++ b/src/test/ui/parser/issue-6610.stderr @@ -0,0 +1,8 @@ +error: expected `;` or `{`, found `}` + --> $DIR/issue-6610.rs:13:20 + | +LL | trait Foo { fn a() } //~ ERROR expected `;` or `{`, found `}` + | ^ expected `;` or `{` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-8537.rs b/src/test/ui/parser/issue-8537.rs new file mode 100644 index 00000000000..e152a369290 --- /dev/null +++ b/src/test/ui/parser/issue-8537.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 + +pub extern + "invalid-ab_isize" //~ ERROR invalid ABI +fn foo() {} + +fn main() {} diff --git a/src/test/ui/parser/issue-8537.stderr b/src/test/ui/parser/issue-8537.stderr new file mode 100644 index 00000000000..0013f972220 --- /dev/null +++ b/src/test/ui/parser/issue-8537.stderr @@ -0,0 +1,11 @@ +error[E0703]: invalid ABI: found `invalid-ab_isize` + --> $DIR/issue-8537.rs:14:3 + | +LL | "invalid-ab_isize" //~ ERROR invalid ABI + | ^^^^^^^^^^^^^^^^^^ invalid ABI + | + = help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0703`. diff --git a/src/test/ui/parser/keyword-abstract.rs b/src/test/ui/parser/keyword-abstract.rs new file mode 100644 index 00000000000..2db5a5c583a --- /dev/null +++ b/src/test/ui/parser/keyword-abstract.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 main() { + let abstract = (); //~ ERROR expected pattern, found reserved keyword `abstract` +} diff --git a/src/test/ui/parser/keyword-abstract.stderr b/src/test/ui/parser/keyword-abstract.stderr new file mode 100644 index 00000000000..1d3ed0d9b3e --- /dev/null +++ b/src/test/ui/parser/keyword-abstract.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `abstract` + --> $DIR/keyword-abstract.rs:14:9 + | +LL | let abstract = (); //~ ERROR expected pattern, found reserved keyword `abstract` + | ^^^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-as-as-identifier.rs b/src/test/ui/parser/keyword-as-as-identifier.rs new file mode 100644 index 00000000000..c6070c456e8 --- /dev/null +++ b/src/test/ui/parser/keyword-as-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py as' + +fn main() { + let as = "foo"; //~ error: expected pattern, found keyword `as` +} diff --git a/src/test/ui/parser/keyword-as-as-identifier.stderr b/src/test/ui/parser/keyword-as-as-identifier.stderr new file mode 100644 index 00000000000..a6295c2fca1 --- /dev/null +++ b/src/test/ui/parser/keyword-as-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `as` + --> $DIR/keyword-as-as-identifier.rs:16:9 + | +LL | let as = "foo"; //~ error: expected pattern, found keyword `as` + | ^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-box-as-identifier.rs b/src/test/ui/parser/keyword-box-as-identifier.rs new file mode 100644 index 00000000000..b5abe14dbe8 --- /dev/null +++ b/src/test/ui/parser/keyword-box-as-identifier.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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 main() { + let box = "foo"; //~ error: expected pattern, found `=` +} diff --git a/src/test/ui/parser/keyword-box-as-identifier.stderr b/src/test/ui/parser/keyword-box-as-identifier.stderr new file mode 100644 index 00000000000..4e9984c2871 --- /dev/null +++ b/src/test/ui/parser/keyword-box-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found `=` + --> $DIR/keyword-box-as-identifier.rs:14:13 + | +LL | let box = "foo"; //~ error: expected pattern, found `=` + | ^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-break-as-identifier.rs b/src/test/ui/parser/keyword-break-as-identifier.rs new file mode 100644 index 00000000000..65c775fa1b6 --- /dev/null +++ b/src/test/ui/parser/keyword-break-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py break' + +fn main() { + let break = "foo"; //~ error: expected pattern, found keyword `break` +} diff --git a/src/test/ui/parser/keyword-break-as-identifier.stderr b/src/test/ui/parser/keyword-break-as-identifier.stderr new file mode 100644 index 00000000000..9e2d2c9caac --- /dev/null +++ b/src/test/ui/parser/keyword-break-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `break` + --> $DIR/keyword-break-as-identifier.rs:16:9 + | +LL | let break = "foo"; //~ error: expected pattern, found keyword `break` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-const-as-identifier.rs b/src/test/ui/parser/keyword-const-as-identifier.rs new file mode 100644 index 00000000000..6ecf14957e3 --- /dev/null +++ b/src/test/ui/parser/keyword-const-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py const' + +fn main() { + let const = "foo"; //~ error: expected pattern, found keyword `const` +} diff --git a/src/test/ui/parser/keyword-const-as-identifier.stderr b/src/test/ui/parser/keyword-const-as-identifier.stderr new file mode 100644 index 00000000000..d662fefda70 --- /dev/null +++ b/src/test/ui/parser/keyword-const-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `const` + --> $DIR/keyword-const-as-identifier.rs:16:9 + | +LL | let const = "foo"; //~ error: expected pattern, found keyword `const` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-continue-as-identifier.rs b/src/test/ui/parser/keyword-continue-as-identifier.rs new file mode 100644 index 00000000000..87377ac8364 --- /dev/null +++ b/src/test/ui/parser/keyword-continue-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py continue' + +fn main() { + let continue = "foo"; //~ error: expected pattern, found keyword `continue` +} diff --git a/src/test/ui/parser/keyword-continue-as-identifier.stderr b/src/test/ui/parser/keyword-continue-as-identifier.stderr new file mode 100644 index 00000000000..52409c1f6bb --- /dev/null +++ b/src/test/ui/parser/keyword-continue-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `continue` + --> $DIR/keyword-continue-as-identifier.rs:16:9 + | +LL | let continue = "foo"; //~ error: expected pattern, found keyword `continue` + | ^^^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-else-as-identifier.rs b/src/test/ui/parser/keyword-else-as-identifier.rs new file mode 100644 index 00000000000..6878f7fea03 --- /dev/null +++ b/src/test/ui/parser/keyword-else-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py else' + +fn main() { + let else = "foo"; //~ error: expected pattern, found keyword `else` +} diff --git a/src/test/ui/parser/keyword-else-as-identifier.stderr b/src/test/ui/parser/keyword-else-as-identifier.stderr new file mode 100644 index 00000000000..ab075a52141 --- /dev/null +++ b/src/test/ui/parser/keyword-else-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `else` + --> $DIR/keyword-else-as-identifier.rs:16:9 + | +LL | let else = "foo"; //~ error: expected pattern, found keyword `else` + | ^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-enum-as-identifier.rs b/src/test/ui/parser/keyword-enum-as-identifier.rs new file mode 100644 index 00000000000..042a02d79e0 --- /dev/null +++ b/src/test/ui/parser/keyword-enum-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py enum' + +fn main() { + let enum = "foo"; //~ error: expected pattern, found keyword `enum` +} diff --git a/src/test/ui/parser/keyword-enum-as-identifier.stderr b/src/test/ui/parser/keyword-enum-as-identifier.stderr new file mode 100644 index 00000000000..f8370134741 --- /dev/null +++ b/src/test/ui/parser/keyword-enum-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `enum` + --> $DIR/keyword-enum-as-identifier.rs:16:9 + | +LL | let enum = "foo"; //~ error: expected pattern, found keyword `enum` + | ^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-final.rs b/src/test/ui/parser/keyword-final.rs new file mode 100644 index 00000000000..be29a739443 --- /dev/null +++ b/src/test/ui/parser/keyword-final.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 main() { + let final = (); //~ ERROR expected pattern, found reserved keyword `final` +} diff --git a/src/test/ui/parser/keyword-final.stderr b/src/test/ui/parser/keyword-final.stderr new file mode 100644 index 00000000000..8ace453f362 --- /dev/null +++ b/src/test/ui/parser/keyword-final.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `final` + --> $DIR/keyword-final.rs:14:9 + | +LL | let final = (); //~ ERROR expected pattern, found reserved keyword `final` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-fn-as-identifier.rs b/src/test/ui/parser/keyword-fn-as-identifier.rs new file mode 100644 index 00000000000..0d454f67d1c --- /dev/null +++ b/src/test/ui/parser/keyword-fn-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py fn' + +fn main() { + let fn = "foo"; //~ error: expected pattern, found keyword `fn` +} diff --git a/src/test/ui/parser/keyword-fn-as-identifier.stderr b/src/test/ui/parser/keyword-fn-as-identifier.stderr new file mode 100644 index 00000000000..bf63775fc9b --- /dev/null +++ b/src/test/ui/parser/keyword-fn-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `fn` + --> $DIR/keyword-fn-as-identifier.rs:16:9 + | +LL | let fn = "foo"; //~ error: expected pattern, found keyword `fn` + | ^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-for-as-identifier.rs b/src/test/ui/parser/keyword-for-as-identifier.rs new file mode 100644 index 00000000000..d341669f727 --- /dev/null +++ b/src/test/ui/parser/keyword-for-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py for' + +fn main() { + let for = "foo"; //~ error: expected pattern, found keyword `for` +} diff --git a/src/test/ui/parser/keyword-for-as-identifier.stderr b/src/test/ui/parser/keyword-for-as-identifier.stderr new file mode 100644 index 00000000000..ed28f77a252 --- /dev/null +++ b/src/test/ui/parser/keyword-for-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `for` + --> $DIR/keyword-for-as-identifier.rs:16:9 + | +LL | let for = "foo"; //~ error: expected pattern, found keyword `for` + | ^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-if-as-identifier.rs b/src/test/ui/parser/keyword-if-as-identifier.rs new file mode 100644 index 00000000000..417e40425e0 --- /dev/null +++ b/src/test/ui/parser/keyword-if-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py if' + +fn main() { + let if = "foo"; //~ error: expected pattern, found keyword `if` +} diff --git a/src/test/ui/parser/keyword-if-as-identifier.stderr b/src/test/ui/parser/keyword-if-as-identifier.stderr new file mode 100644 index 00000000000..bfb7ab78bcf --- /dev/null +++ b/src/test/ui/parser/keyword-if-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `if` + --> $DIR/keyword-if-as-identifier.rs:16:9 + | +LL | let if = "foo"; //~ error: expected pattern, found keyword `if` + | ^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-impl-as-identifier.rs b/src/test/ui/parser/keyword-impl-as-identifier.rs new file mode 100644 index 00000000000..fe97c191f68 --- /dev/null +++ b/src/test/ui/parser/keyword-impl-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py impl' + +fn main() { + let impl = "foo"; //~ error: expected pattern, found keyword `impl` +} diff --git a/src/test/ui/parser/keyword-impl-as-identifier.stderr b/src/test/ui/parser/keyword-impl-as-identifier.stderr new file mode 100644 index 00000000000..43f7072981e --- /dev/null +++ b/src/test/ui/parser/keyword-impl-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `impl` + --> $DIR/keyword-impl-as-identifier.rs:16:9 + | +LL | let impl = "foo"; //~ error: expected pattern, found keyword `impl` + | ^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-in-as-identifier.rs b/src/test/ui/parser/keyword-in-as-identifier.rs new file mode 100644 index 00000000000..c0f9396b981 --- /dev/null +++ b/src/test/ui/parser/keyword-in-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py in' + +fn main() { + let in = "foo"; //~ error: expected pattern, found keyword `in` +} diff --git a/src/test/ui/parser/keyword-in-as-identifier.stderr b/src/test/ui/parser/keyword-in-as-identifier.stderr new file mode 100644 index 00000000000..29bb5f4b724 --- /dev/null +++ b/src/test/ui/parser/keyword-in-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `in` + --> $DIR/keyword-in-as-identifier.rs:16:9 + | +LL | let in = "foo"; //~ error: expected pattern, found keyword `in` + | ^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-let-as-identifier.rs b/src/test/ui/parser/keyword-let-as-identifier.rs new file mode 100644 index 00000000000..5d6dca78d78 --- /dev/null +++ b/src/test/ui/parser/keyword-let-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py let' + +fn main() { + let let = "foo"; //~ error: expected pattern, found keyword `let` +} diff --git a/src/test/ui/parser/keyword-let-as-identifier.stderr b/src/test/ui/parser/keyword-let-as-identifier.stderr new file mode 100644 index 00000000000..7a28aee4657 --- /dev/null +++ b/src/test/ui/parser/keyword-let-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `let` + --> $DIR/keyword-let-as-identifier.rs:16:9 + | +LL | let let = "foo"; //~ error: expected pattern, found keyword `let` + | ^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-loop-as-identifier.rs b/src/test/ui/parser/keyword-loop-as-identifier.rs new file mode 100644 index 00000000000..7c3d11d67f6 --- /dev/null +++ b/src/test/ui/parser/keyword-loop-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py loop' + +fn main() { + let loop = "foo"; //~ error: expected pattern, found keyword `loop` +} diff --git a/src/test/ui/parser/keyword-loop-as-identifier.stderr b/src/test/ui/parser/keyword-loop-as-identifier.stderr new file mode 100644 index 00000000000..1dafe466d79 --- /dev/null +++ b/src/test/ui/parser/keyword-loop-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `loop` + --> $DIR/keyword-loop-as-identifier.rs:16:9 + | +LL | let loop = "foo"; //~ error: expected pattern, found keyword `loop` + | ^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-match-as-identifier.rs b/src/test/ui/parser/keyword-match-as-identifier.rs new file mode 100644 index 00000000000..7c727f44da7 --- /dev/null +++ b/src/test/ui/parser/keyword-match-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py match' + +fn main() { + let match = "foo"; //~ error: expected pattern, found keyword `match` +} diff --git a/src/test/ui/parser/keyword-match-as-identifier.stderr b/src/test/ui/parser/keyword-match-as-identifier.stderr new file mode 100644 index 00000000000..b3b542f1a1d --- /dev/null +++ b/src/test/ui/parser/keyword-match-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `match` + --> $DIR/keyword-match-as-identifier.rs:16:9 + | +LL | let match = "foo"; //~ error: expected pattern, found keyword `match` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-mod-as-identifier.rs b/src/test/ui/parser/keyword-mod-as-identifier.rs new file mode 100644 index 00000000000..85b4cc2e02c --- /dev/null +++ b/src/test/ui/parser/keyword-mod-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py mod' + +fn main() { + let mod = "foo"; //~ error: expected pattern, found keyword `mod` +} diff --git a/src/test/ui/parser/keyword-mod-as-identifier.stderr b/src/test/ui/parser/keyword-mod-as-identifier.stderr new file mode 100644 index 00000000000..113f7084b31 --- /dev/null +++ b/src/test/ui/parser/keyword-mod-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `mod` + --> $DIR/keyword-mod-as-identifier.rs:16:9 + | +LL | let mod = "foo"; //~ error: expected pattern, found keyword `mod` + | ^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-move-as-identifier.rs b/src/test/ui/parser/keyword-move-as-identifier.rs new file mode 100644 index 00000000000..b785ac0058c --- /dev/null +++ b/src/test/ui/parser/keyword-move-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py move' + +fn main() { + let move = "foo"; //~ error: expected pattern, found keyword `move` +} diff --git a/src/test/ui/parser/keyword-move-as-identifier.stderr b/src/test/ui/parser/keyword-move-as-identifier.stderr new file mode 100644 index 00000000000..21b66fbc1e1 --- /dev/null +++ b/src/test/ui/parser/keyword-move-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `move` + --> $DIR/keyword-move-as-identifier.rs:16:9 + | +LL | let move = "foo"; //~ error: expected pattern, found keyword `move` + | ^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-mut-as-identifier.rs b/src/test/ui/parser/keyword-mut-as-identifier.rs new file mode 100644 index 00000000000..0aeca9b34ab --- /dev/null +++ b/src/test/ui/parser/keyword-mut-as-identifier.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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 main() { + let mut = "foo"; //~ error: expected identifier, found `=` +} diff --git a/src/test/ui/parser/keyword-mut-as-identifier.stderr b/src/test/ui/parser/keyword-mut-as-identifier.stderr new file mode 100644 index 00000000000..bb153cf0e6c --- /dev/null +++ b/src/test/ui/parser/keyword-mut-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `=` + --> $DIR/keyword-mut-as-identifier.rs:14:13 + | +LL | let mut = "foo"; //~ error: expected identifier, found `=` + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-override.rs b/src/test/ui/parser/keyword-override.rs new file mode 100644 index 00000000000..60333762b33 --- /dev/null +++ b/src/test/ui/parser/keyword-override.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 main() { + let override = (); //~ ERROR expected pattern, found reserved keyword `override` +} diff --git a/src/test/ui/parser/keyword-override.stderr b/src/test/ui/parser/keyword-override.stderr new file mode 100644 index 00000000000..ce1d4f27716 --- /dev/null +++ b/src/test/ui/parser/keyword-override.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `override` + --> $DIR/keyword-override.rs:14:9 + | +LL | let override = (); //~ ERROR expected pattern, found reserved keyword `override` + | ^^^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-pub-as-identifier.rs b/src/test/ui/parser/keyword-pub-as-identifier.rs new file mode 100644 index 00000000000..92337286970 --- /dev/null +++ b/src/test/ui/parser/keyword-pub-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py pub' + +fn main() { + let pub = "foo"; //~ error: expected pattern, found keyword `pub` +} diff --git a/src/test/ui/parser/keyword-pub-as-identifier.stderr b/src/test/ui/parser/keyword-pub-as-identifier.stderr new file mode 100644 index 00000000000..b52982d144d --- /dev/null +++ b/src/test/ui/parser/keyword-pub-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `pub` + --> $DIR/keyword-pub-as-identifier.rs:16:9 + | +LL | let pub = "foo"; //~ error: expected pattern, found keyword `pub` + | ^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-ref-as-identifier.rs b/src/test/ui/parser/keyword-ref-as-identifier.rs new file mode 100644 index 00000000000..a689c4eeea4 --- /dev/null +++ b/src/test/ui/parser/keyword-ref-as-identifier.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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 main() { + let ref = "foo"; //~ error: expected identifier, found `=` +} diff --git a/src/test/ui/parser/keyword-ref-as-identifier.stderr b/src/test/ui/parser/keyword-ref-as-identifier.stderr new file mode 100644 index 00000000000..34063c88d33 --- /dev/null +++ b/src/test/ui/parser/keyword-ref-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `=` + --> $DIR/keyword-ref-as-identifier.rs:14:13 + | +LL | let ref = "foo"; //~ error: expected identifier, found `=` + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-return-as-identifier.rs b/src/test/ui/parser/keyword-return-as-identifier.rs new file mode 100644 index 00000000000..bcf7f137543 --- /dev/null +++ b/src/test/ui/parser/keyword-return-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py return' + +fn main() { + let return = "foo"; //~ error: expected pattern, found keyword `return` +} diff --git a/src/test/ui/parser/keyword-return-as-identifier.stderr b/src/test/ui/parser/keyword-return-as-identifier.stderr new file mode 100644 index 00000000000..8d8b2aabbdc --- /dev/null +++ b/src/test/ui/parser/keyword-return-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `return` + --> $DIR/keyword-return-as-identifier.rs:16:9 + | +LL | let return = "foo"; //~ error: expected pattern, found keyword `return` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-static-as-identifier.rs b/src/test/ui/parser/keyword-static-as-identifier.rs new file mode 100644 index 00000000000..793262266a3 --- /dev/null +++ b/src/test/ui/parser/keyword-static-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py static' + +fn main() { + let static = "foo"; //~ error: expected pattern, found keyword `static` +} diff --git a/src/test/ui/parser/keyword-static-as-identifier.stderr b/src/test/ui/parser/keyword-static-as-identifier.stderr new file mode 100644 index 00000000000..4c1a0d1a0b0 --- /dev/null +++ b/src/test/ui/parser/keyword-static-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `static` + --> $DIR/keyword-static-as-identifier.rs:16:9 + | +LL | let static = "foo"; //~ error: expected pattern, found keyword `static` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-struct-as-identifier.rs b/src/test/ui/parser/keyword-struct-as-identifier.rs new file mode 100644 index 00000000000..591bd25db65 --- /dev/null +++ b/src/test/ui/parser/keyword-struct-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py struct' + +fn main() { + let struct = "foo"; //~ error: expected pattern, found keyword `struct` +} diff --git a/src/test/ui/parser/keyword-struct-as-identifier.stderr b/src/test/ui/parser/keyword-struct-as-identifier.stderr new file mode 100644 index 00000000000..76179ce7ea7 --- /dev/null +++ b/src/test/ui/parser/keyword-struct-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `struct` + --> $DIR/keyword-struct-as-identifier.rs:16:9 + | +LL | let struct = "foo"; //~ error: expected pattern, found keyword `struct` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-trait-as-identifier.rs b/src/test/ui/parser/keyword-trait-as-identifier.rs new file mode 100644 index 00000000000..bdb5d264b03 --- /dev/null +++ b/src/test/ui/parser/keyword-trait-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py trait' + +fn main() { + let trait = "foo"; //~ error: expected pattern, found keyword `trait` +} diff --git a/src/test/ui/parser/keyword-trait-as-identifier.stderr b/src/test/ui/parser/keyword-trait-as-identifier.stderr new file mode 100644 index 00000000000..084b785f867 --- /dev/null +++ b/src/test/ui/parser/keyword-trait-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `trait` + --> $DIR/keyword-trait-as-identifier.rs:16:9 + | +LL | let trait = "foo"; //~ error: expected pattern, found keyword `trait` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-try-as-identifier-edition2018.rs b/src/test/ui/parser/keyword-try-as-identifier-edition2018.rs new file mode 100644 index 00000000000..1e4f85c122d --- /dev/null +++ b/src/test/ui/parser/keyword-try-as-identifier-edition2018.rs @@ -0,0 +1,15 @@ +// 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. + +// compile-flags: -Z parse-only --edition 2018 + +fn main() { + let try = "foo"; //~ error: expected pattern, found reserved keyword `try` +} diff --git a/src/test/ui/parser/keyword-try-as-identifier-edition2018.stderr b/src/test/ui/parser/keyword-try-as-identifier-edition2018.stderr new file mode 100644 index 00000000000..9306f95d855 --- /dev/null +++ b/src/test/ui/parser/keyword-try-as-identifier-edition2018.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `try` + --> $DIR/keyword-try-as-identifier-edition2018.rs:14:9 + | +LL | let try = "foo"; //~ error: expected pattern, found reserved keyword `try` + | ^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-type-as-identifier.rs b/src/test/ui/parser/keyword-type-as-identifier.rs new file mode 100644 index 00000000000..2ba99d098de --- /dev/null +++ b/src/test/ui/parser/keyword-type-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py type' + +fn main() { + let type = "foo"; //~ error: expected pattern, found keyword `type` +} diff --git a/src/test/ui/parser/keyword-type-as-identifier.stderr b/src/test/ui/parser/keyword-type-as-identifier.stderr new file mode 100644 index 00000000000..03e0bd7dfa9 --- /dev/null +++ b/src/test/ui/parser/keyword-type-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `type` + --> $DIR/keyword-type-as-identifier.rs:16:9 + | +LL | let type = "foo"; //~ error: expected pattern, found keyword `type` + | ^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-typeof.rs b/src/test/ui/parser/keyword-typeof.rs new file mode 100644 index 00000000000..40e26bd375a --- /dev/null +++ b/src/test/ui/parser/keyword-typeof.rs @@ -0,0 +1,15 @@ +// 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 <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 main() { + let typeof = (); //~ ERROR expected pattern, found reserved keyword `typeof` +} diff --git a/src/test/ui/parser/keyword-typeof.stderr b/src/test/ui/parser/keyword-typeof.stderr new file mode 100644 index 00000000000..1c0cd0cca0d --- /dev/null +++ b/src/test/ui/parser/keyword-typeof.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `typeof` + --> $DIR/keyword-typeof.rs:14:9 + | +LL | let typeof = (); //~ ERROR expected pattern, found reserved keyword `typeof` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-unsafe-as-identifier.rs b/src/test/ui/parser/keyword-unsafe-as-identifier.rs new file mode 100644 index 00000000000..a72723e566d --- /dev/null +++ b/src/test/ui/parser/keyword-unsafe-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py unsafe' + +fn main() { + let unsafe = "foo"; //~ error: expected pattern, found keyword `unsafe` +} diff --git a/src/test/ui/parser/keyword-unsafe-as-identifier.stderr b/src/test/ui/parser/keyword-unsafe-as-identifier.stderr new file mode 100644 index 00000000000..360bd21fa5f --- /dev/null +++ b/src/test/ui/parser/keyword-unsafe-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `unsafe` + --> $DIR/keyword-unsafe-as-identifier.rs:16:9 + | +LL | let unsafe = "foo"; //~ error: expected pattern, found keyword `unsafe` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-use-as-identifier.rs b/src/test/ui/parser/keyword-use-as-identifier.rs new file mode 100644 index 00000000000..de74907ff20 --- /dev/null +++ b/src/test/ui/parser/keyword-use-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py use' + +fn main() { + let use = "foo"; //~ error: expected pattern, found keyword `use` +} diff --git a/src/test/ui/parser/keyword-use-as-identifier.stderr b/src/test/ui/parser/keyword-use-as-identifier.stderr new file mode 100644 index 00000000000..bff29788107 --- /dev/null +++ b/src/test/ui/parser/keyword-use-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `use` + --> $DIR/keyword-use-as-identifier.rs:16:9 + | +LL | let use = "foo"; //~ error: expected pattern, found keyword `use` + | ^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-where-as-identifier.rs b/src/test/ui/parser/keyword-where-as-identifier.rs new file mode 100644 index 00000000000..4b7c8920b13 --- /dev/null +++ b/src/test/ui/parser/keyword-where-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py where' + +fn main() { + let where = "foo"; //~ error: expected pattern, found keyword `where` +} diff --git a/src/test/ui/parser/keyword-where-as-identifier.stderr b/src/test/ui/parser/keyword-where-as-identifier.stderr new file mode 100644 index 00000000000..38fe936befe --- /dev/null +++ b/src/test/ui/parser/keyword-where-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `where` + --> $DIR/keyword-where-as-identifier.rs:16:9 + | +LL | let where = "foo"; //~ error: expected pattern, found keyword `where` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword-while-as-identifier.rs b/src/test/ui/parser/keyword-while-as-identifier.rs new file mode 100644 index 00000000000..01793caa38a --- /dev/null +++ b/src/test/ui/parser/keyword-while-as-identifier.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py while' + +fn main() { + let while = "foo"; //~ error: expected pattern, found keyword `while` +} diff --git a/src/test/ui/parser/keyword-while-as-identifier.stderr b/src/test/ui/parser/keyword-while-as-identifier.stderr new file mode 100644 index 00000000000..c9dab8c5170 --- /dev/null +++ b/src/test/ui/parser/keyword-while-as-identifier.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `while` + --> $DIR/keyword-while-as-identifier.rs:16:9 + | +LL | let while = "foo"; //~ error: expected pattern, found keyword `while` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keyword.rs b/src/test/ui/parser/keyword.rs new file mode 100644 index 00000000000..d4ce5518e46 --- /dev/null +++ b/src/test/ui/parser/keyword.rs @@ -0,0 +1,15 @@ +// 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 + +pub mod break { + //~^ ERROR expected identifier, found keyword `break` +} diff --git a/src/test/ui/parser/keyword.stderr b/src/test/ui/parser/keyword.stderr new file mode 100644 index 00000000000..a3fc1677732 --- /dev/null +++ b/src/test/ui/parser/keyword.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found keyword `break` + --> $DIR/keyword.rs:13:9 + | +LL | pub mod break { + | ^^^^^ expected identifier, found keyword + +error: aborting due to previous error + diff --git a/src/test/ui/parser/keywords-followed-by-double-colon.rs b/src/test/ui/parser/keywords-followed-by-double-colon.rs new file mode 100644 index 00000000000..7a5b48c5f00 --- /dev/null +++ b/src/test/ui/parser/keywords-followed-by-double-colon.rs @@ -0,0 +1,20 @@ +// Copyright 2014 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 main() { + struct::foo(); + //~^ ERROR expected identifier +} +fn bar() { + mut::baz(); + //~^ ERROR expected expression, found keyword `mut` +} diff --git a/src/test/ui/parser/keywords-followed-by-double-colon.stderr b/src/test/ui/parser/keywords-followed-by-double-colon.stderr new file mode 100644 index 00000000000..049658571e8 --- /dev/null +++ b/src/test/ui/parser/keywords-followed-by-double-colon.stderr @@ -0,0 +1,14 @@ +error: expected identifier, found `::` + --> $DIR/keywords-followed-by-double-colon.rs:14:11 + | +LL | struct::foo(); + | ^^ expected identifier + +error: expected expression, found keyword `mut` + --> $DIR/keywords-followed-by-double-colon.rs:18:5 + | +LL | mut::baz(); + | ^^^ expected expression + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/lex-bad-binary-literal.rs b/src/test/ui/parser/lex-bad-binary-literal.rs new file mode 100644 index 00000000000..caacb12d008 --- /dev/null +++ b/src/test/ui/parser/lex-bad-binary-literal.rs @@ -0,0 +1,23 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +fn main() { + 0b121; //~ ERROR invalid digit for a base 2 literal + 0b10_10301; //~ ERROR invalid digit for a base 2 literal + 0b30; //~ ERROR invalid digit for a base 2 literal + 0b41; //~ ERROR invalid digit for a base 2 literal + 0b5; //~ ERROR invalid digit for a base 2 literal + 0b6; //~ ERROR invalid digit for a base 2 literal + 0b7; //~ ERROR invalid digit for a base 2 literal + 0b8; //~ ERROR invalid digit for a base 2 literal + 0b9; //~ ERROR invalid digit for a base 2 literal +} diff --git a/src/test/ui/parser/lex-bad-binary-literal.stderr b/src/test/ui/parser/lex-bad-binary-literal.stderr new file mode 100644 index 00000000000..2c23d8c3d61 --- /dev/null +++ b/src/test/ui/parser/lex-bad-binary-literal.stderr @@ -0,0 +1,56 @@ +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:14:8 + | +LL | 0b121; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:15:12 + | +LL | 0b10_10301; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:16:7 + | +LL | 0b30; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:17:7 + | +LL | 0b41; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:18:7 + | +LL | 0b5; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:19:7 + | +LL | 0b6; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:20:7 + | +LL | 0b7; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:21:7 + | +LL | 0b8; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:22:7 + | +LL | 0b9; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/parser/lex-bad-char-literals-1.rs b/src/test/ui/parser/lex-bad-char-literals-1.rs new file mode 100644 index 00000000000..006e3e68d8f --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-1.rs @@ -0,0 +1,27 @@ +// Copyright 2016 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 -Z continue-parse-after-error +static c3: char = + '\x1' //~ ERROR: numeric character escape is too short +; + +static s: &'static str = + "\x1" //~ ERROR: numeric character escape is too short +; + +static c: char = + '\●' //~ ERROR: unknown character escape +; + +static s: &'static str = + "\●" //~ ERROR: unknown character escape +; + diff --git a/src/test/ui/parser/lex-bad-char-literals-1.stderr b/src/test/ui/parser/lex-bad-char-literals-1.stderr new file mode 100644 index 00000000000..081eb2e9fed --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-1.stderr @@ -0,0 +1,26 @@ +error: numeric character escape is too short + --> $DIR/lex-bad-char-literals-1.rs:13:8 + | +LL | '/x1' //~ ERROR: numeric character escape is too short + | ^ + +error: numeric character escape is too short + --> $DIR/lex-bad-char-literals-1.rs:17:8 + | +LL | "/x1" //~ ERROR: numeric character escape is too short + | ^ + +error: unknown character escape: /u{25cf} + --> $DIR/lex-bad-char-literals-1.rs:21:7 + | +LL | '/●' //~ ERROR: unknown character escape + | ^ + +error: unknown character escape: /u{25cf} + --> $DIR/lex-bad-char-literals-1.rs:25:7 + | +LL | "/●" //~ ERROR: unknown character escape + | ^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/parser/lex-bad-char-literals-2.rs b/src/test/ui/parser/lex-bad-char-literals-2.rs new file mode 100644 index 00000000000..8bd6808c5ff --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-2.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + 'nope' //~ ERROR: character literal may only contain one codepoint: 'nope' +; + diff --git a/src/test/ui/parser/lex-bad-char-literals-2.stderr b/src/test/ui/parser/lex-bad-char-literals-2.stderr new file mode 100644 index 00000000000..ed129f5d427 --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-2.stderr @@ -0,0 +1,8 @@ +error: character literal may only contain one codepoint: 'nope' + --> $DIR/lex-bad-char-literals-2.rs:15:5 + | +LL | 'nope' //~ ERROR: character literal may only contain one codepoint: 'nope' + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/lex-bad-char-literals-3.rs b/src/test/ui/parser/lex-bad-char-literals-3.rs new file mode 100644 index 00000000000..464e75ec582 --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-3.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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 + +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + '●●' //~ ERROR: character literal may only contain one codepoint +; diff --git a/src/test/ui/parser/lex-bad-char-literals-3.stderr b/src/test/ui/parser/lex-bad-char-literals-3.stderr new file mode 100644 index 00000000000..f257b5b8268 --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-3.stderr @@ -0,0 +1,12 @@ +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-3.rs:15:5 + | +LL | '●●' //~ ERROR: character literal may only contain one codepoint + | ^^^^ +help: if you meant to write a `str` literal, use double quotes + | +LL | "●●" //~ ERROR: character literal may only contain one codepoint + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/lex-bad-char-literals-4.rs b/src/test/ui/parser/lex-bad-char-literals-4.rs new file mode 100644 index 00000000000..b230e623603 --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-4.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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 +// +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + '● //~ ERROR: character literal may only contain one codepoint: '● +; diff --git a/src/test/ui/parser/lex-bad-char-literals-4.stderr b/src/test/ui/parser/lex-bad-char-literals-4.stderr new file mode 100644 index 00000000000..495becd07d1 --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-4.stderr @@ -0,0 +1,8 @@ +error: character literal may only contain one codepoint: '● + --> $DIR/lex-bad-char-literals-4.rs:15:5 + | +LL | '● //~ ERROR: character literal may only contain one codepoint: '● + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/lex-bad-char-literals-5.rs b/src/test/ui/parser/lex-bad-char-literals-5.rs new file mode 100644 index 00000000000..aa166881d89 --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-5.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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 +// +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + '\x10\x10' //~ ERROR: character literal may only contain one codepoint +; diff --git a/src/test/ui/parser/lex-bad-char-literals-5.stderr b/src/test/ui/parser/lex-bad-char-literals-5.stderr new file mode 100644 index 00000000000..145361eb58a --- /dev/null +++ b/src/test/ui/parser/lex-bad-char-literals-5.stderr @@ -0,0 +1,12 @@ +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-5.rs:15:5 + | +LL | '/x10/x10' //~ ERROR: character literal may only contain one codepoint + | ^^^^^^^^^^ +help: if you meant to write a `str` literal, use double quotes + | +LL | "/x10/x10" //~ ERROR: character literal may only contain one codepoint + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/lex-bad-numeric-literals.rs b/src/test/ui/parser/lex-bad-numeric-literals.rs new file mode 100644 index 00000000000..d495a8edd09 --- /dev/null +++ b/src/test/ui/parser/lex-bad-numeric-literals.rs @@ -0,0 +1,37 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +fn main() { + 0o1.0; //~ ERROR: octal float literal is not supported + 0o2f32; //~ ERROR: octal float literal is not supported + 0o3.0f32; //~ ERROR: octal float literal is not supported + 0o4e4; //~ ERROR: octal float literal is not supported + 0o5.0e5; //~ ERROR: octal float literal is not supported + 0o6e6f32; //~ ERROR: octal float literal is not supported + 0o7.0e7f64; //~ ERROR: octal float literal is not supported + 0x8.0e+9; //~ ERROR: hexadecimal float literal is not supported + 0x9.0e-9; //~ ERROR: hexadecimal float literal is not supported + 0o; //~ ERROR: no valid digits + 1e+; //~ ERROR: expected at least one digit in exponent + 0x539.0; //~ ERROR: hexadecimal float literal is not supported + 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large + 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large + 0x; //~ ERROR: no valid digits + 0xu32; //~ ERROR: no valid digits + 0ou32; //~ ERROR: no valid digits + 0bu32; //~ ERROR: no valid digits + 0b; //~ ERROR: no valid digits + 0o123f64; //~ ERROR: octal float literal is not supported + 0o123.456; //~ ERROR: octal float literal is not supported + 0b101f64; //~ ERROR: binary float literal is not supported + 0b111.101; //~ ERROR: binary float literal is not supported +} diff --git a/src/test/ui/parser/lex-bad-numeric-literals.stderr b/src/test/ui/parser/lex-bad-numeric-literals.stderr new file mode 100644 index 00000000000..3d87b5b7037 --- /dev/null +++ b/src/test/ui/parser/lex-bad-numeric-literals.stderr @@ -0,0 +1,140 @@ +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:14:5 + | +LL | 0o1.0; //~ ERROR: octal float literal is not supported + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:16:5 + | +LL | 0o3.0f32; //~ ERROR: octal float literal is not supported + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:17:5 + | +LL | 0o4e4; //~ ERROR: octal float literal is not supported + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:18:5 + | +LL | 0o5.0e5; //~ ERROR: octal float literal is not supported + | ^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:19:5 + | +LL | 0o6e6f32; //~ ERROR: octal float literal is not supported + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:20:5 + | +LL | 0o7.0e7f64; //~ ERROR: octal float literal is not supported + | ^^^^^^^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:21:5 + | +LL | 0x8.0e+9; //~ ERROR: hexadecimal float literal is not supported + | ^^^^^^^^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:22:5 + | +LL | 0x9.0e-9; //~ ERROR: hexadecimal float literal is not supported + | ^^^^^^^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:23:5 + | +LL | 0o; //~ ERROR: no valid digits + | ^^ + +error: expected at least one digit in exponent + --> $DIR/lex-bad-numeric-literals.rs:24:8 + | +LL | 1e+; //~ ERROR: expected at least one digit in exponent + | ^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:25:5 + | +LL | 0x539.0; //~ ERROR: hexadecimal float literal is not supported + | ^^^^^^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:28:5 + | +LL | 0x; //~ ERROR: no valid digits + | ^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:29:5 + | +LL | 0xu32; //~ ERROR: no valid digits + | ^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:30:5 + | +LL | 0ou32; //~ ERROR: no valid digits + | ^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:31:5 + | +LL | 0bu32; //~ ERROR: no valid digits + | ^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:32:5 + | +LL | 0b; //~ ERROR: no valid digits + | ^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:34:5 + | +LL | 0o123.456; //~ ERROR: octal float literal is not supported + | ^^^^^^^^^ + +error: binary float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:36:5 + | +LL | 0b111.101; //~ ERROR: binary float literal is not supported + | ^^^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:15:5 + | +LL | 0o2f32; //~ ERROR: octal float literal is not supported + | ^^^^^^ + +error: int literal is too large + --> $DIR/lex-bad-numeric-literals.rs:26:5 + | +LL | 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: int literal is too large + --> $DIR/lex-bad-numeric-literals.rs:27:5 + | +LL | 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:33:5 + | +LL | 0o123f64; //~ ERROR: octal float literal is not supported + | ^^^^^^^^ + +error: binary float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:35:5 + | +LL | 0b101f64; //~ ERROR: binary float literal is not supported + | ^^^^^^^^ + +error: aborting due to 23 previous errors + diff --git a/src/test/ui/parser/lex-bad-octal-literal.rs b/src/test/ui/parser/lex-bad-octal-literal.rs new file mode 100644 index 00000000000..c8406af52ae --- /dev/null +++ b/src/test/ui/parser/lex-bad-octal-literal.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +fn main() { + 0o18; //~ ERROR invalid digit for a base 8 literal + 0o1234_9_5670; //~ ERROR invalid digit for a base 8 literal +} diff --git a/src/test/ui/parser/lex-bad-octal-literal.stderr b/src/test/ui/parser/lex-bad-octal-literal.stderr new file mode 100644 index 00000000000..342309fdd1c --- /dev/null +++ b/src/test/ui/parser/lex-bad-octal-literal.stderr @@ -0,0 +1,14 @@ +error: invalid digit for a base 8 literal + --> $DIR/lex-bad-octal-literal.rs:14:8 + | +LL | 0o18; //~ ERROR invalid digit for a base 8 literal + | ^ + +error: invalid digit for a base 8 literal + --> $DIR/lex-bad-octal-literal.rs:15:12 + | +LL | 0o1234_9_5670; //~ ERROR invalid digit for a base 8 literal + | ^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/lex-bad-token.rs b/src/test/ui/parser/lex-bad-token.rs new file mode 100644 index 00000000000..774b10a9f97 --- /dev/null +++ b/src/test/ui/parser/lex-bad-token.rs @@ -0,0 +1,13 @@ +// Copyright 2014 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 + +● //~ ERROR: unknown start of token diff --git a/src/test/ui/parser/lex-bad-token.stderr b/src/test/ui/parser/lex-bad-token.stderr new file mode 100644 index 00000000000..6e2cd9995ca --- /dev/null +++ b/src/test/ui/parser/lex-bad-token.stderr @@ -0,0 +1,8 @@ +error: unknown start of token: /u{25cf} + --> $DIR/lex-bad-token.rs:13:1 + | +LL | ● //~ ERROR: unknown start of token + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs new file mode 100644 index 00000000000..ac085d47511 --- /dev/null +++ b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs @@ -0,0 +1,38 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +// ignore-tidy-cr + +/// doc comment with bare CR: ' ' +pub fn foo() {} +//~^^ ERROR: bare CR not allowed in doc-comment + +/** block doc comment with bare CR: ' ' */ +pub fn bar() {} +//~^^ ERROR: bare CR not allowed in block doc-comment + +fn main() { + //! doc comment with bare CR: ' ' + //~^ ERROR: bare CR not allowed in doc-comment + + /*! block doc comment with bare CR: ' ' */ + //~^ ERROR: bare CR not allowed in block doc-comment + + // the following string literal has a bare CR in it + let _s = "foo bar"; //~ ERROR: bare CR not allowed in string + + // the following string literal has a bare CR in it + let _s = r"bar foo"; //~ ERROR: bare CR not allowed in raw string + + // the following string literal has a bare CR in it + let _s = "foo\ bar"; //~ ERROR: unknown character escape: \r +} diff --git a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr new file mode 100644 index 00000000000..799836759e6 --- /dev/null +++ b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr @@ -0,0 +1,50 @@ +error: bare CR not allowed in doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:15:32 + | +LL | /// doc comment with bare CR: ' ' + | ^ + +error: bare CR not allowed in block doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:19:38 + | +LL | /** block doc comment with bare CR: ' ' */ + | ^ + +error: bare CR not allowed in doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:24:36 + | +LL | //! doc comment with bare CR: ' ' + | ^ + +error: bare CR not allowed in block doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:27:42 + | +LL | /*! block doc comment with bare CR: ' ' */ + | ^ + +error: bare CR not allowed in string, use /r instead + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:31:18 + | +LL | let _s = "foo bar"; //~ ERROR: bare CR not allowed in string + | ^ + +error: bare CR not allowed in raw string, use /r instead + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:34:14 + | +LL | let _s = r"bar foo"; //~ ERROR: bare CR not allowed in raw string + | ^^^^^ + +error: unknown character escape: /r + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:37:19 + | +LL | let _s = "foo/ bar"; //~ ERROR: unknown character escape: /r + | ^ + | +help: this is an isolated carriage return; consider checking your editor and version control settings + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:37:19 + | +LL | let _s = "foo/ bar"; //~ ERROR: unknown character escape: /r + | ^ + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/parser/lex-stray-backslash.rs b/src/test/ui/parser/lex-stray-backslash.rs new file mode 100644 index 00000000000..b6042bbdc1a --- /dev/null +++ b/src/test/ui/parser/lex-stray-backslash.rs @@ -0,0 +1,13 @@ +// Copyright 2014 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 + +\ //~ ERROR: unknown start of token: \ diff --git a/src/test/ui/parser/lex-stray-backslash.stderr b/src/test/ui/parser/lex-stray-backslash.stderr new file mode 100644 index 00000000000..d4ccb6f1459 --- /dev/null +++ b/src/test/ui/parser/lex-stray-backslash.stderr @@ -0,0 +1,8 @@ +error: unknown start of token: / + --> $DIR/lex-stray-backslash.rs:13:1 + | +LL | / //~ ERROR: unknown start of token: / + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/lifetime-in-pattern.rs b/src/test/ui/parser/lifetime-in-pattern.rs new file mode 100644 index 00000000000..ccabcdf2d75 --- /dev/null +++ b/src/test/ui/parser/lifetime-in-pattern.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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 test(&'a str) { + //~^ ERROR unexpected lifetime `'a` in pattern +} + +fn main() { +} diff --git a/src/test/ui/parser/lifetime-in-pattern.stderr b/src/test/ui/parser/lifetime-in-pattern.stderr new file mode 100644 index 00000000000..86cc3c5b0cb --- /dev/null +++ b/src/test/ui/parser/lifetime-in-pattern.stderr @@ -0,0 +1,8 @@ +error: unexpected lifetime `'a` in pattern + --> $DIR/lifetime-in-pattern.rs:13:10 + | +LL | fn test(&'a str) { + | ^^ unexpected lifetime + +error: aborting due to previous error + diff --git a/src/test/ui/parser/lifetime-semicolon.rs b/src/test/ui/parser/lifetime-semicolon.rs new file mode 100644 index 00000000000..e1975952fca --- /dev/null +++ b/src/test/ui/parser/lifetime-semicolon.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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 + +struct Foo<'a, 'b> { + a: &'a &'b i32 +} + +fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} +//~^ ERROR expected one of `,` or `>`, found `;` diff --git a/src/test/ui/parser/lifetime-semicolon.stderr b/src/test/ui/parser/lifetime-semicolon.stderr new file mode 100644 index 00000000000..2ce6d5d6cf3 --- /dev/null +++ b/src/test/ui/parser/lifetime-semicolon.stderr @@ -0,0 +1,8 @@ +error: expected one of `,` or `>`, found `;` + --> $DIR/lifetime-semicolon.rs:17:30 + | +LL | fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} + | ^ expected one of `,` or `>` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro-bad-delimiter-ident.rs b/src/test/ui/parser/macro-bad-delimiter-ident.rs new file mode 100644 index 00000000000..2940adee043 --- /dev/null +++ b/src/test/ui/parser/macro-bad-delimiter-ident.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 main() { + foo! bar < //~ ERROR expected `(` or `{`, found `<` +} diff --git a/src/test/ui/parser/macro-bad-delimiter-ident.stderr b/src/test/ui/parser/macro-bad-delimiter-ident.stderr new file mode 100644 index 00000000000..e1ae9892f74 --- /dev/null +++ b/src/test/ui/parser/macro-bad-delimiter-ident.stderr @@ -0,0 +1,8 @@ +error: expected `(` or `{`, found `<` + --> $DIR/macro-bad-delimiter-ident.rs:14:14 + | +LL | foo! bar < //~ ERROR expected `(` or `{`, found `<` + | ^ expected `(` or `{` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro-keyword.rs b/src/test/ui/parser/macro-keyword.rs new file mode 100644 index 00000000000..c7dcaf4137e --- /dev/null +++ b/src/test/ui/parser/macro-keyword.rs @@ -0,0 +1,17 @@ +// Copyright 2015 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 macro() { //~ ERROR expected identifier, found reserved keyword `macro` +} + +pub fn main() { +} diff --git a/src/test/ui/parser/macro-keyword.stderr b/src/test/ui/parser/macro-keyword.stderr new file mode 100644 index 00000000000..a5582623535 --- /dev/null +++ b/src/test/ui/parser/macro-keyword.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found reserved keyword `macro` + --> $DIR/macro-keyword.rs:13:4 + | +LL | fn macro() { //~ ERROR expected identifier, found reserved keyword `macro` + | ^^^^^ expected identifier, found reserved keyword + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro-mismatched-delim-brace-paren.rs b/src/test/ui/parser/macro-mismatched-delim-brace-paren.rs new file mode 100644 index 00000000000..84cf900129f --- /dev/null +++ b/src/test/ui/parser/macro-mismatched-delim-brace-paren.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 main() { + foo! { + bar, "baz", 1, 2.0 + ) //~ ERROR incorrect close delimiter +} diff --git a/src/test/ui/parser/macro-mismatched-delim-brace-paren.stderr b/src/test/ui/parser/macro-mismatched-delim-brace-paren.stderr new file mode 100644 index 00000000000..69bd40fbb24 --- /dev/null +++ b/src/test/ui/parser/macro-mismatched-delim-brace-paren.stderr @@ -0,0 +1,11 @@ +error: incorrect close delimiter: `)` + --> $DIR/macro-mismatched-delim-brace-paren.rs:16:5 + | +LL | foo! { + | - un-closed delimiter +LL | bar, "baz", 1, 2.0 +LL | ) //~ ERROR incorrect close delimiter + | ^ incorrect close delimiter + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro-mismatched-delim-paren-brace.rs b/src/test/ui/parser/macro-mismatched-delim-paren-brace.rs new file mode 100644 index 00000000000..cbc0ed0ccdb --- /dev/null +++ b/src/test/ui/parser/macro-mismatched-delim-paren-brace.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 main() { + foo! ( + bar, "baz", 1, 2.0 + } //~ ERROR incorrect close delimiter +} //~ ERROR unexpected close delimiter: `}` diff --git a/src/test/ui/parser/macro-mismatched-delim-paren-brace.stderr b/src/test/ui/parser/macro-mismatched-delim-paren-brace.stderr new file mode 100644 index 00000000000..6fe7926f4e1 --- /dev/null +++ b/src/test/ui/parser/macro-mismatched-delim-paren-brace.stderr @@ -0,0 +1,17 @@ +error: incorrect close delimiter: `}` + --> $DIR/macro-mismatched-delim-paren-brace.rs:16:5 + | +LL | foo! ( + | - un-closed delimiter +LL | bar, "baz", 1, 2.0 +LL | } //~ ERROR incorrect close delimiter + | ^ incorrect close delimiter + +error: unexpected close delimiter: `}` + --> $DIR/macro-mismatched-delim-paren-brace.rs:17:1 + | +LL | } //~ ERROR unexpected close delimiter: `}` + | ^ unexpected close delimiter + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/macro/issue-33569.rs b/src/test/ui/parser/macro/issue-33569.rs new file mode 100644 index 00000000000..a0b959ecea5 --- /dev/null +++ b/src/test/ui/parser/macro/issue-33569.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +macro_rules! foo { + { $+ } => { //~ ERROR expected identifier, found `+` + //~^ ERROR missing fragment specifier + $(x)(y) //~ ERROR expected `*` or `+` + } +} + +foo!(); diff --git a/src/test/ui/parser/macro/issue-33569.stderr b/src/test/ui/parser/macro/issue-33569.stderr new file mode 100644 index 00000000000..4dab8fc73f3 --- /dev/null +++ b/src/test/ui/parser/macro/issue-33569.stderr @@ -0,0 +1,20 @@ +error: expected identifier, found `+` + --> $DIR/issue-33569.rs:12:8 + | +LL | { $+ } => { //~ ERROR expected identifier, found `+` + | ^ + +error: expected `*` or `+` + --> $DIR/issue-33569.rs:14:13 + | +LL | $(x)(y) //~ ERROR expected `*` or `+` + | ^^^ + +error: missing fragment specifier + --> $DIR/issue-33569.rs:12:8 + | +LL | { $+ } => { //~ ERROR expected identifier, found `+` + | ^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/parser/macro/issue-37113.rs b/src/test/ui/parser/macro/issue-37113.rs new file mode 100644 index 00000000000..14c6f3944bb --- /dev/null +++ b/src/test/ui/parser/macro/issue-37113.rs @@ -0,0 +1,21 @@ +// Copyright 2016 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. + +macro_rules! test_macro { + ( $( $t:ty ),* $(),*) => { + enum SomeEnum { + $( $t, )* //~ ERROR expected identifier, found `String` + }; + }; +} + +fn main() { + test_macro!(String,); +} diff --git a/src/test/ui/parser/macro/issue-37113.stderr b/src/test/ui/parser/macro/issue-37113.stderr new file mode 100644 index 00000000000..1e8f017e1db --- /dev/null +++ b/src/test/ui/parser/macro/issue-37113.stderr @@ -0,0 +1,11 @@ +error: expected identifier, found `String` + --> $DIR/issue-37113.rs:14:16 + | +LL | $( $t, )* //~ ERROR expected identifier, found `String` + | ^^ expected identifier +... +LL | test_macro!(String,); + | --------------------- in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro/issue-37234.rs b/src/test/ui/parser/macro/issue-37234.rs new file mode 100644 index 00000000000..93a1468bf7b --- /dev/null +++ b/src/test/ui/parser/macro/issue-37234.rs @@ -0,0 +1,19 @@ +// Copyright 2016 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. + +macro_rules! failed { + () => {{ + let x = 5 ""; //~ ERROR found `""` + }} +} + +fn main() { + failed!(); +} diff --git a/src/test/ui/parser/macro/issue-37234.stderr b/src/test/ui/parser/macro/issue-37234.stderr new file mode 100644 index 00000000000..28dd71316aa --- /dev/null +++ b/src/test/ui/parser/macro/issue-37234.stderr @@ -0,0 +1,11 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `""` + --> $DIR/issue-37234.rs:13:19 + | +LL | let x = 5 ""; //~ ERROR found `""` + | ^^ expected one of `.`, `;`, `?`, or an operator here +... +LL | failed!(); + | ---------- in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro/macro-doc-comments-1.rs b/src/test/ui/parser/macro/macro-doc-comments-1.rs new file mode 100644 index 00000000000..03bcef4fa5e --- /dev/null +++ b/src/test/ui/parser/macro/macro-doc-comments-1.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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. + +macro_rules! outer { + (#[$outer:meta]) => () +} + +outer! { + //! Inner +} //~^ ERROR no rules expected the token `!` + +fn main() { } diff --git a/src/test/ui/parser/macro/macro-doc-comments-1.stderr b/src/test/ui/parser/macro/macro-doc-comments-1.stderr new file mode 100644 index 00000000000..1e765dcde4f --- /dev/null +++ b/src/test/ui/parser/macro/macro-doc-comments-1.stderr @@ -0,0 +1,11 @@ +error: no rules expected the token `!` + --> $DIR/macro-doc-comments-1.rs:16:5 + | +LL | macro_rules! outer { + | ------------------ when calling this macro +... +LL | //! Inner + | ^^^^^^^^^ no rules expected the token `!` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro/macro-doc-comments-2.rs b/src/test/ui/parser/macro/macro-doc-comments-2.rs new file mode 100644 index 00000000000..a1b112c29b6 --- /dev/null +++ b/src/test/ui/parser/macro/macro-doc-comments-2.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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. + +macro_rules! inner { + (#![$inner:meta]) => () +} + +inner! { + /// Outer +} //~^ ERROR no rules expected the token `[` + +fn main() { } diff --git a/src/test/ui/parser/macro/macro-doc-comments-2.stderr b/src/test/ui/parser/macro/macro-doc-comments-2.stderr new file mode 100644 index 00000000000..0ab8a3cafb5 --- /dev/null +++ b/src/test/ui/parser/macro/macro-doc-comments-2.stderr @@ -0,0 +1,11 @@ +error: no rules expected the token `[` + --> $DIR/macro-doc-comments-2.rs:16:5 + | +LL | macro_rules! inner { + | ------------------ when calling this macro +... +LL | /// Outer + | ^ no rules expected the token `[` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro/macro-incomplete-parse.rs b/src/test/ui/parser/macro/macro-incomplete-parse.rs new file mode 100644 index 00000000000..9b8fdaf9a25 --- /dev/null +++ b/src/test/ui/parser/macro/macro-incomplete-parse.rs @@ -0,0 +1,39 @@ +// 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 <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 continue-parse-after-error + +macro_rules! ignored_item { + () => { + fn foo() {} + fn bar() {} + , //~ ERROR macro expansion ignores token `,` + } +} + +macro_rules! ignored_expr { + () => ( 1, //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `,` + + 2 ) +} + +macro_rules! ignored_pat { + () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` +} + +ignored_item!(); + +fn main() { + ignored_expr!(); + match 1 { + ignored_pat!() => (), + _ => (), + } +} diff --git a/src/test/ui/parser/macro/macro-incomplete-parse.stderr b/src/test/ui/parser/macro/macro-incomplete-parse.stderr new file mode 100644 index 00000000000..806aca511d0 --- /dev/null +++ b/src/test/ui/parser/macro/macro-incomplete-parse.stderr @@ -0,0 +1,33 @@ +error: macro expansion ignores token `,` and any following + --> $DIR/macro-incomplete-parse.rs:17:9 + | +LL | , //~ ERROR macro expansion ignores token `,` + | ^ +... +LL | ignored_item!(); + | ---------------- caused by the macro expansion here + | + = note: the usage of `ignored_item!` is likely invalid in item context + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` + --> $DIR/macro-incomplete-parse.rs:22:14 + | +LL | () => ( 1, //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `,` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here +... +LL | ignored_expr!(); + | ---------------- in this macro invocation + +error: macro expansion ignores token `,` and any following + --> $DIR/macro-incomplete-parse.rs:28:14 + | +LL | () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` + | ^ +... +LL | ignored_pat!() => (), + | -------------- caused by the macro expansion here + | + = note: the usage of `ignored_pat!` is likely invalid in pattern context + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/parser/macro/macro-repeat.rs b/src/test/ui/parser/macro/macro-repeat.rs new file mode 100644 index 00000000000..3abadd885ac --- /dev/null +++ b/src/test/ui/parser/macro/macro-repeat.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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. + +macro_rules! mac { + ( $($v:tt)* ) => ( + $v //~ ERROR still repeating at this depth + ) +} + +fn main() { + mac!(0); +} diff --git a/src/test/ui/parser/macro/macro-repeat.stderr b/src/test/ui/parser/macro/macro-repeat.stderr new file mode 100644 index 00000000000..7c7a2fb12c3 --- /dev/null +++ b/src/test/ui/parser/macro/macro-repeat.stderr @@ -0,0 +1,8 @@ +error: variable 'v' is still repeating at this depth + --> $DIR/macro-repeat.rs:13:9 + | +LL | $v //~ ERROR still repeating at this depth + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro/pub-item-macro.rs b/src/test/ui/parser/macro/pub-item-macro.rs new file mode 100644 index 00000000000..8809e9a257d --- /dev/null +++ b/src/test/ui/parser/macro/pub-item-macro.rs @@ -0,0 +1,28 @@ +// Copyright 2015 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. + +// Issue #14660 + +macro_rules! priv_x { () => { + static x: u32 = 0; +}} + +macro_rules! pub_x { () => { + pub priv_x!(); //~ ERROR can't qualify macro invocation with `pub` + //~^ HELP try adjusting the macro to put `pub` inside the invocation +}} + +mod foo { + pub_x!(); +} + +fn main() { + let y: u32 = foo::x; +} diff --git a/src/test/ui/parser/macro/pub-item-macro.stderr b/src/test/ui/parser/macro/pub-item-macro.stderr new file mode 100644 index 00000000000..f55ba469ab4 --- /dev/null +++ b/src/test/ui/parser/macro/pub-item-macro.stderr @@ -0,0 +1,13 @@ +error: can't qualify macro invocation with `pub` + --> $DIR/pub-item-macro.rs:18:5 + | +LL | pub priv_x!(); //~ ERROR can't qualify macro invocation with `pub` + | ^^^ +... +LL | pub_x!(); + | --------- in this macro invocation + | + = help: try adjusting the macro to put `pub` inside the invocation + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro/trait-non-item-macros.rs b/src/test/ui/parser/macro/trait-non-item-macros.rs new file mode 100644 index 00000000000..9f94d5d41fd --- /dev/null +++ b/src/test/ui/parser/macro/trait-non-item-macros.rs @@ -0,0 +1,20 @@ +// Copyright 2015 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. + +macro_rules! bah { + ($a:expr) => ($a) + //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `2` +} + +trait bar { + bah!(2); +} + +fn main() {} diff --git a/src/test/ui/parser/macro/trait-non-item-macros.stderr b/src/test/ui/parser/macro/trait-non-item-macros.stderr new file mode 100644 index 00000000000..2f4fdbfbc2b --- /dev/null +++ b/src/test/ui/parser/macro/trait-non-item-macros.stderr @@ -0,0 +1,11 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `2` + --> $DIR/trait-non-item-macros.rs:12:19 + | +LL | ($a:expr) => ($a) + | ^^ unexpected token +... +LL | bah!(2); + | -------- in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macro/trait-object-macro-matcher.rs b/src/test/ui/parser/macro/trait-object-macro-matcher.rs new file mode 100644 index 00000000000..3a5bce509f1 --- /dev/null +++ b/src/test/ui/parser/macro/trait-object-macro-matcher.rs @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// A single lifetime is not parsed as a type. +// `ty` matcher in particular doesn't accept a single lifetime + +macro_rules! m { + ($t: ty) => ( let _: $t; ) +} + +fn main() { + m!('static); //~ ERROR expected type, found `'static` +} diff --git a/src/test/ui/parser/macro/trait-object-macro-matcher.stderr b/src/test/ui/parser/macro/trait-object-macro-matcher.stderr new file mode 100644 index 00000000000..ab536dc5854 --- /dev/null +++ b/src/test/ui/parser/macro/trait-object-macro-matcher.stderr @@ -0,0 +1,8 @@ +error: expected type, found `'static` + --> $DIR/trait-object-macro-matcher.rs:19:8 + | +LL | m!('static); //~ ERROR expected type, found `'static` + | ^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macros-no-semicolon-items.rs b/src/test/ui/parser/macros-no-semicolon-items.rs new file mode 100644 index 00000000000..faf6b4a308a --- /dev/null +++ b/src/test/ui/parser/macros-no-semicolon-items.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 + +macro_rules! foo() //~ ERROR semicolon + +fn main() { +} diff --git a/src/test/ui/parser/macros-no-semicolon-items.stderr b/src/test/ui/parser/macros-no-semicolon-items.stderr new file mode 100644 index 00000000000..1d935f693f1 --- /dev/null +++ b/src/test/ui/parser/macros-no-semicolon-items.stderr @@ -0,0 +1,8 @@ +error: macros that expand to items must either be surrounded with braces or followed by a semicolon + --> $DIR/macros-no-semicolon-items.rs:13:17 + | +LL | macro_rules! foo() //~ ERROR semicolon + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/macros-no-semicolon.rs b/src/test/ui/parser/macros-no-semicolon.rs new file mode 100644 index 00000000000..1c55d70f607 --- /dev/null +++ b/src/test/ui/parser/macros-no-semicolon.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 main() { + assert_eq!(1, 2) + assert_eq!(3, 4) //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `assert_eq` + println!("hello"); +} diff --git a/src/test/ui/parser/macros-no-semicolon.stderr b/src/test/ui/parser/macros-no-semicolon.stderr new file mode 100644 index 00000000000..9ea9e739a0a --- /dev/null +++ b/src/test/ui/parser/macros-no-semicolon.stderr @@ -0,0 +1,10 @@ +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `assert_eq` + --> $DIR/macros-no-semicolon.rs:15:5 + | +LL | assert_eq!(1, 2) + | - expected one of `.`, `;`, `?`, `}`, or an operator here +LL | assert_eq!(3, 4) //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `assert_eq` + | ^^^^^^^^^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/match-arrows-block-then-binop.rs b/src/test/ui/parser/match-arrows-block-then-binop.rs new file mode 100644 index 00000000000..e8cfb77f059 --- /dev/null +++ b/src/test/ui/parser/match-arrows-block-then-binop.rs @@ -0,0 +1,19 @@ +// 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 main() { + + match 0 { + 0 => { + } + 5 //~ ERROR expected pattern, found `+` + } +} diff --git a/src/test/ui/parser/match-arrows-block-then-binop.stderr b/src/test/ui/parser/match-arrows-block-then-binop.stderr new file mode 100644 index 00000000000..9293fd14c49 --- /dev/null +++ b/src/test/ui/parser/match-arrows-block-then-binop.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found `+` + --> $DIR/match-arrows-block-then-binop.rs:17:9 + | +LL | } + 5 //~ ERROR expected pattern, found `+` + | ^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/match-refactor-to-expr.rs b/src/test/ui/parser/match-refactor-to-expr.rs new file mode 100644 index 00000000000..014dba3d4d0 --- /dev/null +++ b/src/test/ui/parser/match-refactor-to-expr.rs @@ -0,0 +1,22 @@ +// Copyright 2015 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 main() { + let foo = + match //~ NOTE while parsing this match expression + Some(4).unwrap_or_else(5) + //~^ NOTE expected one of `.`, `?`, `{`, or an operator here + ; //~ NOTE unexpected token + //~^ ERROR expected one of `.`, `?`, `{`, or an operator, found `;` + + println!("{}", foo) +} diff --git a/src/test/ui/parser/match-refactor-to-expr.stderr b/src/test/ui/parser/match-refactor-to-expr.stderr new file mode 100644 index 00000000000..2ffbddd570f --- /dev/null +++ b/src/test/ui/parser/match-refactor-to-expr.stderr @@ -0,0 +1,16 @@ +error: expected one of `.`, `?`, `{`, or an operator, found `;` + --> $DIR/match-refactor-to-expr.rs:18:9 + | +LL | match //~ NOTE while parsing this match expression + | ----- + | | + | while parsing this match expression + | help: try removing this `match` +LL | Some(4).unwrap_or_else(5) + | - expected one of `.`, `?`, `{`, or an operator here +LL | //~^ NOTE expected one of `.`, `?`, `{`, or an operator here +LL | ; //~ NOTE unexpected token + | ^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/match-vec-invalid.rs b/src/test/ui/parser/match-vec-invalid.rs new file mode 100644 index 00000000000..72501ba0e4f --- /dev/null +++ b/src/test/ui/parser/match-vec-invalid.rs @@ -0,0 +1,19 @@ +// Copyright 2014 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 main() { + let a = Vec::new(); + match a { + [1, tail.., tail..] => {}, //~ ERROR: expected one of `,` or `@`, found `..` + _ => () + } +} diff --git a/src/test/ui/parser/match-vec-invalid.stderr b/src/test/ui/parser/match-vec-invalid.stderr new file mode 100644 index 00000000000..9050223c644 --- /dev/null +++ b/src/test/ui/parser/match-vec-invalid.stderr @@ -0,0 +1,8 @@ +error: expected one of `,` or `@`, found `..` + --> $DIR/match-vec-invalid.rs:16:25 + | +LL | [1, tail.., tail..] => {}, //~ ERROR: expected one of `,` or `@`, found `..` + | ^^ expected one of `,` or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/mod_file_not_exist.rs b/src/test/ui/parser/mod_file_not_exist.rs new file mode 100644 index 00000000000..59b2ebe9f86 --- /dev/null +++ b/src/test/ui/parser/mod_file_not_exist.rs @@ -0,0 +1,19 @@ +// 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. + +// ignore-windows +// compile-flags: -Z parse-only + +mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` +//~^ HELP name the file either not_a_real_file.rs or not_a_real_file/mod.rs inside the directory + +fn main() { + assert_eq!(mod_file_aux::bar(), 10); +} diff --git a/src/test/ui/parser/mod_file_not_exist.stderr b/src/test/ui/parser/mod_file_not_exist.stderr new file mode 100644 index 00000000000..a745fc2847b --- /dev/null +++ b/src/test/ui/parser/mod_file_not_exist.stderr @@ -0,0 +1,11 @@ +error[E0583]: file not found for module `not_a_real_file` + --> $DIR/mod_file_not_exist.rs:14:5 + | +LL | mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` + | ^^^^^^^^^^^^^^^ + | + = help: name the file either not_a_real_file.rs or not_a_real_file/mod.rs inside the directory "$DIR" + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0583`. diff --git a/src/test/ui/parser/mod_file_not_exist_windows.rs b/src/test/ui/parser/mod_file_not_exist_windows.rs new file mode 100644 index 00000000000..6ee6792a8a2 --- /dev/null +++ b/src/test/ui/parser/mod_file_not_exist_windows.rs @@ -0,0 +1,19 @@ +// 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. + +// only-windows +// compile-flags: -Z parse-only + +mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` +//~^ HELP name the file either not_a_real_file.rs or not_a_real_file\mod.rs inside the directory + +fn main() { + assert_eq!(mod_file_aux::bar(), 10); +} diff --git a/src/test/ui/parser/mod_file_not_exist_windows.stderr b/src/test/ui/parser/mod_file_not_exist_windows.stderr new file mode 100644 index 00000000000..695038f8e4d --- /dev/null +++ b/src/test/ui/parser/mod_file_not_exist_windows.stderr @@ -0,0 +1,11 @@ +error[E0583]: file not found for module `not_a_real_file` + --> $DIR/mod_file_not_exist_windows.rs:14:5 + | +LL | mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` + | ^^^^^^^^^^^^^^^ + | + = help: name the file either not_a_real_file.rs or not_a_real_file/mod.rs inside the directory "$DIR" + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0583`. diff --git a/src/test/ui/parser/mod_file_with_path_attr.rs b/src/test/ui/parser/mod_file_with_path_attr.rs new file mode 100644 index 00000000000..03aa8edc229 --- /dev/null +++ b/src/test/ui/parser/mod_file_with_path_attr.rs @@ -0,0 +1,19 @@ +// 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 +// normalize-stderr-test: "not_a_real_file.rs:.*\(" -> "not_a_real_file.rs: $$FILE_NOT_FOUND_MSG (" + +#[path = "not_a_real_file.rs"] +mod m; //~ ERROR not_a_real_file.rs + +fn main() { + assert_eq!(m::foo(), 10); +} diff --git a/src/test/ui/parser/mod_file_with_path_attr.stderr b/src/test/ui/parser/mod_file_with_path_attr.stderr new file mode 100644 index 00000000000..f4247b60f68 --- /dev/null +++ b/src/test/ui/parser/mod_file_with_path_attr.stderr @@ -0,0 +1,8 @@ +error: couldn't read $DIR/not_a_real_file.rs: $FILE_NOT_FOUND_MSG (os error 2) + --> $DIR/mod_file_with_path_attr.rs:15:5 + | +LL | mod m; //~ ERROR not_a_real_file.rs + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/multiline-comment-line-tracking.rs b/src/test/ui/parser/multiline-comment-line-tracking.rs new file mode 100644 index 00000000000..44ed0a3706c --- /dev/null +++ b/src/test/ui/parser/multiline-comment-line-tracking.rs @@ -0,0 +1,20 @@ +// 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 +// error-pattern:19:3 + +/* 1 + * 2 + * 3 + */ +fn main() { + %; // parse error on line 19, but is reported on line 6 instead. +} diff --git a/src/test/ui/parser/multiline-comment-line-tracking.stderr b/src/test/ui/parser/multiline-comment-line-tracking.stderr new file mode 100644 index 00000000000..2dba2b1cb7e --- /dev/null +++ b/src/test/ui/parser/multiline-comment-line-tracking.stderr @@ -0,0 +1,8 @@ +error: expected expression, found `%` + --> $DIR/multiline-comment-line-tracking.rs:19:3 + | +LL | %; // parse error on line 19, but is reported on line 6 instead. + | ^ expected expression + +error: aborting due to previous error + diff --git a/src/test/ui/parser/multitrait.rs b/src/test/ui/parser/multitrait.rs new file mode 100644 index 00000000000..b7c9b165884 --- /dev/null +++ b/src/test/ui/parser/multitrait.rs @@ -0,0 +1,21 @@ +// 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 + +struct S { + y: isize +} + +impl Cmp, ToString for S { +//~^ ERROR: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `,` + fn eq(&&other: S) { false } + fn to_string(&self) -> String { "hi".to_string() } +} diff --git a/src/test/ui/parser/multitrait.stderr b/src/test/ui/parser/multitrait.stderr new file mode 100644 index 00000000000..2ccf49d0315 --- /dev/null +++ b/src/test/ui/parser/multitrait.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `,` + --> $DIR/multitrait.rs:17:9 + | +LL | impl Cmp, ToString for S { + | ^ expected one of 8 possible tokens here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/mut-patterns.rs b/src/test/ui/parser/mut-patterns.rs new file mode 100644 index 00000000000..71d826c67f8 --- /dev/null +++ b/src/test/ui/parser/mut-patterns.rs @@ -0,0 +1,18 @@ +// 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 <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 + +// Can't put mut in non-ident pattern + +pub fn main() { + struct Foo { x: isize } + let mut Foo { x: x } = Foo { x: 3 }; //~ ERROR: expected one of `:`, `;`, `=`, or `@`, found `{` +} diff --git a/src/test/ui/parser/mut-patterns.stderr b/src/test/ui/parser/mut-patterns.stderr new file mode 100644 index 00000000000..afe24595de4 --- /dev/null +++ b/src/test/ui/parser/mut-patterns.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `{` + --> $DIR/mut-patterns.rs:17:17 + | +LL | let mut Foo { x: x } = Foo { x: 3 }; //~ ERROR: expected one of `:`, `;`, `=`, or `@`, found `{` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/new-unicode-escapes-1.rs b/src/test/ui/parser/new-unicode-escapes-1.rs new file mode 100644 index 00000000000..78a68e846d1 --- /dev/null +++ b/src/test/ui/parser/new-unicode-escapes-1.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 + +pub fn main() { + let s = "\u{2603"; //~ ERROR unterminated unicode escape (needed a `}`) +} diff --git a/src/test/ui/parser/new-unicode-escapes-1.stderr b/src/test/ui/parser/new-unicode-escapes-1.stderr new file mode 100644 index 00000000000..4467b394c93 --- /dev/null +++ b/src/test/ui/parser/new-unicode-escapes-1.stderr @@ -0,0 +1,8 @@ +error: unterminated unicode escape (needed a `}`) + --> $DIR/new-unicode-escapes-1.rs:14:21 + | +LL | let s = "/u{2603"; //~ ERROR unterminated unicode escape (needed a `}`) + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/new-unicode-escapes-2.rs b/src/test/ui/parser/new-unicode-escapes-2.rs new file mode 100644 index 00000000000..cdadaef1b59 --- /dev/null +++ b/src/test/ui/parser/new-unicode-escapes-2.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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 + +pub fn main() { + let s = "\u{260311111111}"; //~ ERROR overlong unicode escape (must have at most 6 hex digits) +} diff --git a/src/test/ui/parser/new-unicode-escapes-2.stderr b/src/test/ui/parser/new-unicode-escapes-2.stderr new file mode 100644 index 00000000000..54123be4214 --- /dev/null +++ b/src/test/ui/parser/new-unicode-escapes-2.stderr @@ -0,0 +1,8 @@ +error: overlong unicode escape (must have at most 6 hex digits) + --> $DIR/new-unicode-escapes-2.rs:14:17 + | +LL | let s = "/u{260311111111}"; //~ ERROR overlong unicode escape (must have at most 6 hex digits) + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/new-unicode-escapes-3.rs b/src/test/ui/parser/new-unicode-escapes-3.rs new file mode 100644 index 00000000000..8189bf67712 --- /dev/null +++ b/src/test/ui/parser/new-unicode-escapes-3.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 + +pub fn main() { + let s1 = "\u{d805}"; //~ ERROR invalid unicode character escape + let s2 = "\u{ffffff}"; //~ ERROR invalid unicode character escape +} diff --git a/src/test/ui/parser/new-unicode-escapes-3.stderr b/src/test/ui/parser/new-unicode-escapes-3.stderr new file mode 100644 index 00000000000..65196f91b08 --- /dev/null +++ b/src/test/ui/parser/new-unicode-escapes-3.stderr @@ -0,0 +1,18 @@ +error: invalid unicode character escape + --> $DIR/new-unicode-escapes-3.rs:14:14 + | +LL | let s1 = "/u{d805}"; //~ ERROR invalid unicode character escape + | ^^^^^^^^^^ + | + = help: unicode escape must not be a surrogate + +error: invalid unicode character escape + --> $DIR/new-unicode-escapes-3.rs:15:14 + | +LL | let s2 = "/u{ffffff}"; //~ ERROR invalid unicode character escape + | ^^^^^^^^^^^^ + | + = help: unicode escape must be at most 10FFFF + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/new-unicode-escapes-4.rs b/src/test/ui/parser/new-unicode-escapes-4.rs new file mode 100644 index 00000000000..8770fb319df --- /dev/null +++ b/src/test/ui/parser/new-unicode-escapes-4.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +pub fn main() { + let s = "\u{lol}"; + //~^ ERROR invalid character in unicode escape: l +} diff --git a/src/test/ui/parser/new-unicode-escapes-4.stderr b/src/test/ui/parser/new-unicode-escapes-4.stderr new file mode 100644 index 00000000000..309a77e7df0 --- /dev/null +++ b/src/test/ui/parser/new-unicode-escapes-4.stderr @@ -0,0 +1,8 @@ +error: invalid character in unicode escape: l + --> $DIR/new-unicode-escapes-4.rs:14:17 + | +LL | let s = "/u{lol}"; + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/no-binary-float-literal.rs b/src/test/ui/parser/no-binary-float-literal.rs new file mode 100644 index 00000000000..528a2b1ad33 --- /dev/null +++ b/src/test/ui/parser/no-binary-float-literal.rs @@ -0,0 +1,19 @@ +// 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 <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 + +// error-pattern:binary float literal is not supported + +fn main() { + 0b101010f64; + 0b101.010; + 0b101p4f64; +} diff --git a/src/test/ui/parser/no-binary-float-literal.stderr b/src/test/ui/parser/no-binary-float-literal.stderr new file mode 100644 index 00000000000..db3c3791daf --- /dev/null +++ b/src/test/ui/parser/no-binary-float-literal.stderr @@ -0,0 +1,8 @@ +error: binary float literal is not supported + --> $DIR/no-binary-float-literal.rs:17:5 + | +LL | 0b101.010; + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/no-hex-float-literal.rs b/src/test/ui/parser/no-hex-float-literal.rs new file mode 100644 index 00000000000..df40fdde866 --- /dev/null +++ b/src/test/ui/parser/no-hex-float-literal.rs @@ -0,0 +1,19 @@ +// 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 <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 + +// error-pattern:hexadecimal float literal is not supported + +fn main() { + 0xABC.Df; + 0x567.89; + 0xDEAD.BEEFp-2f; +} diff --git a/src/test/ui/parser/no-hex-float-literal.stderr b/src/test/ui/parser/no-hex-float-literal.stderr new file mode 100644 index 00000000000..dba019baff8 --- /dev/null +++ b/src/test/ui/parser/no-hex-float-literal.stderr @@ -0,0 +1,8 @@ +error: hexadecimal float literal is not supported + --> $DIR/no-hex-float-literal.rs:17:5 + | +LL | 0x567.89; + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/no-unsafe-self.rs b/src/test/ui/parser/no-unsafe-self.rs new file mode 100644 index 00000000000..22baf88b43f --- /dev/null +++ b/src/test/ui/parser/no-unsafe-self.rs @@ -0,0 +1,26 @@ +// 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 <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 -Z continue-parse-after-error + +trait A { + fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer + fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer + fn bar(*self); //~ ERROR cannot pass `self` by raw pointer +} + +struct X; +impl A for X { + fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer + fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer + fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer +} + +fn main() { } diff --git a/src/test/ui/parser/no-unsafe-self.stderr b/src/test/ui/parser/no-unsafe-self.stderr new file mode 100644 index 00000000000..7fe66bffd86 --- /dev/null +++ b/src/test/ui/parser/no-unsafe-self.stderr @@ -0,0 +1,38 @@ +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:14:17 + | +LL | fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:15:19 + | +LL | fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:16:13 + | +LL | fn bar(*self); //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:21:17 + | +LL | fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:22:19 + | +LL | fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:23:13 + | +LL | fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/parser/not-a-pred.rs b/src/test/ui/parser/not-a-pred.rs new file mode 100644 index 00000000000..d880c06f8a1 --- /dev/null +++ b/src/test/ui/parser/not-a-pred.rs @@ -0,0 +1,19 @@ +// 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 + +// error-pattern: lt + +fn f(a: isize, b: isize) : lt(a, b) { } + +fn lt(a: isize, b: isize) { } + +fn main() { let a: isize = 10; let b: isize = 23; check (lt(a, b)); f(a, b); } diff --git a/src/test/ui/parser/not-a-pred.stderr b/src/test/ui/parser/not-a-pred.stderr new file mode 100644 index 00000000000..15558043737 --- /dev/null +++ b/src/test/ui/parser/not-a-pred.stderr @@ -0,0 +1,8 @@ +error: expected one of `->`, `where`, or `{`, found `:` + --> $DIR/not-a-pred.rs:15:26 + | +LL | fn f(a: isize, b: isize) : lt(a, b) { } + | ^ expected one of `->`, `where`, or `{` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/omitted-arg-in-item-fn.rs b/src/test/ui/parser/omitted-arg-in-item-fn.rs new file mode 100644 index 00000000000..388b7c8772e --- /dev/null +++ b/src/test/ui/parser/omitted-arg-in-item-fn.rs @@ -0,0 +1,14 @@ +// 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(x) { //~ ERROR expected one of `:` or `@`, found `)` +} diff --git a/src/test/ui/parser/omitted-arg-in-item-fn.stderr b/src/test/ui/parser/omitted-arg-in-item-fn.stderr new file mode 100644 index 00000000000..4e051b6206f --- /dev/null +++ b/src/test/ui/parser/omitted-arg-in-item-fn.stderr @@ -0,0 +1,8 @@ +error: expected one of `:` or `@`, found `)` + --> $DIR/omitted-arg-in-item-fn.rs:13:9 + | +LL | fn foo(x) { //~ ERROR expected one of `:` or `@`, found `)` + | ^ expected one of `:` or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/paamayim-nekudotayim.rs b/src/test/ui/parser/paamayim-nekudotayim.rs new file mode 100644 index 00000000000..3466fc6e71a --- /dev/null +++ b/src/test/ui/parser/paamayim-nekudotayim.rs @@ -0,0 +1,17 @@ +// 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 <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 + +// http://phpsadness.com/sad/1 + +fn main() { + ::; //~ ERROR expected identifier, found `;` +} diff --git a/src/test/ui/parser/paamayim-nekudotayim.stderr b/src/test/ui/parser/paamayim-nekudotayim.stderr new file mode 100644 index 00000000000..68912f52dc1 --- /dev/null +++ b/src/test/ui/parser/paamayim-nekudotayim.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `;` + --> $DIR/paamayim-nekudotayim.rs:16:7 + | +LL | ::; //~ ERROR expected identifier, found `;` + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/paren-after-qualified-path-in-match.rs b/src/test/ui/parser/paren-after-qualified-path-in-match.rs new file mode 100644 index 00000000000..d3aa4b72b78 --- /dev/null +++ b/src/test/ui/parser/paren-after-qualified-path-in-match.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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() { + match x { + <T as Trait>::Type(2) => (), + //~^ ERROR unexpected `(` after qualified path + _ => (), + } +} diff --git a/src/test/ui/parser/paren-after-qualified-path-in-match.stderr b/src/test/ui/parser/paren-after-qualified-path-in-match.stderr new file mode 100644 index 00000000000..df3a5011fd8 --- /dev/null +++ b/src/test/ui/parser/paren-after-qualified-path-in-match.stderr @@ -0,0 +1,8 @@ +error: unexpected `(` after qualified path + --> $DIR/paren-after-qualified-path-in-match.rs:15:27 + | +LL | <T as Trait>::Type(2) => (), + | ^ unexpected `(` after qualified path + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-lt-bracket-1.rs b/src/test/ui/parser/pat-lt-bracket-1.rs new file mode 100644 index 00000000000..fc1957571b1 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-1.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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 main() { + match 42 { + x < 7 => (), + //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + _ => () + } +} diff --git a/src/test/ui/parser/pat-lt-bracket-1.stderr b/src/test/ui/parser/pat-lt-bracket-1.stderr new file mode 100644 index 00000000000..5ab5ce2649a --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-1.stderr @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `<` + --> $DIR/pat-lt-bracket-1.rs:15:7 + | +LL | x < 7 => (), + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-lt-bracket-2.rs b/src/test/ui/parser/pat-lt-bracket-2.rs new file mode 100644 index 00000000000..a88e8384711 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-2.rs @@ -0,0 +1,14 @@ +// Copyright 2015 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 a(B<) {} + //~^ error: expected one of `:` or `@`, found `<` diff --git a/src/test/ui/parser/pat-lt-bracket-2.stderr b/src/test/ui/parser/pat-lt-bracket-2.stderr new file mode 100644 index 00000000000..d0d815045e0 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-2.stderr @@ -0,0 +1,8 @@ +error: expected one of `:` or `@`, found `<` + --> $DIR/pat-lt-bracket-2.rs:13:7 + | +LL | fn a(B<) {} + | ^ expected one of `:` or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-lt-bracket-3.rs b/src/test/ui/parser/pat-lt-bracket-3.rs new file mode 100644 index 00000000000..1a3f7aa8182 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-3.rs @@ -0,0 +1,24 @@ +// Copyright 2015 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 + +struct Foo<T>(T, T); + +impl<T> Foo<T> { + fn foo(&self) { + match *self { + Foo<T>(x, y) => { + //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + println!("Goodbye, World!") + } + } + } +} diff --git a/src/test/ui/parser/pat-lt-bracket-3.stderr b/src/test/ui/parser/pat-lt-bracket-3.stderr new file mode 100644 index 00000000000..1be61b1a12b --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-3.stderr @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `<` + --> $DIR/pat-lt-bracket-3.rs:18:16 + | +LL | Foo<T>(x, y) => { + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-lt-bracket-4.rs b/src/test/ui/parser/pat-lt-bracket-4.rs new file mode 100644 index 00000000000..a163b38b492 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-4.rs @@ -0,0 +1,23 @@ +// Copyright 2015 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 + +enum BtNode { + Node(u32,Box<BtNode>,Box<BtNode>), + Leaf(u32), +} + +fn main() { + let y = match x { + Foo<T>::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + Foo<T>::B => 7, + }; +} diff --git a/src/test/ui/parser/pat-lt-bracket-4.stderr b/src/test/ui/parser/pat-lt-bracket-4.stderr new file mode 100644 index 00000000000..4a0dec1b5c6 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-4.stderr @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `<` + --> $DIR/pat-lt-bracket-4.rs:20:12 + | +LL | Foo<T>::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-lt-bracket-5.rs b/src/test/ui/parser/pat-lt-bracket-5.rs new file mode 100644 index 00000000000..160b985dc6e --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-5.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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 main() { + let v[0] = v[1]; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` +} diff --git a/src/test/ui/parser/pat-lt-bracket-5.stderr b/src/test/ui/parser/pat-lt-bracket-5.stderr new file mode 100644 index 00000000000..6174ed63007 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-5.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `[` + --> $DIR/pat-lt-bracket-5.rs:14:10 + | +LL | let v[0] = v[1]; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-lt-bracket-6.rs b/src/test/ui/parser/pat-lt-bracket-6.rs new file mode 100644 index 00000000000..eaea9f4acd7 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-6.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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 main() { + let Test(&desc[..]) = x; //~ ERROR: expected one of `)`, `,`, or `@`, found `[` +} diff --git a/src/test/ui/parser/pat-lt-bracket-6.stderr b/src/test/ui/parser/pat-lt-bracket-6.stderr new file mode 100644 index 00000000000..9666f18fac5 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-6.stderr @@ -0,0 +1,8 @@ +error: expected one of `)`, `,`, or `@`, found `[` + --> $DIR/pat-lt-bracket-6.rs:14:19 + | +LL | let Test(&desc[..]) = x; //~ ERROR: expected one of `)`, `,`, or `@`, found `[` + | ^ expected one of `)`, `,`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-lt-bracket-7.rs b/src/test/ui/parser/pat-lt-bracket-7.rs new file mode 100644 index 00000000000..ac1c1f7ee1f --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-7.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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 main() { + for thing(x[]) in foo {} //~ ERROR: expected one of `)`, `,`, or `@`, found `[` +} diff --git a/src/test/ui/parser/pat-lt-bracket-7.stderr b/src/test/ui/parser/pat-lt-bracket-7.stderr new file mode 100644 index 00000000000..09a398fb2b0 --- /dev/null +++ b/src/test/ui/parser/pat-lt-bracket-7.stderr @@ -0,0 +1,8 @@ +error: expected one of `)`, `,`, or `@`, found `[` + --> $DIR/pat-lt-bracket-7.rs:14:16 + | +LL | for thing(x[]) in foo {} //~ ERROR: expected one of `)`, `,`, or `@`, found `[` + | ^ expected one of `)`, `,`, or `@` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-ranges-1.rs b/src/test/ui/parser/pat-ranges-1.rs new file mode 100644 index 00000000000..7aa02871018 --- /dev/null +++ b/src/test/ui/parser/pat-ranges-1.rs @@ -0,0 +1,17 @@ +// Copyright 2015 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. + +// Parsing of range patterns + +// compile-flags: -Z parse-only + +fn main() { + let macropus!() ..= 11 = 12; //~ error: expected one of `:`, `;`, or `=`, found `..=` +} diff --git a/src/test/ui/parser/pat-ranges-1.stderr b/src/test/ui/parser/pat-ranges-1.stderr new file mode 100644 index 00000000000..61d1bf258fe --- /dev/null +++ b/src/test/ui/parser/pat-ranges-1.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, or `=`, found `..=` + --> $DIR/pat-ranges-1.rs:16:21 + | +LL | let macropus!() ..= 11 = 12; //~ error: expected one of `:`, `;`, or `=`, found `..=` + | ^^^ expected one of `:`, `;`, or `=` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-ranges-2.rs b/src/test/ui/parser/pat-ranges-2.rs new file mode 100644 index 00000000000..123aa0d5088 --- /dev/null +++ b/src/test/ui/parser/pat-ranges-2.rs @@ -0,0 +1,17 @@ +// Copyright 2015 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. + +// Parsing of range patterns + +// compile-flags: -Z parse-only + +fn main() { + let 10 ..= makropulos!() = 12; //~ error: expected one of `::`, `:`, `;`, or `=`, found `!` +} diff --git a/src/test/ui/parser/pat-ranges-2.stderr b/src/test/ui/parser/pat-ranges-2.stderr new file mode 100644 index 00000000000..29f641f2be4 --- /dev/null +++ b/src/test/ui/parser/pat-ranges-2.stderr @@ -0,0 +1,8 @@ +error: expected one of `::`, `:`, `;`, or `=`, found `!` + --> $DIR/pat-ranges-2.rs:16:26 + | +LL | let 10 ..= makropulos!() = 12; //~ error: expected one of `::`, `:`, `;`, or `=`, found `!` + | ^ expected one of `::`, `:`, `;`, or `=` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-ranges-3.rs b/src/test/ui/parser/pat-ranges-3.rs new file mode 100644 index 00000000000..6384b606219 --- /dev/null +++ b/src/test/ui/parser/pat-ranges-3.rs @@ -0,0 +1,17 @@ +// Copyright 2015 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. + +// Parsing of range patterns + +// compile-flags: -Z parse-only + +fn main() { + let 10 ..= 10 + 3 = 12; //~ expected one of `:`, `;`, or `=`, found `+` +} diff --git a/src/test/ui/parser/pat-ranges-3.stderr b/src/test/ui/parser/pat-ranges-3.stderr new file mode 100644 index 00000000000..c78c43cddbf --- /dev/null +++ b/src/test/ui/parser/pat-ranges-3.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, or `=`, found `+` + --> $DIR/pat-ranges-3.rs:16:19 + | +LL | let 10 ..= 10 + 3 = 12; //~ expected one of `:`, `;`, or `=`, found `+` + | ^ expected one of `:`, `;`, or `=` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-ranges-4.rs b/src/test/ui/parser/pat-ranges-4.rs new file mode 100644 index 00000000000..023e5b40797 --- /dev/null +++ b/src/test/ui/parser/pat-ranges-4.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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. + +// Parsing of range patterns + +// compile-flags: -Z parse-only + +fn main() { + let 10 - 3 ..= 10 = 8; + //~^ error: expected one of `...`, `..=`, `..`, `:`, `;`, or `=`, found `-` +} diff --git a/src/test/ui/parser/pat-ranges-4.stderr b/src/test/ui/parser/pat-ranges-4.stderr new file mode 100644 index 00000000000..40b7fc8f753 --- /dev/null +++ b/src/test/ui/parser/pat-ranges-4.stderr @@ -0,0 +1,8 @@ +error: expected one of `...`, `..=`, `..`, `:`, `;`, or `=`, found `-` + --> $DIR/pat-ranges-4.rs:16:12 + | +LL | let 10 - 3 ..= 10 = 8; + | ^ expected one of `...`, `..=`, `..`, `:`, `;`, or `=` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-ref-enum.rs b/src/test/ui/parser/pat-ref-enum.rs new file mode 100644 index 00000000000..cf802572659 --- /dev/null +++ b/src/test/ui/parser/pat-ref-enum.rs @@ -0,0 +1,20 @@ +// 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 matcher(x: Option<isize>) { + match x { + ref Some(i) => {} //~ ERROR expected identifier, found enum pattern + None => {} + } +} + +fn main() {} diff --git a/src/test/ui/parser/pat-ref-enum.stderr b/src/test/ui/parser/pat-ref-enum.stderr new file mode 100644 index 00000000000..5e39b6d8fa9 --- /dev/null +++ b/src/test/ui/parser/pat-ref-enum.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found enum pattern + --> $DIR/pat-ref-enum.rs:15:11 + | +LL | ref Some(i) => {} //~ ERROR expected identifier, found enum pattern + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-tuple-1.rs b/src/test/ui/parser/pat-tuple-1.rs new file mode 100644 index 00000000000..945d0740654 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-1.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 main() { + match 0 { + (, ..) => {} //~ ERROR expected pattern, found `,` + } +} diff --git a/src/test/ui/parser/pat-tuple-1.stderr b/src/test/ui/parser/pat-tuple-1.stderr new file mode 100644 index 00000000000..eb970e6e220 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-1.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found `,` + --> $DIR/pat-tuple-1.rs:15:10 + | +LL | (, ..) => {} //~ ERROR expected pattern, found `,` + | ^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-tuple-2.rs b/src/test/ui/parser/pat-tuple-2.rs new file mode 100644 index 00000000000..07b391d3279 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-2.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 main() { + match 0 { + (pat, ..,) => {} //~ ERROR trailing comma is not permitted after `..` + } +} diff --git a/src/test/ui/parser/pat-tuple-2.stderr b/src/test/ui/parser/pat-tuple-2.stderr new file mode 100644 index 00000000000..cedc98ace64 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-2.stderr @@ -0,0 +1,8 @@ +error: trailing comma is not permitted after `..` + --> $DIR/pat-tuple-2.rs:15:17 + | +LL | (pat, ..,) => {} //~ ERROR trailing comma is not permitted after `..` + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-tuple-3.rs b/src/test/ui/parser/pat-tuple-3.rs new file mode 100644 index 00000000000..029dc7a2956 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-3.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 main() { + match 0 { + (.., pat, ..) => {} //~ ERROR `..` can only be used once per tuple or tuple struct pattern + } +} diff --git a/src/test/ui/parser/pat-tuple-3.stderr b/src/test/ui/parser/pat-tuple-3.stderr new file mode 100644 index 00000000000..28662f74142 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-3.stderr @@ -0,0 +1,8 @@ +error: `..` can only be used once per tuple or tuple struct pattern + --> $DIR/pat-tuple-3.rs:15:19 + | +LL | (.., pat, ..) => {} //~ ERROR `..` can only be used once per tuple or tuple struct pattern + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-tuple-4.rs b/src/test/ui/parser/pat-tuple-4.rs new file mode 100644 index 00000000000..f4c3afa07f1 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-4.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 main() { + match 0 { + (.. pat) => {} //~ ERROR expected one of `)` or `,`, found `pat` + } +} diff --git a/src/test/ui/parser/pat-tuple-4.stderr b/src/test/ui/parser/pat-tuple-4.stderr new file mode 100644 index 00000000000..586baddc363 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-4.stderr @@ -0,0 +1,8 @@ +error: expected one of `)` or `,`, found `pat` + --> $DIR/pat-tuple-4.rs:15:13 + | +LL | (.. pat) => {} //~ ERROR expected one of `)` or `,`, found `pat` + | ^^^ expected one of `)` or `,` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pat-tuple-5.rs b/src/test/ui/parser/pat-tuple-5.rs new file mode 100644 index 00000000000..d528b97b5de --- /dev/null +++ b/src/test/ui/parser/pat-tuple-5.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 main() { + match 0 { + (pat ..) => {} //~ ERROR unexpected token: `)` + } +} diff --git a/src/test/ui/parser/pat-tuple-5.stderr b/src/test/ui/parser/pat-tuple-5.stderr new file mode 100644 index 00000000000..1e192cfe598 --- /dev/null +++ b/src/test/ui/parser/pat-tuple-5.stderr @@ -0,0 +1,8 @@ +error: unexpected token: `)` + --> $DIR/pat-tuple-5.rs:15:14 + | +LL | (pat ..) => {} //~ ERROR unexpected token: `)` + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/pub-method-macro.rs b/src/test/ui/parser/pub-method-macro.rs new file mode 100644 index 00000000000..817a9465ef3 --- /dev/null +++ b/src/test/ui/parser/pub-method-macro.rs @@ -0,0 +1,34 @@ +// Copyright 2015 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. + +// Issue #18317 + +// compile-flags: -Z parse-only + +mod bleh { + macro_rules! defn { + ($n:ident) => ( + fn $n (&self) -> i32 { + println!("{}", stringify!($n)); + 1 + } + ) + } + + #[derive(Copy, Clone)] + pub struct S; + + impl S { + pub defn!(f); //~ ERROR can't qualify macro invocation with `pub` + //~^ HELP try adjusting the macro to put `pub` inside the invocation + } +} + +fn main() {} diff --git a/src/test/ui/parser/pub-method-macro.stderr b/src/test/ui/parser/pub-method-macro.stderr new file mode 100644 index 00000000000..91151ce7279 --- /dev/null +++ b/src/test/ui/parser/pub-method-macro.stderr @@ -0,0 +1,10 @@ +error: can't qualify macro invocation with `pub` + --> $DIR/pub-method-macro.rs:29:9 + | +LL | pub defn!(f); //~ ERROR can't qualify macro invocation with `pub` + | ^^^ + | + = help: try adjusting the macro to put `pub` inside the invocation + +error: aborting due to previous error + diff --git a/src/test/ui/parser/range-3.rs b/src/test/ui/parser/range-3.rs new file mode 100644 index 00000000000..95aa71b0cdf --- /dev/null +++ b/src/test/ui/parser/range-3.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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 + +// Test range syntax - syntax errors. + +pub fn main() { + let r = 1..2..3; + //~^ ERROR expected one of `.`, `;`, `?`, or an operator, found `..` +} diff --git a/src/test/ui/parser/range-3.stderr b/src/test/ui/parser/range-3.stderr new file mode 100644 index 00000000000..b8185862b3a --- /dev/null +++ b/src/test/ui/parser/range-3.stderr @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `..` + --> $DIR/range-3.rs:16:17 + | +LL | let r = 1..2..3; + | ^^ expected one of `.`, `;`, `?`, or an operator here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/range-4.rs b/src/test/ui/parser/range-4.rs new file mode 100644 index 00000000000..4500df116a2 --- /dev/null +++ b/src/test/ui/parser/range-4.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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 + +// Test range syntax - syntax errors. + +pub fn main() { + let r = ..1..2; + //~^ ERROR expected one of `.`, `;`, `?`, or an operator, found `..` +} diff --git a/src/test/ui/parser/range-4.stderr b/src/test/ui/parser/range-4.stderr new file mode 100644 index 00000000000..b5013f2e003 --- /dev/null +++ b/src/test/ui/parser/range-4.stderr @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `..` + --> $DIR/range-4.rs:16:16 + | +LL | let r = ..1..2; + | ^^ expected one of `.`, `;`, `?`, or an operator here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/range_inclusive.rs b/src/test/ui/parser/range_inclusive.rs new file mode 100644 index 00000000000..0d344cf6444 --- /dev/null +++ b/src/test/ui/parser/range_inclusive.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +// Make sure that inclusive ranges with no end point don't parse. + +// compile-flags: -Z parse-only + +pub fn main() { + for _ in 1..= {} //~ERROR inclusive range with no end + //~^HELP bounded at the end +} diff --git a/src/test/ui/parser/range_inclusive.stderr b/src/test/ui/parser/range_inclusive.stderr new file mode 100644 index 00000000000..90b7c089103 --- /dev/null +++ b/src/test/ui/parser/range_inclusive.stderr @@ -0,0 +1,11 @@ +error[E0586]: inclusive range with no end + --> $DIR/range_inclusive.rs:16:19 + | +LL | for _ in 1..= {} //~ERROR inclusive range with no end + | ^ + | + = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0586`. diff --git a/src/test/ui/parser/range_inclusive_dotdotdot.rs b/src/test/ui/parser/range_inclusive_dotdotdot.rs new file mode 100644 index 00000000000..34b96a59c2d --- /dev/null +++ b/src/test/ui/parser/range_inclusive_dotdotdot.rs @@ -0,0 +1,35 @@ +// Copyright 2017 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 -Z continue-parse-after-error + +// Make sure that inclusive ranges with `...` syntax don't parse. + +use std::ops::RangeToInclusive; + +fn return_range_to() -> RangeToInclusive<i32> { + return ...1; //~ERROR unexpected token: `...` + //~^HELP use `..` for an exclusive range + //~^^HELP or `..=` for an inclusive range +} + +pub fn main() { + let x = ...0; //~ERROR unexpected token: `...` + //~^HELP use `..` for an exclusive range + //~^^HELP or `..=` for an inclusive range + + let x = 5...5; //~ERROR unexpected token: `...` + //~^HELP use `..` for an exclusive range + //~^^HELP or `..=` for an inclusive range + + for _ in 0...1 {} //~ERROR unexpected token: `...` + //~^HELP use `..` for an exclusive range + //~^^HELP or `..=` for an inclusive range +} diff --git a/src/test/ui/parser/range_inclusive_dotdotdot.stderr b/src/test/ui/parser/range_inclusive_dotdotdot.stderr new file mode 100644 index 00000000000..7e1df24fc06 --- /dev/null +++ b/src/test/ui/parser/range_inclusive_dotdotdot.stderr @@ -0,0 +1,58 @@ +error: unexpected token: `...` + --> $DIR/range_inclusive_dotdotdot.rs:18:12 + | +LL | return ...1; //~ERROR unexpected token: `...` + | ^^^ +help: use `..` for an exclusive range + | +LL | return ..1; //~ERROR unexpected token: `...` + | ^^ +help: or `..=` for an inclusive range + | +LL | return ..=1; //~ERROR unexpected token: `...` + | ^^^ + +error: unexpected token: `...` + --> $DIR/range_inclusive_dotdotdot.rs:24:13 + | +LL | let x = ...0; //~ERROR unexpected token: `...` + | ^^^ +help: use `..` for an exclusive range + | +LL | let x = ..0; //~ERROR unexpected token: `...` + | ^^ +help: or `..=` for an inclusive range + | +LL | let x = ..=0; //~ERROR unexpected token: `...` + | ^^^ + +error: unexpected token: `...` + --> $DIR/range_inclusive_dotdotdot.rs:28:14 + | +LL | let x = 5...5; //~ERROR unexpected token: `...` + | ^^^ +help: use `..` for an exclusive range + | +LL | let x = 5..5; //~ERROR unexpected token: `...` + | ^^ +help: or `..=` for an inclusive range + | +LL | let x = 5..=5; //~ERROR unexpected token: `...` + | ^^^ + +error: unexpected token: `...` + --> $DIR/range_inclusive_dotdotdot.rs:32:15 + | +LL | for _ in 0...1 {} //~ERROR unexpected token: `...` + | ^^^ +help: use `..` for an exclusive range + | +LL | for _ in 0..1 {} //~ERROR unexpected token: `...` + | ^^ +help: or `..=` for an inclusive range + | +LL | for _ in 0..=1 {} //~ERROR unexpected token: `...` + | ^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/parser/raw-byte-string-eof.rs b/src/test/ui/parser/raw-byte-string-eof.rs new file mode 100644 index 00000000000..4b8bb31d19a --- /dev/null +++ b/src/test/ui/parser/raw-byte-string-eof.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 + + +pub fn main() { + br##"a"#; //~ unterminated raw string +} diff --git a/src/test/ui/parser/raw-byte-string-eof.stderr b/src/test/ui/parser/raw-byte-string-eof.stderr new file mode 100644 index 00000000000..4c8a3bfa644 --- /dev/null +++ b/src/test/ui/parser/raw-byte-string-eof.stderr @@ -0,0 +1,10 @@ +error: unterminated raw string + --> $DIR/raw-byte-string-eof.rs:15:6 + | +LL | br##"a"#; //~ unterminated raw string + | ^ unterminated raw string + | + = note: this raw string should be terminated with `"##` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/raw-byte-string-literals.rs b/src/test/ui/parser/raw-byte-string-literals.rs new file mode 100644 index 00000000000..2e33f98add6 --- /dev/null +++ b/src/test/ui/parser/raw-byte-string-literals.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 -Z continue-parse-after-error + + +pub fn main() { + br"é"; //~ ERROR raw byte string must be ASCII + br##~"a"~##; //~ ERROR only `#` is allowed in raw string delimitation +} diff --git a/src/test/ui/parser/raw-byte-string-literals.stderr b/src/test/ui/parser/raw-byte-string-literals.stderr new file mode 100644 index 00000000000..b5a379fc378 --- /dev/null +++ b/src/test/ui/parser/raw-byte-string-literals.stderr @@ -0,0 +1,14 @@ +error: raw byte string must be ASCII: /u{e9} + --> $DIR/raw-byte-string-literals.rs:15:8 + | +LL | br"é"; //~ ERROR raw byte string must be ASCII + | ^ + +error: found invalid character; only `#` is allowed in raw string delimitation: ~ + --> $DIR/raw-byte-string-literals.rs:16:6 + | +LL | br##~"a"~##; //~ ERROR only `#` is allowed in raw string delimitation + | ^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/raw-str-delim.rs b/src/test/ui/parser/raw-str-delim.rs new file mode 100644 index 00000000000..8c0027287de --- /dev/null +++ b/src/test/ui/parser/raw-str-delim.rs @@ -0,0 +1,15 @@ +// 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 <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 + +static s: &'static str = + r#~"#"~# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation +; diff --git a/src/test/ui/parser/raw-str-delim.stderr b/src/test/ui/parser/raw-str-delim.stderr new file mode 100644 index 00000000000..307550081d5 --- /dev/null +++ b/src/test/ui/parser/raw-str-delim.stderr @@ -0,0 +1,8 @@ +error: found invalid character; only `#` is allowed in raw string delimitation: ~ + --> $DIR/raw-str-delim.rs:14:5 + | +LL | r#~"#"~# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/raw-str-unbalanced.rs b/src/test/ui/parser/raw-str-unbalanced.rs new file mode 100644 index 00000000000..5c09f68970b --- /dev/null +++ b/src/test/ui/parser/raw-str-unbalanced.rs @@ -0,0 +1,16 @@ +// 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 <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 + +static s: &'static str = + r#" + "## //~ ERROR expected one of `.`, `;`, `?`, or an operator, found `#` +; diff --git a/src/test/ui/parser/raw-str-unbalanced.stderr b/src/test/ui/parser/raw-str-unbalanced.stderr new file mode 100644 index 00000000000..666faaabc10 --- /dev/null +++ b/src/test/ui/parser/raw-str-unbalanced.stderr @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `#` + --> $DIR/raw-str-unbalanced.rs:15:9 + | +LL | "## //~ ERROR expected one of `.`, `;`, `?`, or an operator, found `#` + | ^ expected one of `.`, `;`, `?`, or an operator here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/raw-str-unterminated.rs b/src/test/ui/parser/raw-str-unterminated.rs new file mode 100644 index 00000000000..c37239ac42c --- /dev/null +++ b/src/test/ui/parser/raw-str-unterminated.rs @@ -0,0 +1,16 @@ +// 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 <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 + +static s: &'static str = + r#" string literal goes on + and on + //~^^ ERROR unterminated raw string diff --git a/src/test/ui/parser/raw-str-unterminated.stderr b/src/test/ui/parser/raw-str-unterminated.stderr new file mode 100644 index 00000000000..a7d1ad227d2 --- /dev/null +++ b/src/test/ui/parser/raw-str-unterminated.stderr @@ -0,0 +1,10 @@ +error: unterminated raw string + --> $DIR/raw-str-unterminated.rs:14:5 + | +LL | r#" string literal goes on + | ^ unterminated raw string + | + = note: this raw string should be terminated with `"#` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/expected-comma-found-token.rs b/src/test/ui/parser/raw/raw-literal-keywords.rs index f7a632dfaa1..f1bfbc95eb3 100644 --- a/src/test/ui/parser/expected-comma-found-token.rs +++ b/src/test/ui/parser/raw/raw-literal-keywords.rs @@ -8,17 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Tests that two closures cannot simultaneously have mutable -// access to the variable, whether that mutable access be used -// for direct assignment or for taking mutable ref. Issue #6801. +// compile-flags: -Z parse-only -#![feature(on_unimplemented)] +fn test_if() { + r#if true { } //~ ERROR found `true` +} -#[rustc_on_unimplemented( - message="the message" - label="the label" -)] -trait T {} -//~^^^ ERROR expected one of `)` or `,`, found `label` +fn test_struct() { + r#struct Test; //~ ERROR found `Test` +} -fn main() { } +fn test_union() { + r#union Test; //~ ERROR found `Test` +} diff --git a/src/test/ui/parser/raw/raw-literal-keywords.stderr b/src/test/ui/parser/raw/raw-literal-keywords.stderr new file mode 100644 index 00000000000..8a6b91b4b4b --- /dev/null +++ b/src/test/ui/parser/raw/raw-literal-keywords.stderr @@ -0,0 +1,20 @@ +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true` + --> $DIR/raw-literal-keywords.rs:14:10 + | +LL | r#if true { } //~ ERROR found `true` + | ^^^^ expected one of 8 possible tokens here + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` + --> $DIR/raw-literal-keywords.rs:18:14 + | +LL | r#struct Test; //~ ERROR found `Test` + | ^^^^ expected one of 8 possible tokens here + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` + --> $DIR/raw-literal-keywords.rs:22:13 + | +LL | r#union Test; //~ ERROR found `Test` + | ^^^^ expected one of 8 possible tokens here + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/parser/raw/raw-literal-self.rs b/src/test/ui/parser/raw/raw-literal-self.rs new file mode 100644 index 00000000000..17496d767b6 --- /dev/null +++ b/src/test/ui/parser/raw/raw-literal-self.rs @@ -0,0 +1,15 @@ +// 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. + +// compile-flags: -Z parse-only + +fn self_test(r#self: u32) { + //~^ ERROR `r#self` is not currently supported. +} diff --git a/src/test/ui/parser/raw/raw-literal-self.stderr b/src/test/ui/parser/raw/raw-literal-self.stderr new file mode 100644 index 00000000000..f4b75937247 --- /dev/null +++ b/src/test/ui/parser/raw/raw-literal-self.stderr @@ -0,0 +1,8 @@ +error: `r#self` is not currently supported. + --> $DIR/raw-literal-self.rs:13:14 + | +LL | fn self_test(r#self: u32) { + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/raw/raw-literal-underscore.rs b/src/test/ui/parser/raw/raw-literal-underscore.rs new file mode 100644 index 00000000000..ec33e486195 --- /dev/null +++ b/src/test/ui/parser/raw/raw-literal-underscore.rs @@ -0,0 +1,15 @@ +// 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. + +// compile-flags: -Z parse-only + +fn underscore_test(r#_: u32) { + //~^ ERROR `r#_` is not currently supported. +} diff --git a/src/test/ui/parser/raw/raw-literal-underscore.stderr b/src/test/ui/parser/raw/raw-literal-underscore.stderr new file mode 100644 index 00000000000..8072eee4f06 --- /dev/null +++ b/src/test/ui/parser/raw/raw-literal-underscore.stderr @@ -0,0 +1,8 @@ +error: `r#_` is not currently supported. + --> $DIR/raw-literal-underscore.rs:13:20 + | +LL | fn underscore_test(r#_: u32) { + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/raw/raw_string.rs b/src/test/ui/parser/raw/raw_string.rs new file mode 100644 index 00000000000..de80abfbe49 --- /dev/null +++ b/src/test/ui/parser/raw/raw_string.rs @@ -0,0 +1,16 @@ +// 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. + +// compile-flags: -Z parse-only + +fn main() { + let x = r##"lol"#; + //~^ ERROR unterminated raw string +} diff --git a/src/test/ui/parser/raw/raw_string.stderr b/src/test/ui/parser/raw/raw_string.stderr new file mode 100644 index 00000000000..9e46d1955a0 --- /dev/null +++ b/src/test/ui/parser/raw/raw_string.stderr @@ -0,0 +1,10 @@ +error: unterminated raw string + --> $DIR/raw_string.rs:14:13 + | +LL | let x = r##"lol"#; + | ^ unterminated raw string + | + = note: this raw string should be terminated with `"##` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/recover-enum.rs b/src/test/ui/parser/recover-enum.rs new file mode 100644 index 00000000000..7de3ed10c90 --- /dev/null +++ b/src/test/ui/parser/recover-enum.rs @@ -0,0 +1,19 @@ +// Copyright 2016 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 -Z continue-parse-after-error + +fn main() { + enum Test { + Very + Bad //~ ERROR found `Bad` + Stuff + } +} diff --git a/src/test/ui/parser/recover-enum.stderr b/src/test/ui/parser/recover-enum.stderr new file mode 100644 index 00000000000..1d157c19005 --- /dev/null +++ b/src/test/ui/parser/recover-enum.stderr @@ -0,0 +1,10 @@ +error: expected one of `(`, `,`, `=`, `{`, or `}`, found `Bad` + --> $DIR/recover-enum.rs:16:9 + | +LL | Very + | - expected one of `(`, `,`, `=`, `{`, or `}` here +LL | Bad //~ ERROR found `Bad` + | ^^^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/recover-enum2.rs b/src/test/ui/parser/recover-enum2.rs new file mode 100644 index 00000000000..6fd32f842f1 --- /dev/null +++ b/src/test/ui/parser/recover-enum2.rs @@ -0,0 +1,43 @@ +// Copyright 2016 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 -Z continue-parse-after-error + +fn main() { + enum Test { + Var1, + Var2(String), + Var3 { + abc: {}, //~ ERROR: expected type, found `{` + }, + } + + // recover... + let a = 1; + enum Test2 { + Fine, + } + + enum Test3 { + StillFine { + def: i32, + }, + } + + { + // fail again + enum Test4 { + Nope(i32 {}) //~ ERROR: found `{` + //~^ ERROR: found `{` + } + } + // still recover later + let bad_syntax = _; //~ ERROR: expected expression, found reserved identifier `_` +} diff --git a/src/test/ui/parser/recover-enum2.stderr b/src/test/ui/parser/recover-enum2.stderr new file mode 100644 index 00000000000..802f0004564 --- /dev/null +++ b/src/test/ui/parser/recover-enum2.stderr @@ -0,0 +1,26 @@ +error: expected type, found `{` + --> $DIR/recover-enum2.rs:18:18 + | +LL | abc: {}, //~ ERROR: expected type, found `{` + | ^ + +error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `{` + --> $DIR/recover-enum2.rs:37:22 + | +LL | Nope(i32 {}) //~ ERROR: found `{` + | ^ expected one of 7 possible tokens here + +error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `::`, `<`, `?`, `[`, `_`, `crate`, `dyn`, `extern`, `fn`, `for`, `impl`, `pub`, `unsafe`, `}`, or lifetime, found `{` + --> $DIR/recover-enum2.rs:37:22 + | +LL | Nope(i32 {}) //~ ERROR: found `{` + | ^ expected one of 23 possible tokens here + +error: expected expression, found reserved identifier `_` + --> $DIR/recover-enum2.rs:42:22 + | +LL | let bad_syntax = _; //~ ERROR: expected expression, found reserved identifier `_` + | ^ expected expression + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/parser/recover-struct.rs b/src/test/ui/parser/recover-struct.rs new file mode 100644 index 00000000000..535dd529c0b --- /dev/null +++ b/src/test/ui/parser/recover-struct.rs @@ -0,0 +1,19 @@ +// Copyright 2016 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 -Z continue-parse-after-error + +fn main() { + struct Test { + Very + Bad //~ ERROR found `Bad` + Stuff + } +} diff --git a/src/test/ui/parser/recover-struct.stderr b/src/test/ui/parser/recover-struct.stderr new file mode 100644 index 00000000000..715c9e5f709 --- /dev/null +++ b/src/test/ui/parser/recover-struct.stderr @@ -0,0 +1,10 @@ +error: expected `:`, found `Bad` + --> $DIR/recover-struct.rs:16:9 + | +LL | Very + | - expected `:` +LL | Bad //~ ERROR found `Bad` + | ^^^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/regions-out-of-scope-slice.rs b/src/test/ui/parser/regions-out-of-scope-slice.rs new file mode 100644 index 00000000000..0ff0f9bbf87 --- /dev/null +++ b/src/test/ui/parser/regions-out-of-scope-slice.rs @@ -0,0 +1,25 @@ +// Copyright 2012-2014 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. + +// blk region isn't supported in the front-end + +// compile-flags: -Z parse-only + +fn foo(cond: bool) { + // Here we will infer a type that uses the + // region of the if stmt then block, but in the scope: + let mut x; + + if cond { + x = &'blk [1,2,3]; //~ ERROR expected `:`, found `[` + } +} + +fn main() {} diff --git a/src/test/ui/parser/regions-out-of-scope-slice.stderr b/src/test/ui/parser/regions-out-of-scope-slice.stderr new file mode 100644 index 00000000000..2eabc59882a --- /dev/null +++ b/src/test/ui/parser/regions-out-of-scope-slice.stderr @@ -0,0 +1,8 @@ +error: expected `:`, found `[` + --> $DIR/regions-out-of-scope-slice.rs:21:19 + | +LL | x = &'blk [1,2,3]; //~ ERROR expected `:`, found `[` + | ^ expected `:` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-closure-lifetime.rs b/src/test/ui/parser/removed-syntax-closure-lifetime.rs new file mode 100644 index 00000000000..b305b1894a8 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-closure-lifetime.rs @@ -0,0 +1,14 @@ +// 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 <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 + +type closure = Box<lt/fn()>; +//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/` diff --git a/src/test/ui/parser/removed-syntax-closure-lifetime.stderr b/src/test/ui/parser/removed-syntax-closure-lifetime.stderr new file mode 100644 index 00000000000..97219d5bba9 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-closure-lifetime.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/` + --> $DIR/removed-syntax-closure-lifetime.rs:13:22 + | +LL | type closure = Box<lt/fn()>; + | ^ expected one of 7 possible tokens here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-enum-newtype.rs b/src/test/ui/parser/removed-syntax-enum-newtype.rs new file mode 100644 index 00000000000..6a7f706624d --- /dev/null +++ b/src/test/ui/parser/removed-syntax-enum-newtype.rs @@ -0,0 +1,13 @@ +// 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 <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 + +enum e = isize; //~ ERROR expected one of `<`, `where`, or `{`, found `=` diff --git a/src/test/ui/parser/removed-syntax-enum-newtype.stderr b/src/test/ui/parser/removed-syntax-enum-newtype.stderr new file mode 100644 index 00000000000..97ba0ff8d58 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-enum-newtype.stderr @@ -0,0 +1,8 @@ +error: expected one of `<`, `where`, or `{`, found `=` + --> $DIR/removed-syntax-enum-newtype.rs:13:8 + | +LL | enum e = isize; //~ ERROR expected one of `<`, `where`, or `{`, found `=` + | ^ expected one of `<`, `where`, or `{` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-extern-const.rs b/src/test/ui/parser/removed-syntax-extern-const.rs new file mode 100644 index 00000000000..27688867de3 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-extern-const.rs @@ -0,0 +1,16 @@ +// 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 <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 + +extern { + const i: isize; + //~^ ERROR extern items cannot be `const` +} diff --git a/src/test/ui/parser/removed-syntax-extern-const.stderr b/src/test/ui/parser/removed-syntax-extern-const.stderr new file mode 100644 index 00000000000..b40684ccc7c --- /dev/null +++ b/src/test/ui/parser/removed-syntax-extern-const.stderr @@ -0,0 +1,8 @@ +error: extern items cannot be `const` + --> $DIR/removed-syntax-extern-const.rs:14:5 + | +LL | const i: isize; + | ^^^^^ help: try using a static value: `static` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-field-let.rs b/src/test/ui/parser/removed-syntax-field-let.rs new file mode 100644 index 00000000000..6deb3bb2e95 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-field-let.rs @@ -0,0 +1,17 @@ +// 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 <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 -Z continue-parse-after-error + +struct s { + let foo: (), + //~^ ERROR expected identifier, found keyword `let` + //~^^ ERROR expected `:`, found `foo` +} diff --git a/src/test/ui/parser/removed-syntax-field-let.stderr b/src/test/ui/parser/removed-syntax-field-let.stderr new file mode 100644 index 00000000000..8782a37b35a --- /dev/null +++ b/src/test/ui/parser/removed-syntax-field-let.stderr @@ -0,0 +1,14 @@ +error: expected identifier, found keyword `let` + --> $DIR/removed-syntax-field-let.rs:14:5 + | +LL | let foo: (), + | ^^^ expected identifier, found keyword + +error: expected `:`, found `foo` + --> $DIR/removed-syntax-field-let.rs:14:9 + | +LL | let foo: (), + | ^^^ expected `:` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/removed-syntax-field-semicolon.rs b/src/test/ui/parser/removed-syntax-field-semicolon.rs new file mode 100644 index 00000000000..409b9507769 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-field-semicolon.rs @@ -0,0 +1,16 @@ +// 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 <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 + +struct s { + bar: (); + //~^ ERROR expected `,`, or `}`, found `;` +} diff --git a/src/test/ui/parser/removed-syntax-field-semicolon.stderr b/src/test/ui/parser/removed-syntax-field-semicolon.stderr new file mode 100644 index 00000000000..3800697221e --- /dev/null +++ b/src/test/ui/parser/removed-syntax-field-semicolon.stderr @@ -0,0 +1,8 @@ +error: expected `,`, or `}`, found `;` + --> $DIR/removed-syntax-field-semicolon.rs:14:12 + | +LL | bar: (); + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-fixed-vec.rs b/src/test/ui/parser/removed-syntax-fixed-vec.rs new file mode 100644 index 00000000000..0f34db08852 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-fixed-vec.rs @@ -0,0 +1,13 @@ +// 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 <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 + +type v = [isize * 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` diff --git a/src/test/ui/parser/removed-syntax-fixed-vec.stderr b/src/test/ui/parser/removed-syntax-fixed-vec.stderr new file mode 100644 index 00000000000..737faf79a01 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-fixed-vec.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` + --> $DIR/removed-syntax-fixed-vec.rs:13:17 + | +LL | type v = [isize * 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` + | ^ expected one of 7 possible tokens here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-fn-sigil.rs b/src/test/ui/parser/removed-syntax-fn-sigil.rs new file mode 100644 index 00000000000..f47ad01d7e1 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-fn-sigil.rs @@ -0,0 +1,15 @@ +// 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 <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 f() { + let x: fn~() = || (); //~ ERROR expected `(`, found `~` +} diff --git a/src/test/ui/parser/removed-syntax-fn-sigil.stderr b/src/test/ui/parser/removed-syntax-fn-sigil.stderr new file mode 100644 index 00000000000..587be63041d --- /dev/null +++ b/src/test/ui/parser/removed-syntax-fn-sigil.stderr @@ -0,0 +1,10 @@ +error: expected `(`, found `~` + --> $DIR/removed-syntax-fn-sigil.rs:14:14 + | +LL | let x: fn~() = || (); //~ ERROR expected `(`, found `~` + | - ^ expected `(` + | | + | while parsing the type for `x` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-mode.rs b/src/test/ui/parser/removed-syntax-mode.rs new file mode 100644 index 00000000000..c2f87d8afce --- /dev/null +++ b/src/test/ui/parser/removed-syntax-mode.rs @@ -0,0 +1,14 @@ +// 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 <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 f(+x: isize) {} +//~^ ERROR expected argument name, found `+` diff --git a/src/test/ui/parser/removed-syntax-mode.stderr b/src/test/ui/parser/removed-syntax-mode.stderr new file mode 100644 index 00000000000..7ad88471d5a --- /dev/null +++ b/src/test/ui/parser/removed-syntax-mode.stderr @@ -0,0 +1,8 @@ +error: expected argument name, found `+` + --> $DIR/removed-syntax-mode.rs:13:6 + | +LL | fn f(+x: isize) {} + | ^ expected argument name + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-mut-vec-expr.rs b/src/test/ui/parser/removed-syntax-mut-vec-expr.rs new file mode 100644 index 00000000000..7e5bd27b497 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-mut-vec-expr.rs @@ -0,0 +1,15 @@ +// 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 <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 f() { + let v = [mut 1, 2, 3, 4]; //~ ERROR expected expression, found keyword `mut` +} diff --git a/src/test/ui/parser/removed-syntax-mut-vec-expr.stderr b/src/test/ui/parser/removed-syntax-mut-vec-expr.stderr new file mode 100644 index 00000000000..253ecf41edd --- /dev/null +++ b/src/test/ui/parser/removed-syntax-mut-vec-expr.stderr @@ -0,0 +1,8 @@ +error: expected expression, found keyword `mut` + --> $DIR/removed-syntax-mut-vec-expr.rs:14:14 + | +LL | let v = [mut 1, 2, 3, 4]; //~ ERROR expected expression, found keyword `mut` + | ^^^ expected expression + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-mut-vec-ty.rs b/src/test/ui/parser/removed-syntax-mut-vec-ty.rs new file mode 100644 index 00000000000..0cdf1981a23 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-mut-vec-ty.rs @@ -0,0 +1,13 @@ +// 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 <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 + +type v = [mut isize]; //~ ERROR expected type, found keyword `mut` diff --git a/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr b/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr new file mode 100644 index 00000000000..d6b47accb97 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr @@ -0,0 +1,8 @@ +error: expected type, found keyword `mut` + --> $DIR/removed-syntax-mut-vec-ty.rs:13:11 + | +LL | type v = [mut isize]; //~ ERROR expected type, found keyword `mut` + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-ptr-lifetime.rs b/src/test/ui/parser/removed-syntax-ptr-lifetime.rs new file mode 100644 index 00000000000..b91ab8730b3 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-ptr-lifetime.rs @@ -0,0 +1,13 @@ +// 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 <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 + +type bptr = &lifetime/isize; //~ ERROR expected one of `!`, `(`, `::`, `;`, or `<`, found `/` diff --git a/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr b/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr new file mode 100644 index 00000000000..2538e5473ee --- /dev/null +++ b/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `::`, `;`, or `<`, found `/` + --> $DIR/removed-syntax-ptr-lifetime.rs:13:22 + | +LL | type bptr = &lifetime/isize; //~ ERROR expected one of `!`, `(`, `::`, `;`, or `<`, found `/` + | ^ expected one of `!`, `(`, `::`, `;`, or `<` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-record.rs b/src/test/ui/parser/removed-syntax-record.rs new file mode 100644 index 00000000000..fd6f99bdbf9 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-record.rs @@ -0,0 +1,13 @@ +// 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 <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 + +type t = { f: () }; //~ ERROR expected type, found `{` diff --git a/src/test/ui/parser/removed-syntax-record.stderr b/src/test/ui/parser/removed-syntax-record.stderr new file mode 100644 index 00000000000..99d4ef44f9a --- /dev/null +++ b/src/test/ui/parser/removed-syntax-record.stderr @@ -0,0 +1,8 @@ +error: expected type, found `{` + --> $DIR/removed-syntax-record.rs:13:10 + | +LL | type t = { f: () }; //~ ERROR expected type, found `{` + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-static-fn.rs b/src/test/ui/parser/removed-syntax-static-fn.rs new file mode 100644 index 00000000000..4c0cd3358dd --- /dev/null +++ b/src/test/ui/parser/removed-syntax-static-fn.rs @@ -0,0 +1,19 @@ +// 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 <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 +// ignore-tidy-linelength + +struct S; + +impl S { + static fn f() {} +} +//~^^ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, diff --git a/src/test/ui/parser/removed-syntax-static-fn.stderr b/src/test/ui/parser/removed-syntax-static-fn.stderr new file mode 100644 index 00000000000..dd3b0e00101 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-static-fn.stderr @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static` + --> $DIR/removed-syntax-static-fn.rs:17:5 + | +LL | impl S { + | - expected one of 11 possible tokens here +LL | static fn f() {} + | ^^^^^^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-uniq-mut-expr.rs b/src/test/ui/parser/removed-syntax-uniq-mut-expr.rs new file mode 100644 index 00000000000..b16c77ab6b5 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-uniq-mut-expr.rs @@ -0,0 +1,15 @@ +// 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 <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 f() { + let a_box = box mut 42; //~ ERROR expected expression, found keyword `mut` +} diff --git a/src/test/ui/parser/removed-syntax-uniq-mut-expr.stderr b/src/test/ui/parser/removed-syntax-uniq-mut-expr.stderr new file mode 100644 index 00000000000..54e6a517343 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-uniq-mut-expr.stderr @@ -0,0 +1,8 @@ +error: expected expression, found keyword `mut` + --> $DIR/removed-syntax-uniq-mut-expr.rs:14:21 + | +LL | let a_box = box mut 42; //~ ERROR expected expression, found keyword `mut` + | ^^^ expected expression + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs b/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs new file mode 100644 index 00000000000..8a47376179d --- /dev/null +++ b/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs @@ -0,0 +1,13 @@ +// 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 <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 + +type mut_box = Box<mut isize>; //~ ERROR expected one of `>`, lifetime, or type, found `mut` diff --git a/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr b/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr new file mode 100644 index 00000000000..e9660f3e1c2 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr @@ -0,0 +1,8 @@ +error: expected one of `>`, lifetime, or type, found `mut` + --> $DIR/removed-syntax-uniq-mut-ty.rs:13:20 + | +LL | type mut_box = Box<mut isize>; //~ ERROR expected one of `>`, lifetime, or type, found `mut` + | ^^^ expected one of `>`, lifetime, or type here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-with-1.rs b/src/test/ui/parser/removed-syntax-with-1.rs new file mode 100644 index 00000000000..156b172a944 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-with-1.rs @@ -0,0 +1,22 @@ +// 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 <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 removed_with() { + struct S { + foo: (), + bar: (), + } + + let a = S { foo: (), bar: () }; + let b = S { foo: () with a }; + //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `with` +} diff --git a/src/test/ui/parser/removed-syntax-with-1.stderr b/src/test/ui/parser/removed-syntax-with-1.stderr new file mode 100644 index 00000000000..37baf742ed8 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-with-1.stderr @@ -0,0 +1,8 @@ +error: expected one of `,`, `.`, `?`, `}`, or an operator, found `with` + --> $DIR/removed-syntax-with-1.rs:20:25 + | +LL | let b = S { foo: () with a }; + | ^^^^ expected one of `,`, `.`, `?`, `}`, or an operator here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/removed-syntax-with-2.rs b/src/test/ui/parser/removed-syntax-with-2.rs new file mode 100644 index 00000000000..c4354c07604 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-with-2.rs @@ -0,0 +1,22 @@ +// 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 <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 removed_with() { + struct S { + foo: (), + bar: (), + } + + let a = S { foo: (), bar: () }; + let b = S { foo: (), with a }; + //~^ ERROR expected one of `,` or `}`, found `a` +} diff --git a/src/test/ui/parser/removed-syntax-with-2.stderr b/src/test/ui/parser/removed-syntax-with-2.stderr new file mode 100644 index 00000000000..6999196c1b7 --- /dev/null +++ b/src/test/ui/parser/removed-syntax-with-2.stderr @@ -0,0 +1,8 @@ +error: expected one of `,` or `}`, found `a` + --> $DIR/removed-syntax-with-2.rs:20:31 + | +LL | let b = S { foo: (), with a }; + | ^ expected one of `,` or `}` here + +error: aborting due to previous error + diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.rs b/src/test/ui/parser/require-parens-for-chained-comparison.rs new file mode 100644 index 00000000000..1ee6996ce9c --- /dev/null +++ b/src/test/ui/parser/require-parens-for-chained-comparison.rs @@ -0,0 +1,26 @@ +// Copyright 2015 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 f<T>() {} + +fn main() { + false == false == false; + //~^ ERROR: chained comparison operators require parentheses + + false == 0 < 2; + //~^ ERROR: chained comparison operators require parentheses + + f<X>(); + //~^ ERROR: chained comparison operators require parentheses + //~| HELP: use `::<...>` instead of `<...>` + //~| HELP: or use `(...)` +} diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.stderr b/src/test/ui/parser/require-parens-for-chained-comparison.stderr new file mode 100644 index 00000000000..8facdab4285 --- /dev/null +++ b/src/test/ui/parser/require-parens-for-chained-comparison.stderr @@ -0,0 +1,23 @@ +error: chained comparison operators require parentheses + --> $DIR/require-parens-for-chained-comparison.rs:16:11 + | +LL | false == false == false; + | ^^^^^^^^^^^^^^^^^ + +error: chained comparison operators require parentheses + --> $DIR/require-parens-for-chained-comparison.rs:19:11 + | +LL | false == 0 < 2; + | ^^^^^^^^ + +error: chained comparison operators require parentheses + --> $DIR/require-parens-for-chained-comparison.rs:22:6 + | +LL | f<X>(); + | ^^^^ + | + = help: use `::<...>` instead of `<...>` if you meant to specify type arguments + = help: or use `(...)` if you meant to specify fn arguments + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/parser/struct-field-numeric-shorthand.rs b/src/test/ui/parser/struct-field-numeric-shorthand.rs new file mode 100644 index 00000000000..49ba0d8bde6 --- /dev/null +++ b/src/test/ui/parser/struct-field-numeric-shorthand.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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 + +struct Rgb(u8, u8, u8); + +fn main() { + let _ = Rgb { 0, 1, 2 }; //~ ERROR expected identifier, found `0` +} diff --git a/src/test/ui/parser/struct-field-numeric-shorthand.stderr b/src/test/ui/parser/struct-field-numeric-shorthand.stderr new file mode 100644 index 00000000000..e909a9ece60 --- /dev/null +++ b/src/test/ui/parser/struct-field-numeric-shorthand.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found `0` + --> $DIR/struct-field-numeric-shorthand.rs:16:19 + | +LL | let _ = Rgb { 0, 1, 2 }; //~ ERROR expected identifier, found `0` + | --- ^ expected identifier + | | + | while parsing this struct + +error: aborting due to previous error + diff --git a/src/test/ui/parser/struct-literal-in-for.rs b/src/test/ui/parser/struct-literal-in-for.rs new file mode 100644 index 00000000000..93098455560 --- /dev/null +++ b/src/test/ui/parser/struct-literal-in-for.rs @@ -0,0 +1,29 @@ +// 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 + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + for x in Foo { + x: 3 //~ ERROR expected type, found `3` + }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + println!("yo"); + } +} diff --git a/src/test/ui/parser/struct-literal-in-for.stderr b/src/test/ui/parser/struct-literal-in-for.stderr new file mode 100644 index 00000000000..4a074eef889 --- /dev/null +++ b/src/test/ui/parser/struct-literal-in-for.stderr @@ -0,0 +1,14 @@ +error: expected type, found `3` + --> $DIR/struct-literal-in-for.rs:25:12 + | +LL | x: 3 //~ ERROR expected type, found `3` + | ^ expecting a type here because of type ascription + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + --> $DIR/struct-literal-in-for.rs:26:12 + | +LL | }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/struct-literal-in-if.rs b/src/test/ui/parser/struct-literal-in-if.rs new file mode 100644 index 00000000000..db6a360a567 --- /dev/null +++ b/src/test/ui/parser/struct-literal-in-if.rs @@ -0,0 +1,29 @@ +// 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 + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + if Foo { + x: 3 //~ ERROR expected type, found `3` + }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + println!("yo"); + } +} diff --git a/src/test/ui/parser/struct-literal-in-if.stderr b/src/test/ui/parser/struct-literal-in-if.stderr new file mode 100644 index 00000000000..02659ffb5aa --- /dev/null +++ b/src/test/ui/parser/struct-literal-in-if.stderr @@ -0,0 +1,14 @@ +error: expected type, found `3` + --> $DIR/struct-literal-in-if.rs:25:12 + | +LL | x: 3 //~ ERROR expected type, found `3` + | ^ expecting a type here because of type ascription + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + --> $DIR/struct-literal-in-if.rs:26:12 + | +LL | }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/struct-literal-in-match-discriminant.rs b/src/test/ui/parser/struct-literal-in-match-discriminant.rs new file mode 100644 index 00000000000..7038cc798c4 --- /dev/null +++ b/src/test/ui/parser/struct-literal-in-match-discriminant.rs @@ -0,0 +1,25 @@ +// 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 + +struct Foo { + x: isize, +} + +fn main() { + match Foo { + x: 3 //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `:` + } { + Foo { + x: x + } => {} //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `=>` + } +} diff --git a/src/test/ui/parser/struct-literal-in-match-discriminant.stderr b/src/test/ui/parser/struct-literal-in-match-discriminant.stderr new file mode 100644 index 00000000000..9b8eecd389e --- /dev/null +++ b/src/test/ui/parser/struct-literal-in-match-discriminant.stderr @@ -0,0 +1,14 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `:` + --> $DIR/struct-literal-in-match-discriminant.rs:19:10 + | +LL | x: 3 //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `:` + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `=>` + --> $DIR/struct-literal-in-match-discriminant.rs:23:11 + | +LL | } => {} //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `=>` + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/struct-literal-in-while.rs b/src/test/ui/parser/struct-literal-in-while.rs new file mode 100644 index 00000000000..75e4eb3de07 --- /dev/null +++ b/src/test/ui/parser/struct-literal-in-while.rs @@ -0,0 +1,29 @@ +// 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 + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + while Foo { + x: 3 //~ ERROR expected type, found `3` + }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + println!("yo"); + } +} diff --git a/src/test/ui/parser/struct-literal-in-while.stderr b/src/test/ui/parser/struct-literal-in-while.stderr new file mode 100644 index 00000000000..6ecc14cd081 --- /dev/null +++ b/src/test/ui/parser/struct-literal-in-while.stderr @@ -0,0 +1,14 @@ +error: expected type, found `3` + --> $DIR/struct-literal-in-while.rs:25:12 + | +LL | x: 3 //~ ERROR expected type, found `3` + | ^ expecting a type here because of type ascription + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + --> $DIR/struct-literal-in-while.rs:26:12 + | +LL | }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/struct-literal-restrictions-in-lamda.rs b/src/test/ui/parser/struct-literal-restrictions-in-lamda.rs new file mode 100644 index 00000000000..6b7a26556f4 --- /dev/null +++ b/src/test/ui/parser/struct-literal-restrictions-in-lamda.rs @@ -0,0 +1,29 @@ +// Copyright 2017 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 + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + while || Foo { + x: 3 //~ ERROR expected type, found `3` + }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + println!("yo"); + } +} diff --git a/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr b/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr new file mode 100644 index 00000000000..1341a2b241d --- /dev/null +++ b/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr @@ -0,0 +1,14 @@ +error: expected type, found `3` + --> $DIR/struct-literal-restrictions-in-lamda.rs:25:12 + | +LL | x: 3 //~ ERROR expected type, found `3` + | ^ expecting a type here because of type ascription + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + --> $DIR/struct-literal-restrictions-in-lamda.rs:26:12 + | +LL | }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/tag-variant-disr-non-nullary.rs b/src/test/ui/parser/tag-variant-disr-non-nullary.rs new file mode 100644 index 00000000000..2d86589285c --- /dev/null +++ b/src/test/ui/parser/tag-variant-disr-non-nullary.rs @@ -0,0 +1,22 @@ +// 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 + +//error-pattern: discriminator values can only be used with a field-less enum + +enum color { + red = 0xff0000, + green = 0x00ff00, + blue = 0x0000ff, + black = 0x000000, + white = 0xffffff, + other (str), +} diff --git a/src/test/ui/parser/tag-variant-disr-non-nullary.stderr b/src/test/ui/parser/tag-variant-disr-non-nullary.stderr new file mode 100644 index 00000000000..990ddca05d9 --- /dev/null +++ b/src/test/ui/parser/tag-variant-disr-non-nullary.stderr @@ -0,0 +1,8 @@ +error: discriminator values can only be used with a field-less enum + --> $DIR/tag-variant-disr-non-nullary.rs:20:13 + | +LL | white = 0xffffff, + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/trailing-carriage-return-in-string.rs b/src/test/ui/parser/trailing-carriage-return-in-string.rs new file mode 100644 index 00000000000..dd763dc64c0 --- /dev/null +++ b/src/test/ui/parser/trailing-carriage-return-in-string.rs @@ -0,0 +1,25 @@ +// Copyright 2014 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 + +// ignore-tidy-cr +// Issue #11669 + +fn main() { + // \r\n + let ok = "This is \ + a test"; + // \r only + let bad = "This is \ a test"; + //~^ ERROR unknown character escape: \r + //~^^ HELP this is an isolated carriage return + +} diff --git a/src/test/ui/parser/trailing-carriage-return-in-string.stderr b/src/test/ui/parser/trailing-carriage-return-in-string.stderr new file mode 100644 index 00000000000..4e6d38dd7af --- /dev/null +++ b/src/test/ui/parser/trailing-carriage-return-in-string.stderr @@ -0,0 +1,14 @@ +error: unknown character escape: /r + --> $DIR/trailing-carriage-return-in-string.rs:21:25 + | +LL | let bad = "This is / a test"; + | ^ + | +help: this is an isolated carriage return; consider checking your editor and version control settings + --> $DIR/trailing-carriage-return-in-string.rs:21:25 + | +LL | let bad = "This is / a test"; + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/trailing-plus-in-bounds.rs b/src/test/ui/parser/trailing-plus-in-bounds.rs new file mode 100644 index 00000000000..b0dda815f83 --- /dev/null +++ b/src/test/ui/parser/trailing-plus-in-bounds.rs @@ -0,0 +1,18 @@ +// 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-pass +// compile-flags: -Z parse-only -Z continue-parse-after-error + +use std::fmt::Debug; + +fn main() { + let x: Box<Debug+> = box 3 as Box<Debug+>; // Trailing `+` is OK +} diff --git a/src/test/ui/parser/trait-bounds-not-on-impl.rs b/src/test/ui/parser/trait-bounds-not-on-impl.rs new file mode 100644 index 00000000000..7cd2774fe39 --- /dev/null +++ b/src/test/ui/parser/trait-bounds-not-on-impl.rs @@ -0,0 +1,21 @@ +// 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 <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 -Z continue-parse-after-error + +trait Foo { +} + +struct Bar; + +impl Foo + Owned for Bar { //~ ERROR expected a trait, found type +} + +fn main() { } diff --git a/src/test/ui/parser/trait-bounds-not-on-impl.stderr b/src/test/ui/parser/trait-bounds-not-on-impl.stderr new file mode 100644 index 00000000000..68bb090e45f --- /dev/null +++ b/src/test/ui/parser/trait-bounds-not-on-impl.stderr @@ -0,0 +1,8 @@ +error: expected a trait, found type + --> $DIR/trait-bounds-not-on-impl.rs:18:6 + | +LL | impl Foo + Owned for Bar { //~ ERROR expected a trait, found type + | ^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/trait-object-bad-parens.rs b/src/test/ui/parser/trait-object-bad-parens.rs new file mode 100644 index 00000000000..25e9c3071d6 --- /dev/null +++ b/src/test/ui/parser/trait-object-bad-parens.rs @@ -0,0 +1,22 @@ +// Copyright 2017 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 -Z continue-parse-after-error + +fn main() { + let _: Box<((Copy)) + Copy>; + //~^ ERROR expected a path on the left-hand side of `+`, not `((Copy))` + let _: Box<(Copy + Copy) + Copy>; + //~^ ERROR expected a path on the left-hand side of `+`, not `(Copy + Copy)` + let _: Box<(Copy +) + Copy>; + //~^ ERROR expected a path on the left-hand side of `+`, not `(Copy)` + let _: Box<(dyn Copy) + Copy>; + //~^ ERROR expected a path on the left-hand side of `+`, not `(dyn Copy)` +} diff --git a/src/test/ui/parser/trait-object-bad-parens.stderr b/src/test/ui/parser/trait-object-bad-parens.stderr new file mode 100644 index 00000000000..a1c483c3eca --- /dev/null +++ b/src/test/ui/parser/trait-object-bad-parens.stderr @@ -0,0 +1,27 @@ +error[E0178]: expected a path on the left-hand side of `+`, not `((Copy))` + --> $DIR/trait-object-bad-parens.rs:14:16 + | +LL | let _: Box<((Copy)) + Copy>; + | ^^^^^^^^^^^^^^^ expected a path + +error[E0178]: expected a path on the left-hand side of `+`, not `(Copy + Copy)` + --> $DIR/trait-object-bad-parens.rs:16:16 + | +LL | let _: Box<(Copy + Copy) + Copy>; + | ^^^^^^^^^^^^^^^^^^^^ expected a path + +error[E0178]: expected a path on the left-hand side of `+`, not `(Copy)` + --> $DIR/trait-object-bad-parens.rs:18:16 + | +LL | let _: Box<(Copy +) + Copy>; + | ^^^^^^^^^^^^^^^ expected a path + +error[E0178]: expected a path on the left-hand side of `+`, not `(dyn Copy)` + --> $DIR/trait-object-bad-parens.rs:20:16 + | +LL | let _: Box<(dyn Copy) + Copy>; + | ^^^^^^^^^^^^^^^^^ expected a path + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0178`. diff --git a/src/test/ui/parser/trait-object-lifetime-parens.rs b/src/test/ui/parser/trait-object-lifetime-parens.rs new file mode 100644 index 00000000000..6be62d966eb --- /dev/null +++ b/src/test/ui/parser/trait-object-lifetime-parens.rs @@ -0,0 +1,18 @@ +// Copyright 2017 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 -Z continue-parse-after-error + +fn f<T: Copy + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported + +fn main() { + let _: Box<Copy + ('a)>; //~ ERROR parenthesized lifetime bounds are not supported + let _: Box<('a) + Copy>; //~ ERROR expected type, found `'a` +} diff --git a/src/test/ui/parser/trait-object-lifetime-parens.stderr b/src/test/ui/parser/trait-object-lifetime-parens.stderr new file mode 100644 index 00000000000..7c7921bd38d --- /dev/null +++ b/src/test/ui/parser/trait-object-lifetime-parens.stderr @@ -0,0 +1,22 @@ +error: parenthesized lifetime bounds are not supported + --> $DIR/trait-object-lifetime-parens.rs:13:19 + | +LL | fn f<T: Copy + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported + | ^ + +error: parenthesized lifetime bounds are not supported + --> $DIR/trait-object-lifetime-parens.rs:16:26 + | +LL | let _: Box<Copy + ('a)>; //~ ERROR parenthesized lifetime bounds are not supported + | ^ + +error: expected type, found `'a` + --> $DIR/trait-object-lifetime-parens.rs:17:17 + | +LL | let _: Box<('a) + Copy>; //~ ERROR expected type, found `'a` + | - ^^ + | | + | while parsing the type for `_` + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/parser/trait-object-polytrait-priority.rs b/src/test/ui/parser/trait-object-polytrait-priority.rs new file mode 100644 index 00000000000..646ef487665 --- /dev/null +++ b/src/test/ui/parser/trait-object-polytrait-priority.rs @@ -0,0 +1,20 @@ +// Copyright 2017 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 + +trait Trait<'a> {} + +fn main() { + let _: &for<'a> Trait<'a> + 'static; + //~^ ERROR expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>` + //~| HELP try adding parentheses + //~| SUGGESTION &(for<'a> Trait<'a> + 'static) +} diff --git a/src/test/ui/parser/trait-object-polytrait-priority.stderr b/src/test/ui/parser/trait-object-polytrait-priority.stderr new file mode 100644 index 00000000000..4ceff81885a --- /dev/null +++ b/src/test/ui/parser/trait-object-polytrait-priority.stderr @@ -0,0 +1,9 @@ +error[E0178]: expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>` + --> $DIR/trait-object-polytrait-priority.rs:16:12 + | +LL | let _: &for<'a> Trait<'a> + 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&(for<'a> Trait<'a> + 'static)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0178`. diff --git a/src/test/ui/parser/trait-object-trait-parens.rs b/src/test/ui/parser/trait-object-trait-parens.rs new file mode 100644 index 00000000000..1feb0c84532 --- /dev/null +++ b/src/test/ui/parser/trait-object-trait-parens.rs @@ -0,0 +1,20 @@ +// Copyright 2017 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-pass +// compile-flags: -Z parse-only + +fn f<T: (Copy) + (?Sized) + (for<'a> Trait<'a>)>() {} + +fn main() { + let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>; + let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>; + let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>; +} diff --git a/src/test/ui/parser/trait-plusequal-splitting.rs b/src/test/ui/parser/trait-plusequal-splitting.rs new file mode 100644 index 00000000000..32174d6254a --- /dev/null +++ b/src/test/ui/parser/trait-plusequal-splitting.rs @@ -0,0 +1,19 @@ +// 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. + +// Fixes issue where `+` in generics weren't parsed if they were part of a `+=`. + +// compile-pass +// compile-flags: -Z parse-only + +struct Whitespace<T: Clone + = ()> { t: T } +struct TokenSplit<T: Clone += ()> { t: T } + +fn main() {} diff --git a/src/test/ui/parser/trait-pub-assoc-const.rs b/src/test/ui/parser/trait-pub-assoc-const.rs new file mode 100644 index 00000000000..0a412092017 --- /dev/null +++ b/src/test/ui/parser/trait-pub-assoc-const.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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 + +trait Foo { + pub const Foo: u32; + //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found +} + +fn main() {} diff --git a/src/test/ui/parser/trait-pub-assoc-const.stderr b/src/test/ui/parser/trait-pub-assoc-const.stderr new file mode 100644 index 00000000000..9e82d348453 --- /dev/null +++ b/src/test/ui/parser/trait-pub-assoc-const.stderr @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub` + --> $DIR/trait-pub-assoc-const.rs:14:5 + | +LL | trait Foo { + | - expected one of 7 possible tokens here +LL | pub const Foo: u32; + | ^^^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/trait-pub-assoc-ty.rs b/src/test/ui/parser/trait-pub-assoc-ty.rs new file mode 100644 index 00000000000..940743d3ffa --- /dev/null +++ b/src/test/ui/parser/trait-pub-assoc-ty.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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 + +trait Foo { + pub type Foo; + //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found +} + +fn main() {} diff --git a/src/test/ui/parser/trait-pub-assoc-ty.stderr b/src/test/ui/parser/trait-pub-assoc-ty.stderr new file mode 100644 index 00000000000..47ae68353ac --- /dev/null +++ b/src/test/ui/parser/trait-pub-assoc-ty.stderr @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub` + --> $DIR/trait-pub-assoc-ty.rs:14:5 + | +LL | trait Foo { + | - expected one of 7 possible tokens here +LL | pub type Foo; + | ^^^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/trait-pub-method.rs b/src/test/ui/parser/trait-pub-method.rs new file mode 100644 index 00000000000..f9c064a105c --- /dev/null +++ b/src/test/ui/parser/trait-pub-method.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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 + +trait Foo { + pub fn foo(); + //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found +} + +fn main() {} diff --git a/src/test/ui/parser/trait-pub-method.stderr b/src/test/ui/parser/trait-pub-method.stderr new file mode 100644 index 00000000000..49bcb64aa7d --- /dev/null +++ b/src/test/ui/parser/trait-pub-method.stderr @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub` + --> $DIR/trait-pub-method.rs:14:5 + | +LL | trait Foo { + | - expected one of 7 possible tokens here +LL | pub fn foo(); + | ^^^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/ui/parser/type-parameters-in-field-exprs.rs b/src/test/ui/parser/type-parameters-in-field-exprs.rs new file mode 100644 index 00000000000..cb018ff1bfa --- /dev/null +++ b/src/test/ui/parser/type-parameters-in-field-exprs.rs @@ -0,0 +1,29 @@ +// Copyright 2014 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 -Z continue-parse-after-error + +struct Foo { + x: isize, + y: isize, +} + +fn main() { + let f = Foo { + x: 1, + y: 2, + }; + f.x::<isize>; + //~^ ERROR field expressions may not have generic arguments + f.x::<>; + //~^ ERROR field expressions may not have generic arguments + f.x::(); + //~^ ERROR field expressions may not have generic arguments +} diff --git a/src/test/ui/parser/type-parameters-in-field-exprs.stderr b/src/test/ui/parser/type-parameters-in-field-exprs.stderr new file mode 100644 index 00000000000..f8b63b49be3 --- /dev/null +++ b/src/test/ui/parser/type-parameters-in-field-exprs.stderr @@ -0,0 +1,20 @@ +error: field expressions may not have generic arguments + --> $DIR/type-parameters-in-field-exprs.rs:23:8 + | +LL | f.x::<isize>; + | ^^^^^^^^^ + +error: field expressions may not have generic arguments + --> $DIR/type-parameters-in-field-exprs.rs:25:8 + | +LL | f.x::<>; + | ^^^^ + +error: field expressions may not have generic arguments + --> $DIR/type-parameters-in-field-exprs.rs:27:8 + | +LL | f.x::(); + | ^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/parser/unbalanced-doublequote.rs b/src/test/ui/parser/unbalanced-doublequote.rs new file mode 100644 index 00000000000..8d10f64504a --- /dev/null +++ b/src/test/ui/parser/unbalanced-doublequote.rs @@ -0,0 +1,19 @@ +// 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 + + +// error-pattern: unterminated double quote string + + +fn main() { + " +} diff --git a/src/test/ui/parser/unbalanced-doublequote.stderr b/src/test/ui/parser/unbalanced-doublequote.stderr new file mode 100644 index 00000000000..e12eceeb24b --- /dev/null +++ b/src/test/ui/parser/unbalanced-doublequote.stderr @@ -0,0 +1,9 @@ +error: unterminated double quote string + --> $DIR/unbalanced-doublequote.rs:18:5 + | +LL | / " +LL | | } + | |__^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/unclosed-braces.rs b/src/test/ui/parser/unclosed-braces.rs index 802133ae6b9..82f2ffd4dc0 100644 --- a/src/test/ui/parser/unclosed-braces.rs +++ b/src/test/ui/parser/unclosed-braces.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z parse-only + struct S { x: [usize; 3], } diff --git a/src/test/ui/parser/unclosed-braces.stderr b/src/test/ui/parser/unclosed-braces.stderr index 4f865bc9b39..3fdfdc0a809 100644 --- a/src/test/ui/parser/unclosed-braces.stderr +++ b/src/test/ui/parser/unclosed-braces.stderr @@ -1,5 +1,5 @@ error: this file contains an un-closed delimiter - --> $DIR/unclosed-braces.rs:32:53 + --> $DIR/unclosed-braces.rs:34:53 | LL | fn main() { | - un-closed delimiter diff --git a/src/test/ui/parser/underscore-suffix-for-float.rs b/src/test/ui/parser/underscore-suffix-for-float.rs new file mode 100644 index 00000000000..bb1cf5949b9 --- /dev/null +++ b/src/test/ui/parser/underscore-suffix-for-float.rs @@ -0,0 +1,15 @@ +// Copyright 2017 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 main() { + let a = 42._; //~ ERROR expected identifier, found reserved identifier `_` +} diff --git a/src/test/ui/parser/underscore-suffix-for-float.stderr b/src/test/ui/parser/underscore-suffix-for-float.stderr new file mode 100644 index 00000000000..18e6dac2608 --- /dev/null +++ b/src/test/ui/parser/underscore-suffix-for-float.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/underscore-suffix-for-float.rs:14:16 + | +LL | let a = 42._; //~ ERROR expected identifier, found reserved identifier `_` + | ^ expected identifier, found reserved identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/underscore-suffix-for-string.rs b/src/test/ui/parser/underscore-suffix-for-string.rs new file mode 100644 index 00000000000..3ef29a3692e --- /dev/null +++ b/src/test/ui/parser/underscore-suffix-for-string.rs @@ -0,0 +1,19 @@ +// Copyright 2017 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-pass +// compile-flags: -Z parse-only + +fn main() { + let _ = "Foo"_; + //~^ WARNING underscore literal suffix is not allowed + //~| WARNING this was previously accepted + //~| NOTE issue #42326 +} diff --git a/src/test/ui/parser/underscore-suffix-for-string.stderr b/src/test/ui/parser/underscore-suffix-for-string.stderr new file mode 100644 index 00000000000..bbce7097354 --- /dev/null +++ b/src/test/ui/parser/underscore-suffix-for-string.stderr @@ -0,0 +1,9 @@ +warning: underscore literal suffix is not allowed + --> $DIR/underscore-suffix-for-string.rs:15:18 + | +LL | let _ = "Foo"_; + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42326 <https://github.com/rust-lang/rust/issues/42326> + diff --git a/src/test/ui/parser/unicode-chars.rs b/src/test/ui/parser/unicode-chars.rs new file mode 100644 index 00000000000..f590a7f2aa2 --- /dev/null +++ b/src/test/ui/parser/unicode-chars.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 main() { + let y = 0; + //~^ ERROR unknown start of token: \u{37e} + //~^^ HELP Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not +} diff --git a/src/test/ui/parser/unicode-chars.stderr b/src/test/ui/parser/unicode-chars.stderr new file mode 100644 index 00000000000..5c30a5040f0 --- /dev/null +++ b/src/test/ui/parser/unicode-chars.stderr @@ -0,0 +1,12 @@ +error: unknown start of token: /u{37e} + --> $DIR/unicode-chars.rs:14:14 + | +LL | let y = 0; + | ^ +help: Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not + | +LL | let y = 0; + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/unsized.rs b/src/test/ui/parser/unsized.rs new file mode 100644 index 00000000000..533b947b79a --- /dev/null +++ b/src/test/ui/parser/unsized.rs @@ -0,0 +1,19 @@ +// Copyright 2014 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 + +// Test syntax checks for `type` keyword. + +struct S1 for type; +//~^ ERROR expected `where`, `{`, `(`, or `;` after struct name, found keyword `for` + +pub fn main() { +} diff --git a/src/test/ui/parser/unsized.stderr b/src/test/ui/parser/unsized.stderr new file mode 100644 index 00000000000..cc35c2035ea --- /dev/null +++ b/src/test/ui/parser/unsized.stderr @@ -0,0 +1,8 @@ +error: expected `where`, `{`, `(`, or `;` after struct name, found keyword `for` + --> $DIR/unsized.rs:15:11 + | +LL | struct S1 for type; + | ^^^ expected `where`, `{`, `(`, or `;` after struct name + +error: aborting due to previous error + diff --git a/src/test/ui/parser/unsized2.rs b/src/test/ui/parser/unsized2.rs new file mode 100644 index 00000000000..f3af8740be9 --- /dev/null +++ b/src/test/ui/parser/unsized2.rs @@ -0,0 +1,19 @@ +// Copyright 2014 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 + +// Test syntax checks for `type` keyword. + +fn f<X>() {} + +pub fn main() { + f<type>(); //~ ERROR expected expression, found keyword `type` +} diff --git a/src/test/ui/parser/unsized2.stderr b/src/test/ui/parser/unsized2.stderr new file mode 100644 index 00000000000..323b8fd9ea8 --- /dev/null +++ b/src/test/ui/parser/unsized2.stderr @@ -0,0 +1,8 @@ +error: expected expression, found keyword `type` + --> $DIR/unsized2.rs:18:7 + | +LL | f<type>(); //~ ERROR expected expression, found keyword `type` + | ^^^^ expected expression + +error: aborting due to previous error + diff --git a/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.rs b/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.rs new file mode 100644 index 00000000000..9e16e29ba50 --- /dev/null +++ b/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.rs @@ -0,0 +1,14 @@ +// Copyright 2015 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 -Z continue-parse-after-error + +use std::any:: as foo; //~ ERROR expected identifier, found keyword `as` +//~^ ERROR: expected one of `::`, `;`, or `as`, found `foo` diff --git a/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr b/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr new file mode 100644 index 00000000000..e7452f403b2 --- /dev/null +++ b/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr @@ -0,0 +1,14 @@ +error: expected identifier, found keyword `as` + --> $DIR/use-as-where-use-ends-with-mod-sep.rs:13:16 + | +LL | use std::any:: as foo; //~ ERROR expected identifier, found keyword `as` + | ^^ expected identifier, found keyword + +error: expected one of `::`, `;`, or `as`, found `foo` + --> $DIR/use-as-where-use-ends-with-mod-sep.rs:13:19 + | +LL | use std::any:: as foo; //~ ERROR expected identifier, found keyword `as` + | ^^^ expected one of `::`, `;`, or `as` here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/use-ends-with-mod-sep.rs b/src/test/ui/parser/use-ends-with-mod-sep.rs new file mode 100644 index 00000000000..e6a10d43e29 --- /dev/null +++ b/src/test/ui/parser/use-ends-with-mod-sep.rs @@ -0,0 +1,13 @@ +// Copyright 2015 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 + +use std::any::; //~ ERROR expected identifier, found `;` diff --git a/src/test/ui/parser/use-ends-with-mod-sep.stderr b/src/test/ui/parser/use-ends-with-mod-sep.stderr new file mode 100644 index 00000000000..c463f746a58 --- /dev/null +++ b/src/test/ui/parser/use-ends-with-mod-sep.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `;` + --> $DIR/use-ends-with-mod-sep.rs:13:15 + | +LL | use std::any::; //~ ERROR expected identifier, found `;` + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/parser/variadic-ffi-3.rs b/src/test/ui/parser/variadic-ffi-3.rs new file mode 100644 index 00000000000..d202fa33cc1 --- /dev/null +++ b/src/test/ui/parser/variadic-ffi-3.rs @@ -0,0 +1,17 @@ +// 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 <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(x: isize, ...) { + //~^ ERROR: only foreign functions are allowed to be variadic +} + +fn main() {} diff --git a/src/test/ui/parser/variadic-ffi-3.stderr b/src/test/ui/parser/variadic-ffi-3.stderr new file mode 100644 index 00000000000..93f19253f00 --- /dev/null +++ b/src/test/ui/parser/variadic-ffi-3.stderr @@ -0,0 +1,8 @@ +error: only foreign functions are allowed to be variadic + --> $DIR/variadic-ffi-3.rs:13:18 + | +LL | fn foo(x: isize, ...) { + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/variadic-ffi-4.rs b/src/test/ui/parser/variadic-ffi-4.rs new file mode 100644 index 00000000000..ef9d4558f68 --- /dev/null +++ b/src/test/ui/parser/variadic-ffi-4.rs @@ -0,0 +1,17 @@ +// 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 <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 + +extern "C" fn foo(x: isize, ...) { + //~^ ERROR: only foreign functions are allowed to be variadic +} + +fn main() {} diff --git a/src/test/ui/parser/variadic-ffi-4.stderr b/src/test/ui/parser/variadic-ffi-4.stderr new file mode 100644 index 00000000000..228c0d6ef14 --- /dev/null +++ b/src/test/ui/parser/variadic-ffi-4.stderr @@ -0,0 +1,8 @@ +error: only foreign functions are allowed to be variadic + --> $DIR/variadic-ffi-4.rs:13:29 + | +LL | extern "C" fn foo(x: isize, ...) { + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/virtual-structs.rs b/src/test/ui/parser/virtual-structs.rs new file mode 100644 index 00000000000..b7426140d8a --- /dev/null +++ b/src/test/ui/parser/virtual-structs.rs @@ -0,0 +1,22 @@ +// Copyright 2014 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 + +// Test diagnostics for the removed struct inheritance feature. + +virtual struct SuperStruct { +//~^ ERROR expected item, found reserved keyword `virtual` + f1: isize, +} + +struct Struct : SuperStruct; + +pub fn main() {} diff --git a/src/test/ui/parser/virtual-structs.stderr b/src/test/ui/parser/virtual-structs.stderr new file mode 100644 index 00000000000..659c7701c00 --- /dev/null +++ b/src/test/ui/parser/virtual-structs.stderr @@ -0,0 +1,8 @@ +error: expected item, found reserved keyword `virtual` + --> $DIR/virtual-structs.rs:15:1 + | +LL | virtual struct SuperStruct { + | ^^^^^^^ expected item + +error: aborting due to previous error + diff --git a/src/test/ui/parser/where-clauses-no-bounds-or-predicates.rs b/src/test/ui/parser/where-clauses-no-bounds-or-predicates.rs new file mode 100644 index 00000000000..cf67b518fff --- /dev/null +++ b/src/test/ui/parser/where-clauses-no-bounds-or-predicates.rs @@ -0,0 +1,27 @@ +// Copyright 2016 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 -Z continue-parse-after-error + +// Empty predicate list is OK +fn equal1<T>(_: &T, _: &T) -> bool where { + true +} + +// Empty bound list is OK +fn equal2<T>(_: &T, _: &T) -> bool where T: { + true +} + +fn foo<'a>() where 'a {} +//~^ ERROR expected `:`, found `{` + +fn main() { +} diff --git a/src/test/ui/parser/where-clauses-no-bounds-or-predicates.stderr b/src/test/ui/parser/where-clauses-no-bounds-or-predicates.stderr new file mode 100644 index 00000000000..1dda2d3e7fd --- /dev/null +++ b/src/test/ui/parser/where-clauses-no-bounds-or-predicates.stderr @@ -0,0 +1,8 @@ +error: expected `:`, found `{` + --> $DIR/where-clauses-no-bounds-or-predicates.rs:23:23 + | +LL | fn foo<'a>() where 'a {} + | ^ expected `:` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/where_with_bound.rs b/src/test/ui/parser/where_with_bound.rs new file mode 100644 index 00000000000..2948619ccd0 --- /dev/null +++ b/src/test/ui/parser/where_with_bound.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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<T>() where <T>::Item: ToString, T: Iterator { } +//~^ ERROR generic parameters on `where` clauses are reserved for future use + +fn main() {} diff --git a/src/test/ui/parser/where_with_bound.stderr b/src/test/ui/parser/where_with_bound.stderr new file mode 100644 index 00000000000..7cf16fbcef4 --- /dev/null +++ b/src/test/ui/parser/where_with_bound.stderr @@ -0,0 +1,8 @@ +error: generic parameters on `where` clauses are reserved for future use + --> $DIR/where_with_bound.rs:13:19 + | +LL | fn foo<T>() where <T>::Item: ToString, T: Iterator { } + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/wrong-escape-of-curly-braces.rs b/src/test/ui/parser/wrong-escape-of-curly-braces.rs new file mode 100644 index 00000000000..e501f5ef1fd --- /dev/null +++ b/src/test/ui/parser/wrong-escape-of-curly-braces.rs @@ -0,0 +1,20 @@ +// Copyright 2015 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 f() { + let ok = "{{everything fine}}"; + let bad = "\{it is wrong\}"; + //~^ ERROR unknown character escape: { + //~^^ HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` + //~^^^ ERROR unknown character escape: } + //~^^^^ HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` +} diff --git a/src/test/ui/parser/wrong-escape-of-curly-braces.stderr b/src/test/ui/parser/wrong-escape-of-curly-braces.stderr new file mode 100644 index 00000000000..cbb5c4ff3ec --- /dev/null +++ b/src/test/ui/parser/wrong-escape-of-curly-braces.stderr @@ -0,0 +1,26 @@ +error: unknown character escape: { + --> $DIR/wrong-escape-of-curly-braces.rs:15:17 + | +LL | let bad = "/{it is wrong/}"; + | ^ + | +help: if used in a formatting string, curly braces are escaped with `{{` and `}}` + --> $DIR/wrong-escape-of-curly-braces.rs:15:17 + | +LL | let bad = "/{it is wrong/}"; + | ^ + +error: unknown character escape: } + --> $DIR/wrong-escape-of-curly-braces.rs:15:30 + | +LL | let bad = "/{it is wrong/}"; + | ^ + | +help: if used in a formatting string, curly braces are escaped with `{{` and `}}` + --> $DIR/wrong-escape-of-curly-braces.rs:15:30 + | +LL | let bad = "/{it is wrong/}"; + | ^ + +error: aborting due to 2 previous errors + |
