diff options
| author | Florian Hahn <flo@fhahn.com> | 2015-02-06 16:51:47 +0100 |
|---|---|---|
| committer | Florian Hahn <flo@fhahn.com> | 2015-02-06 22:23:16 +0100 |
| commit | 01db9a46af72383811f39091be70e9721aaa159a (patch) | |
| tree | 7ec89e0b80122be6fec09d6f5eaf24d7f3142fcd /src/test/parse-fail | |
| parent | f3573aa834627e52583a9895a8bac6206c56eeef (diff) | |
| download | rust-01db9a46af72383811f39091be70e9721aaa159a.tar.gz rust-01db9a46af72383811f39091be70e9721aaa159a.zip | |
Move compile-fail tests that are rejected by the parser to parse-fail
Diffstat (limited to 'src/test/parse-fail')
130 files changed, 2172 insertions, 0 deletions
diff --git a/src/test/parse-fail/array-old-syntax-1.rs b/src/test/parse-fail/array-old-syntax-1.rs new file mode 100644 index 00000000000..71c57fefc2e --- /dev/null +++ b/src/test/parse-fail/array-old-syntax-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. + +// Test that the old fixed length array syntax is a parsing error. + +fn main() { + let _x: [isize, ..3] = [0, 1, 2]; //~ ERROR +} diff --git a/src/test/parse-fail/associated-types-project-from-hrtb-explicit.rs b/src/test/parse-fail/associated-types-project-from-hrtb-explicit.rs new file mode 100644 index 00000000000..917c03fbf4b --- /dev/null +++ b/src/test/parse-fail/associated-types-project-from-hrtb-explicit.rs @@ -0,0 +1,26 @@ +// 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 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/parse-fail/attr-bad-meta.rs b/src/test/parse-fail/attr-bad-meta.rs new file mode 100644 index 00000000000..dbf2929afe4 --- /dev/null +++ b/src/test/parse-fail/attr-bad-meta.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. + +// error-pattern:expected `]` + +// asterisk is bogus +#[attr*] +mod m {} diff --git a/src/test/parse-fail/bad-match.rs b/src/test/parse-fail/bad-match.rs new file mode 100644 index 00000000000..33043ff5524 --- /dev/null +++ b/src/test/parse-fail/bad-match.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. + +// error-pattern: expected + +fn main() { + let isize x = 5; + match x; +} + +fn main() { +} diff --git a/src/test/parse-fail/bad-name.rs b/src/test/parse-fail/bad-name.rs new file mode 100644 index 00000000000..b208c6f4244 --- /dev/null +++ b/src/test/parse-fail/bad-name.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. + +// error-pattern: expected + +fn main() { + let x.y::<isize>.z foo; +} diff --git a/src/test/parse-fail/better-expected.rs b/src/test/parse-fail/better-expected.rs new file mode 100644 index 00000000000..e07f4b8e549 --- /dev/null +++ b/src/test/parse-fail/better-expected.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. + +fn main() { + let x: [isize 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, `<`, or `]`, found `3` +} diff --git a/src/test/parse-fail/bind-struct-early-modifiers.rs b/src/test/parse-fail/bind-struct-early-modifiers.rs new file mode 100644 index 00000000000..c358a21d125 --- /dev/null +++ b/src/test/parse-fail/bind-struct-early-modifiers.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. + +fn main() { + struct Foo { x: isize } + match (Foo { x: 10 }) { + Foo { ref x: ref x } => {}, //~ ERROR expected `,`, found `:` + _ => {} + } +} diff --git a/src/test/parse-fail/byte-literals.rs b/src/test/parse-fail/byte-literals.rs new file mode 100644 index 00000000000..436078fa762 --- /dev/null +++ b/src/test/parse-fail/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. + + +// ignore-tidy-tab + +static FOO: u8 = b'\f'; //~ ERROR unknown byte escape + +pub fn main() { + b'\f'; //~ ERROR unknown byte escape + b'\x0Z'; //~ ERROR illegal 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/parse-fail/byte-string-literals.rs b/src/test/parse-fail/byte-string-literals.rs new file mode 100644 index 00000000000..ec67cdd77e1 --- /dev/null +++ b/src/test/parse-fail/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. + + +// 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 illegal 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/parse-fail/circular_modules_hello.rs b/src/test/parse-fail/circular_modules_hello.rs new file mode 100644 index 00000000000..3bf851643f2 --- /dev/null +++ b/src/test/parse-fail/circular_modules_hello.rs @@ -0,0 +1,17 @@ +// 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. + +// ignore-test: this is an auxiliary file for circular-modules-main.rs + +mod circular_modules_main; + +pub fn say_hello() { + println!("{}", circular_modules_main::hi_str()); +} diff --git a/src/test/parse-fail/circular_modules_main.rs b/src/test/parse-fail/circular_modules_main.rs new file mode 100644 index 00000000000..ac5ec1236ff --- /dev/null +++ b/src/test/parse-fail/circular_modules_main.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. + +#[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/parse-fail/class-implements-bad-trait.rs b/src/test/parse-fail/class-implements-bad-trait.rs new file mode 100644 index 00000000000..d709ffdc3fc --- /dev/null +++ b/src/test/parse-fail/class-implements-bad-trait.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. + +// error-pattern:nonexistent +class cat : nonexistent { + let meows: usize; + new(in_x : usize) { self.meows = in_x; } +} + +fn main() { + let nyan = cat(0us); +} diff --git a/src/test/parse-fail/column-offset-1-based.rs b/src/test/parse-fail/column-offset-1-based.rs new file mode 100644 index 00000000000..621b480fe77 --- /dev/null +++ b/src/test/parse-fail/column-offset-1-based.rs @@ -0,0 +1,11 @@ +// 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. + +# //~ ERROR 11:1: 11:2 error: expected one of `!` or `[`, found `<eof>` diff --git a/src/test/parse-fail/duplicate-visibility.rs b/src/test/parse-fail/duplicate-visibility.rs new file mode 100644 index 00000000000..b213730ef75 --- /dev/null +++ b/src/test/parse-fail/duplicate-visibility.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. + +// error-pattern:unmatched visibility `pub` +extern { + pub pub fn foo(); +} diff --git a/src/test/parse-fail/empty-impl-semicolon.rs b/src/test/parse-fail/empty-impl-semicolon.rs new file mode 100644 index 00000000000..70c7d42feb5 --- /dev/null +++ b/src/test/parse-fail/empty-impl-semicolon.rs @@ -0,0 +1,11 @@ +// 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. + +impl Foo; //~ ERROR expected one of `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;` diff --git a/src/test/parse-fail/extern-expected-fn-or-brace.rs b/src/test/parse-fail/extern-expected-fn-or-brace.rs new file mode 100644 index 00000000000..7d1110cf6df --- /dev/null +++ b/src/test/parse-fail/extern-expected-fn-or-brace.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. + +// Verifies that the expected token errors for `extern crate` are +// raised + +extern "C" mod foo; //~ERROR expected `{` or `fn`, found `mod` diff --git a/src/test/parse-fail/extern-foreign-crate.rs b/src/test/parse-fail/extern-foreign-crate.rs new file mode 100644 index 00000000000..24b978b0a21 --- /dev/null +++ b/src/test/parse-fail/extern-foreign-crate.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. + +// Verifies that the expected token errors for `extern crate` are +// raised + +extern crate foo {} //~ERROR expected `;`, found `{` diff --git a/src/test/parse-fail/extern-no-fn.rs b/src/test/parse-fail/extern-no-fn.rs new file mode 100644 index 00000000000..69e2f3ae60b --- /dev/null +++ b/src/test/parse-fail/extern-no-fn.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. + +extern { + f(); //~ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `f` +} + +fn main() { +} diff --git a/src/test/parse-fail/import-from-path.rs b/src/test/parse-fail/import-from-path.rs new file mode 100644 index 00000000000..ce91de7e9d9 --- /dev/null +++ b/src/test/parse-fail/import-from-path.rs @@ -0,0 +1,12 @@ +// 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. + +// error-pattern:expected +use foo::{bar}::baz diff --git a/src/test/parse-fail/import-from-rename.rs b/src/test/parse-fail/import-from-rename.rs new file mode 100644 index 00000000000..ebd897a0611 --- /dev/null +++ b/src/test/parse-fail/import-from-rename.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. + +// error-pattern:expected + +use foo::{bar} as baz; + +mod foo { + pub fn bar() {} +} + +fn main() { +} diff --git a/src/test/parse-fail/import-glob-path.rs b/src/test/parse-fail/import-glob-path.rs new file mode 100644 index 00000000000..b6bc53fad94 --- /dev/null +++ b/src/test/parse-fail/import-glob-path.rs @@ -0,0 +1,12 @@ +// 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. + +// error-pattern:expected +use foo::*::bar diff --git a/src/test/parse-fail/import-glob-rename.rs b/src/test/parse-fail/import-glob-rename.rs new file mode 100644 index 00000000000..fb400b6c2bb --- /dev/null +++ b/src/test/parse-fail/import-glob-rename.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. + +// error-pattern:expected + +use foo::* as baz; + +mod foo { + pub fn bar() {} +} + +fn main() { +} diff --git a/src/test/parse-fail/issue-10392-2.rs b/src/test/parse-fail/issue-10392-2.rs new file mode 100644 index 00000000000..b077081c5b0 --- /dev/null +++ b/src/test/parse-fail/issue-10392-2.rs @@ -0,0 +1,18 @@ +// 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. + +struct A { foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { .., } = a(); //~ ERROR: expected `}` +} + diff --git a/src/test/parse-fail/issue-10392.rs b/src/test/parse-fail/issue-10392.rs new file mode 100644 index 00000000000..3f8d26bfec0 --- /dev/null +++ b/src/test/parse-fail/issue-10392.rs @@ -0,0 +1,17 @@ +// 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. + +struct A { foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { , } = a(); //~ ERROR: expected ident +} diff --git a/src/test/parse-fail/issue-10636-1.rs b/src/test/parse-fail/issue-10636-1.rs new file mode 100644 index 00000000000..bb020d55bdb --- /dev/null +++ b/src/test/parse-fail/issue-10636-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. + +struct Obj { //~ NOTE: unclosed delimiter + member: usize +) //~ ERROR: incorrect close delimiter diff --git a/src/test/parse-fail/issue-10636-2.rs b/src/test/parse-fail/issue-10636-2.rs new file mode 100644 index 00000000000..a92ef248924 --- /dev/null +++ b/src/test/parse-fail/issue-10636-2.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. + +pub fn trace_option(option: Option<isize>) { + option.map(|some| 42; //~ NOTE: unclosed delimiter +} //~ ERROR: incorrect close delimiter diff --git a/src/test/parse-fail/issue-14303-enum.rs b/src/test/parse-fail/issue-14303-enum.rs new file mode 100644 index 00000000000..a26b7fdc425 --- /dev/null +++ b/src/test/parse-fail/issue-14303-enum.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. + +enum X<'a, T, 'b> { +//~^ ERROR lifetime parameters must be declared prior to type parameters + A(&'a T) +} diff --git a/src/test/parse-fail/issue-14303-fn-def.rs b/src/test/parse-fail/issue-14303-fn-def.rs new file mode 100644 index 00000000000..aaf95410b8e --- /dev/null +++ b/src/test/parse-fail/issue-14303-fn-def.rs @@ -0,0 +1,12 @@ +// 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. + +fn foo<'a, T, 'b>(x: &'a T) {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff --git a/src/test/parse-fail/issue-14303-fncall.rs b/src/test/parse-fail/issue-14303-fncall.rs new file mode 100644 index 00000000000..a7adaacc0a5 --- /dev/null +++ b/src/test/parse-fail/issue-14303-fncall.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. + +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/parse-fail/issue-14303-impl.rs b/src/test/parse-fail/issue-14303-impl.rs new file mode 100644 index 00000000000..c4a00581274 --- /dev/null +++ b/src/test/parse-fail/issue-14303-impl.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. + +struct X { x: isize } + +impl<'a, T, 'b> X {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff --git a/src/test/parse-fail/issue-14303-path.rs b/src/test/parse-fail/issue-14303-path.rs new file mode 100644 index 00000000000..30cc41c3588 --- /dev/null +++ b/src/test/parse-fail/issue-14303-path.rs @@ -0,0 +1,12 @@ +// 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. + +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/parse-fail/issue-14303-struct.rs b/src/test/parse-fail/issue-14303-struct.rs new file mode 100644 index 00000000000..6edd808d847 --- /dev/null +++ b/src/test/parse-fail/issue-14303-struct.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. + +struct X<'a, T, 'b> { +//~^ ERROR lifetime parameters must be declared prior to type parameters + x: &'a T +} diff --git a/src/test/parse-fail/issue-14303-trait.rs b/src/test/parse-fail/issue-14303-trait.rs new file mode 100644 index 00000000000..753acdd75fe --- /dev/null +++ b/src/test/parse-fail/issue-14303-trait.rs @@ -0,0 +1,12 @@ +// 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. + +trait Foo<'a, T, 'b> {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff --git a/src/test/parse-fail/issue-15914.rs b/src/test/parse-fail/issue-15914.rs new file mode 100644 index 00000000000..45b3abfddfb --- /dev/null +++ b/src/test/parse-fail/issue-15914.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. + +fn main() { + let ref + (); //~ ERROR expected identifier, found `(` +} diff --git a/src/test/parse-fail/issue-1655.rs b/src/test/parse-fail/issue-1655.rs new file mode 100644 index 00000000000..a8704f7545f --- /dev/null +++ b/src/test/parse-fail/issue-1655.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. + +// error-pattern:expected one of `!` or `[`, 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/parse-fail/issue-17904.rs b/src/test/parse-fail/issue-17904.rs new file mode 100644 index 00000000000..96ba712bbae --- /dev/null +++ b/src/test/parse-fail/issue-17904.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. + +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 unexpected token in `where` clause +struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found `where` + +fn main() {} diff --git a/src/test/parse-fail/issue-1802-1.rs b/src/test/parse-fail/issue-1802-1.rs new file mode 100644 index 00000000000..8ce99f517c4 --- /dev/null +++ b/src/test/parse-fail/issue-1802-1.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. + +// error-pattern:no valid digits found for number +fn main() { + log(error, 0b42); +} diff --git a/src/test/parse-fail/issue-19096.rs b/src/test/parse-fail/issue-19096.rs new file mode 100644 index 00000000000..90d2acbe581 --- /dev/null +++ b/src/test/parse-fail/issue-19096.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. + +fn main() { + let t = (42, 42); + t.0::<isize>; //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `::` +} diff --git a/src/test/parse-fail/issue-19398.rs b/src/test/parse-fail/issue-19398.rs new file mode 100644 index 00000000000..3a6d15e0086 --- /dev/null +++ b/src/test/parse-fail/issue-19398.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. + +trait T { + extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found `unsafe` +} + +fn main() {} diff --git a/src/test/parse-fail/issue-20711-2.rs b/src/test/parse-fail/issue-20711-2.rs new file mode 100644 index 00000000000..a6c4570c60f --- /dev/null +++ b/src/test/parse-fail/issue-20711-2.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. + +struct Foo; + +impl Foo { + fn foo() {} + + #[stable(feature = "rust1", since = "1.0.0")] +} //~ ERROR expected one of `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` + +fn main() {} + diff --git a/src/test/parse-fail/issue-20711.rs b/src/test/parse-fail/issue-20711.rs new file mode 100644 index 00000000000..3b329d78237 --- /dev/null +++ b/src/test/parse-fail/issue-20711.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. + +struct Foo; + +impl Foo { + #[stable(feature = "rust1", since = "1.0.0")] +} //~ ERROR expected one of `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` + +fn main() {} diff --git a/src/test/parse-fail/issue-21153.rs b/src/test/parse-fail/issue-21153.rs new file mode 100644 index 00000000000..e2b6deb0ad9 --- /dev/null +++ b/src/test/parse-fail/issue-21153.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. + +trait MyTrait<T>: Iterator { + Item = T; //~ ERROR expected one of `extern`, `fn`, `pub`, `type`, or `unsafe`, found `Item` +} diff --git a/src/test/parse-fail/issue-2354-1.rs b/src/test/parse-fail/issue-2354-1.rs new file mode 100644 index 00000000000..d37837b9714 --- /dev/null +++ b/src/test/parse-fail/issue-2354-1.rs @@ -0,0 +1,12 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static foo: isize = 2; } //~ ERROR incorrect close delimiter: + diff --git a/src/test/parse-fail/issue-2354.rs b/src/test/parse-fail/issue-2354.rs new file mode 100644 index 00000000000..cc219a6acb5 --- /dev/null +++ b/src/test/parse-fail/issue-2354.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. + +fn foo() { //~ HELP did you mean to close this delimiter? + match Some(x) { + Some(y) { panic!(); } + None { panic!(); } +} + +fn bar() { + let mut i = 0; + while (i < 1000) {} +} + +fn main() {} //~ ERROR this file contains an un-closed delimiter diff --git a/src/test/parse-fail/issue-3036.rs b/src/test/parse-fail/issue-3036.rs new file mode 100644 index 00000000000..16834f49165 --- /dev/null +++ b/src/test/parse-fail/issue-3036.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. + +// 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/parse-fail/issue-5806.rs b/src/test/parse-fail/issue-5806.rs new file mode 100644 index 00000000000..597366a1b35 --- /dev/null +++ b/src/test/parse-fail/issue-5806.rs @@ -0,0 +1,24 @@ +// 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. + +// 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. + +#[path = "../compile-fail"] +mod foo; //~ ERROR: a directory + +fn main() {} diff --git a/src/test/parse-fail/issue-6610.rs b/src/test/parse-fail/issue-6610.rs new file mode 100644 index 00000000000..166e91b27ac --- /dev/null +++ b/src/test/parse-fail/issue-6610.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. + +trait Foo { fn a() } //~ ERROR expected `;` or `{`, found `}` + +fn main() {} diff --git a/src/test/parse-fail/keyword-abstract.rs b/src/test/parse-fail/keyword-abstract.rs new file mode 100644 index 00000000000..1f1360eac00 --- /dev/null +++ b/src/test/parse-fail/keyword-abstract.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. + +fn main() { + let abstract = (); //~ ERROR `abstract` is a reserved keyword +} diff --git a/src/test/parse-fail/keyword-do-as-identifier.rs b/src/test/parse-fail/keyword-do-as-identifier.rs new file mode 100644 index 00000000000..90f73f8a9f4 --- /dev/null +++ b/src/test/parse-fail/keyword-do-as-identifier.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. + +fn main() { + let do = "bar"; //~ error: ident +} diff --git a/src/test/parse-fail/keyword-final.rs b/src/test/parse-fail/keyword-final.rs new file mode 100644 index 00000000000..305ef0ef075 --- /dev/null +++ b/src/test/parse-fail/keyword-final.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. + +fn main() { + let final = (); //~ ERROR `final` is a reserved keyword +} diff --git a/src/test/parse-fail/keyword-mut-as-identifier.rs b/src/test/parse-fail/keyword-mut-as-identifier.rs new file mode 100644 index 00000000000..b5d36e57750 --- /dev/null +++ b/src/test/parse-fail/keyword-mut-as-identifier.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. + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py mut' + +fn main() { + let mut = "foo"; //~ error: ident +} diff --git a/src/test/parse-fail/keyword-override.rs b/src/test/parse-fail/keyword-override.rs new file mode 100644 index 00000000000..f70e6b92610 --- /dev/null +++ b/src/test/parse-fail/keyword-override.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. + +fn main() { + let override = (); //~ ERROR `override` is a reserved keyword +} diff --git a/src/test/parse-fail/keyword-priv-as-identifier.rs b/src/test/parse-fail/keyword-priv-as-identifier.rs new file mode 100644 index 00000000000..7cbaeb9d518 --- /dev/null +++ b/src/test/parse-fail/keyword-priv-as-identifier.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. + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py priv' + +fn main() { + let priv = "foo"; //~ error: ident +} diff --git a/src/test/parse-fail/keyword-ref-as-identifier.rs b/src/test/parse-fail/keyword-ref-as-identifier.rs new file mode 100644 index 00000000000..72af521f6f1 --- /dev/null +++ b/src/test/parse-fail/keyword-ref-as-identifier.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. + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py ref' + +fn main() { + let ref = "foo"; //~ error: ident +} diff --git a/src/test/parse-fail/keyword-typeof.rs b/src/test/parse-fail/keyword-typeof.rs new file mode 100644 index 00000000000..c42875382b9 --- /dev/null +++ b/src/test/parse-fail/keyword-typeof.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. + +fn main() { + let typeof = (); //~ ERROR `typeof` is a reserved keyword +} diff --git a/src/test/parse-fail/lex-bad-char-literals.rs b/src/test/parse-fail/lex-bad-char-literals.rs new file mode 100644 index 00000000000..fbe03e355ee --- /dev/null +++ b/src/test/parse-fail/lex-bad-char-literals.rs @@ -0,0 +1,53 @@ +// 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. + +static c: char = + '\u539_' //~ ERROR: illegal character in numeric character escape + //~^ WARNING: \uABCD escapes are deprecated +; + +static c2: char = + '\Uffffffff' //~ ERROR: illegal numeric character escape + //~^ WARNING: \uABCD escapes are deprecated +; + +static c3: char = + '\x1' //~ ERROR: numeric character escape is too short +; + +static c4: char = + '\u23q' //~ ERROR: illegal character in numeric character escape + //~^ WARNING: \uABCD escapes are deprecated +; +//~^^^ ERROR: numeric character escape is too short + +static s: &'static str = + "\x1" //~ ERROR: numeric character escape is too short +; + +static s2: &'static str = + "\u23q" //~ ERROR: illegal character in numeric character escape + //~^ ERROR: numeric character escape is too short + //~^^ WARNING: \uABCD escapes are deprecated +; + +static c: char = + '\●' //~ ERROR: unknown character escape +; + +static s: &'static str = + "\●" //~ ERROR: unknown character escape +; + +// THIS MUST BE LAST, since unterminated character constants kill the lexer + +static c: char = + '● //~ ERROR: unterminated character constant +; diff --git a/src/test/parse-fail/lex-bad-token.rs b/src/test/parse-fail/lex-bad-token.rs new file mode 100644 index 00000000000..d28d9a20c6e --- /dev/null +++ b/src/test/parse-fail/lex-bad-token.rs @@ -0,0 +1,11 @@ +// 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. + +● //~ ERROR: unknown start of token diff --git a/src/test/parse-fail/macro-attribute.rs b/src/test/parse-fail/macro-attribute.rs new file mode 100644 index 00000000000..77ea0c9c4f3 --- /dev/null +++ b/src/test/parse-fail/macro-attribute.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. + +#[doc = $not_there] //~ error: unexpected token: `$` +fn main() { } + diff --git a/src/test/parse-fail/macro-bad-delimiter-ident.rs b/src/test/parse-fail/macro-bad-delimiter-ident.rs new file mode 100644 index 00000000000..75f7b5d4dd8 --- /dev/null +++ b/src/test/parse-fail/macro-bad-delimiter-ident.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. + +fn main() { + foo! bar < //~ ERROR expected `(` or `{`, found `<` +} diff --git a/src/test/parse-fail/macro-keyword.rs b/src/test/parse-fail/macro-keyword.rs new file mode 100644 index 00000000000..9d4ec9c176c --- /dev/null +++ b/src/test/parse-fail/macro-keyword.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. + +fn macro() { //~ ERROR `macro` is a reserved keyword +} + +pub fn main() { +} diff --git a/src/test/parse-fail/macro-mismatched-delim-brace-paren.rs b/src/test/parse-fail/macro-mismatched-delim-brace-paren.rs new file mode 100644 index 00000000000..d03698c1573 --- /dev/null +++ b/src/test/parse-fail/macro-mismatched-delim-brace-paren.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. + +fn main() { + foo! { + bar, "baz", 1, 2.0 + ) //~ ERROR incorrect close delimiter +} diff --git a/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs b/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs new file mode 100644 index 00000000000..d80f93d7ad0 --- /dev/null +++ b/src/test/parse-fail/macro-mismatched-delim-paren-brace.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. + +fn main() { + foo! ( + bar, "baz", 1, 2.0 + } //~ ERROR incorrect close delimiter +} diff --git a/src/test/parse-fail/macros-no-semicolon.rs b/src/test/parse-fail/macros-no-semicolon.rs new file mode 100644 index 00000000000..0e85551e216 --- /dev/null +++ b/src/test/parse-fail/macros-no-semicolon.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. + +fn main() { + assert!(1 == 2) + assert!(3 == 4) //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `assert` + println!("hello"); +} + diff --git a/src/test/parse-fail/match-arrows-block-then-binop.rs b/src/test/parse-fail/match-arrows-block-then-binop.rs new file mode 100644 index 00000000000..b6b2313aa09 --- /dev/null +++ b/src/test/parse-fail/match-arrows-block-then-binop.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. + +fn main() { + + match 0 { + 0 => { + } + 5 //~ ERROR unexpected token: `+` + } +} diff --git a/src/test/parse-fail/match-vec-invalid.rs b/src/test/parse-fail/match-vec-invalid.rs new file mode 100644 index 00000000000..3e073d34f32 --- /dev/null +++ b/src/test/parse-fail/match-vec-invalid.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. + +fn main() { + let a = Vec::new(); + match a { + [1, tail.., tail..] => {}, //~ ERROR: expected one of `!`, `,`, or `@`, found `..` + _ => () + } +} diff --git a/src/test/parse-fail/mod_file_disambig.rs b/src/test/parse-fail/mod_file_disambig.rs new file mode 100644 index 00000000000..48bd00a3ee0 --- /dev/null +++ b/src/test/parse-fail/mod_file_disambig.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. + +mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both + +fn main() { + assert_eq!(mod_file_aux::bar(), 10); +} diff --git a/src/test/parse-fail/mod_file_not_exist.rs b/src/test/parse-fail/mod_file_not_exist.rs new file mode 100644 index 00000000000..bbf2152d5b7 --- /dev/null +++ b/src/test/parse-fail/mod_file_not_exist.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. + +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/parse-fail/mod_file_not_owning.rs b/src/test/parse-fail/mod_file_not_owning.rs new file mode 100644 index 00000000000..adbcedd91f2 --- /dev/null +++ b/src/test/parse-fail/mod_file_not_owning.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. + +// error-pattern: cannot declare a new module at this location + +mod mod_file_not_owning_aux1; + +fn main() {} diff --git a/src/test/parse-fail/mod_file_with_path_attr.rs b/src/test/parse-fail/mod_file_with_path_attr.rs new file mode 100644 index 00000000000..ff330047c4e --- /dev/null +++ b/src/test/parse-fail/mod_file_with_path_attr.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. + +#[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/parse-fail/multiline-comment-line-tracking.rs b/src/test/parse-fail/multiline-comment-line-tracking.rs new file mode 100644 index 00000000000..11abe672745 --- /dev/null +++ b/src/test/parse-fail/multiline-comment-line-tracking.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. + +// error-pattern:18:3 + +/* 1 + * 2 + * 3 + */ +fn main() { + %; // parse error on line 18, but is reported on line 6 instead. +} diff --git a/src/test/parse-fail/multitrait.rs b/src/test/parse-fail/multitrait.rs new file mode 100644 index 00000000000..f182eb8fa5b --- /dev/null +++ b/src/test/parse-fail/multitrait.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. + +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/parse-fail/mut-patterns.rs b/src/test/parse-fail/mut-patterns.rs new file mode 100644 index 00000000000..cde05bc1d52 --- /dev/null +++ b/src/test/parse-fail/mut-patterns.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. + +// 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/parse-fail/new-unicode-escapes-1.rs b/src/test/parse-fail/new-unicode-escapes-1.rs new file mode 100644 index 00000000000..f2422830a21 --- /dev/null +++ b/src/test/parse-fail/new-unicode-escapes-1.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. + +pub fn main() { + let s = "\u{2603"; //~ ERROR unterminated unicode escape (needed a `}`) +} diff --git a/src/test/parse-fail/new-unicode-escapes-2.rs b/src/test/parse-fail/new-unicode-escapes-2.rs new file mode 100644 index 00000000000..5da8674c37e --- /dev/null +++ b/src/test/parse-fail/new-unicode-escapes-2.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. + +pub fn main() { + let s = "\u{260311111111}"; //~ ERROR overlong unicode escape (can have at most 6 hex digits) +} diff --git a/src/test/parse-fail/new-unicode-escapes-3.rs b/src/test/parse-fail/new-unicode-escapes-3.rs new file mode 100644 index 00000000000..7c64d02efd7 --- /dev/null +++ b/src/test/parse-fail/new-unicode-escapes-3.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. + +pub fn main() { + let s = "\u{d805}"; //~ ERROR illegal unicode character escape +} diff --git a/src/test/parse-fail/new-unicode-escapes-4.rs b/src/test/parse-fail/new-unicode-escapes-4.rs new file mode 100644 index 00000000000..ffc2b11e0c1 --- /dev/null +++ b/src/test/parse-fail/new-unicode-escapes-4.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. + +pub fn main() { + let s = "\u{lol}"; //~ ERROR illegal character in unicode escape +} diff --git a/src/test/parse-fail/not-a-pred.rs b/src/test/parse-fail/not-a-pred.rs new file mode 100644 index 00000000000..782c90a6c26 --- /dev/null +++ b/src/test/parse-fail/not-a-pred.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. + +// 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/parse-fail/omitted-arg-in-item-fn.rs b/src/test/parse-fail/omitted-arg-in-item-fn.rs new file mode 100644 index 00000000000..729b45df8b4 --- /dev/null +++ b/src/test/parse-fail/omitted-arg-in-item-fn.rs @@ -0,0 +1,12 @@ +// 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. + +fn foo(x) { //~ ERROR expected one of `!`, `:`, or `@`, found `)` +} diff --git a/src/test/parse-fail/paamayim-nekudotayim.rs b/src/test/parse-fail/paamayim-nekudotayim.rs new file mode 100644 index 00000000000..4d5473faf73 --- /dev/null +++ b/src/test/parse-fail/paamayim-nekudotayim.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. + +// http://phpsadness.com/sad/1 + +fn main() { + ::; //~ ERROR expected ident, found `;` +} diff --git a/src/test/parse-fail/parenthesized-box-expr-message.rs b/src/test/parse-fail/parenthesized-box-expr-message.rs new file mode 100644 index 00000000000..05bbaec37af --- /dev/null +++ b/src/test/parse-fail/parenthesized-box-expr-message.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. + +fn main() { + box(1 + 1) //~ HELP perhaps you meant `box() (foo)` instead? + ; //~ ERROR expected expression, found `;` +} diff --git a/src/test/parse-fail/pat-range-bad-dots.rs b/src/test/parse-fail/pat-range-bad-dots.rs new file mode 100644 index 00000000000..c52fb8c9b67 --- /dev/null +++ b/src/test/parse-fail/pat-range-bad-dots.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. + +pub fn main() { + match 22 { + 0 .. 3 => {} //~ ERROR expected one of `...`, `=>`, `if`, or `|`, found `..` + _ => {} + } +} diff --git a/src/test/parse-fail/pat-ref-enum.rs b/src/test/parse-fail/pat-ref-enum.rs new file mode 100644 index 00000000000..062d3308c3d --- /dev/null +++ b/src/test/parse-fail/pat-ref-enum.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. + +fn matcher(x: Option<isize>) { + match x { + ref Some(i) => {} //~ ERROR expected identifier, found enum pattern + None => {} + } +} + +fn main() {} diff --git a/src/test/parse-fail/range-3.rs b/src/test/parse-fail/range-3.rs new file mode 100644 index 00000000000..78c575d33ba --- /dev/null +++ b/src/test/parse-fail/range-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. + +// 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/parse-fail/range-4.rs b/src/test/parse-fail/range-4.rs new file mode 100644 index 00000000000..a3e27fbbe9a --- /dev/null +++ b/src/test/parse-fail/range-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. + +// 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/parse-fail/raw-byte-string-eof.rs b/src/test/parse-fail/raw-byte-string-eof.rs new file mode 100644 index 00000000000..83ea9db39b7 --- /dev/null +++ b/src/test/parse-fail/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. + + +pub fn main() { + br##"a"#; //~ unterminated raw string +} + + diff --git a/src/test/parse-fail/raw-byte-string-literals.rs b/src/test/parse-fail/raw-byte-string-literals.rs new file mode 100644 index 00000000000..7a3d1b2318a --- /dev/null +++ b/src/test/parse-fail/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. + + +pub fn main() { + br"é"; //~ raw byte string must be ASCII + br##~"a"~##; //~ only `#` is allowed in raw string delimitation +} + + diff --git a/src/test/parse-fail/raw-str-delim.rs b/src/test/parse-fail/raw-str-delim.rs new file mode 100644 index 00000000000..83afb33b641 --- /dev/null +++ b/src/test/parse-fail/raw-str-delim.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. + +static s: &'static str = + r#x"#"x# //~ ERROR only `#` is allowed in raw string delimitation; found illegal character +; diff --git a/src/test/parse-fail/raw-str-unbalanced.rs b/src/test/parse-fail/raw-str-unbalanced.rs new file mode 100644 index 00000000000..3403b28fdc9 --- /dev/null +++ b/src/test/parse-fail/raw-str-unbalanced.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. + +static s: &'static str = + r#" + "## //~ ERROR expected one of `.`, `;`, or an operator, found `#` +; diff --git a/src/test/parse-fail/raw-str-unterminated.rs b/src/test/parse-fail/raw-str-unterminated.rs new file mode 100644 index 00000000000..4151cf32346 --- /dev/null +++ b/src/test/parse-fail/raw-str-unterminated.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. + +static s: &'static str = + r#" string literal goes on + and on + //~^^ ERROR unterminated raw string diff --git a/src/test/parse-fail/regions-infer-paramd-method.rs b/src/test/parse-fail/regions-infer-paramd-method.rs new file mode 100644 index 00000000000..ef331bb0fd7 --- /dev/null +++ b/src/test/parse-fail/regions-infer-paramd-method.rs @@ -0,0 +1,67 @@ +// 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. + +// ignore-test +// ignored due to problems with by value self. + +// 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. + +// Here: foo is parameterized because it contains a method that +// refers to self. + +trait foo<'a> { + fn self_int(self) -> &'a isize; + + fn any_int(self) -> &isize; +} + +struct with_foo<'a> { + f: @foo<'a> +} + +trait set_foo_foo { + fn set_foo(&mut self, f: @foo); +} + +impl<'a> set_foo_foo for with_foo<'a> { + fn set_foo(&mut self, f: @foo) { + self.f = f; //~ ERROR mismatched types: expected `@foo/&self`, found `@foo/&` + } +} + +// Bar is not region parameterized. + +trait bar { + fn any_int(&self) -> &isize; +} + +struct with_bar { + f: bar +} + +trait set_foo_bar { + fn set_foo(&mut self, f: bar); +} + +impl set_foo_bar for with_bar { + fn set_foo(&mut self, f: bar) { + self.f = f; + } +} + +fn main() {} diff --git a/src/test/parse-fail/regions-out-of-scope-slice.rs b/src/test/parse-fail/regions-out-of-scope-slice.rs new file mode 100644 index 00000000000..c67c14d35d8 --- /dev/null +++ b/src/test/parse-fail/regions-out-of-scope-slice.rs @@ -0,0 +1,23 @@ +// 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. + +// ignore-test blk region isn't supported in the front-end + +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; //~ ERROR foo + + if cond { + x = &'blk [1,2,3]; + } +} + +fn main() {} diff --git a/src/test/parse-fail/regions-trait-2.rs b/src/test/parse-fail/regions-trait-2.rs new file mode 100644 index 00000000000..8b36e87db3e --- /dev/null +++ b/src/test/parse-fail/regions-trait-2.rs @@ -0,0 +1,37 @@ +// 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. + +// ignore-test #5723 + +// Test that you cannot escape a reference +// into a trait. + +struct ctxt { v: usize } + +trait get_ctxt { + fn get_ctxt(&self) -> &'a ctxt; +} + +struct has_ctxt<'a> { c: &'a ctxt } + +impl<'a> get_ctxt for has_ctxt<'a> { + fn get_ctxt(&self) -> &'a ctxt { self.c } +} + +fn make_gc() -> @get_ctxt { + let ctxt = ctxt { v: 22us }; + let hc = has_ctxt { c: &ctxt }; + return @hc as @get_ctxt; + //~^ ERROR source contains reference +} + +fn main() { + make_gc().get_ctxt().v; +} diff --git a/src/test/parse-fail/regions-trait-3.rs b/src/test/parse-fail/regions-trait-3.rs new file mode 100644 index 00000000000..8943abb49ae --- /dev/null +++ b/src/test/parse-fail/regions-trait-3.rs @@ -0,0 +1,45 @@ +// 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. + +// ignore-test +// ignore'd due to problems with by-value self. + +// 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. + +trait get_ctxt<'a> { + fn get_ctxt(self) -> &'a usize; +} + +fn make_gc1(gc: @get_ctxt<'a>) -> @get_ctxt<'b> { + return gc; //~ ERROR mismatched types: expected `@get_ctxt/&b`, found `@get_ctxt/&a` +} + +struct Foo { + r: &'a usize +} + +impl get_ctxt for Foo<'a> { + fn get_ctxt(&self) -> &'a usize { self.r } +} + +fn make_gc2<'a,'b>(foo: Foo<'a>) -> @get_ctxt<'b> { + return @foo as @get_ctxt; //~ ERROR cannot infer +} + +fn main() { +} diff --git a/src/test/parse-fail/removed-syntax-closure-lifetime.rs b/src/test/parse-fail/removed-syntax-closure-lifetime.rs new file mode 100644 index 00000000000..0cea87dba19 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-closure-lifetime.rs @@ -0,0 +1,11 @@ +// 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. + +type closure = Box<lt/fn()>; //~ ERROR expected one of `(`, `+`, `,`, `::`, `<`, or `>`, found `/` diff --git a/src/test/parse-fail/removed-syntax-enum-newtype.rs b/src/test/parse-fail/removed-syntax-enum-newtype.rs new file mode 100644 index 00000000000..b067cee03d2 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-enum-newtype.rs @@ -0,0 +1,11 @@ +// 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. + +enum e = isize; //~ ERROR expected one of `<`, `where`, or `{`, found `=` diff --git a/src/test/parse-fail/removed-syntax-extern-const.rs b/src/test/parse-fail/removed-syntax-extern-const.rs new file mode 100644 index 00000000000..a0e1d04a3dc --- /dev/null +++ b/src/test/parse-fail/removed-syntax-extern-const.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. + +extern { + const i: isize; + //~^ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `const` +} diff --git a/src/test/parse-fail/removed-syntax-field-let.rs b/src/test/parse-fail/removed-syntax-field-let.rs new file mode 100644 index 00000000000..c8711598163 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-field-let.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. + +struct s { + let foo: (), + //~^ ERROR expected identifier, found keyword `let` + //~^^ ERROR expected `:`, found `foo` +} diff --git a/src/test/parse-fail/removed-syntax-field-semicolon.rs b/src/test/parse-fail/removed-syntax-field-semicolon.rs new file mode 100644 index 00000000000..9bb3c649cdf --- /dev/null +++ b/src/test/parse-fail/removed-syntax-field-semicolon.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. + +struct s { + bar: (); + //~^ ERROR expected `,`, or `}`, found `;` +} diff --git a/src/test/parse-fail/removed-syntax-fixed-vec.rs b/src/test/parse-fail/removed-syntax-fixed-vec.rs new file mode 100644 index 00000000000..0e8e20b3891 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-fixed-vec.rs @@ -0,0 +1,11 @@ +// 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. + +type v = [isize * 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, `<`, or `]`, found `*` diff --git a/src/test/parse-fail/removed-syntax-fn-pure.rs b/src/test/parse-fail/removed-syntax-fn-pure.rs new file mode 100644 index 00000000000..d569ea25c46 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-fn-pure.rs @@ -0,0 +1,11 @@ +// 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. + +pure fn f() {} //~ ERROR expected item, found `pure` diff --git a/src/test/parse-fail/removed-syntax-fn-sigil.rs b/src/test/parse-fail/removed-syntax-fn-sigil.rs new file mode 100644 index 00000000000..83ebe7cc7a3 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-fn-sigil.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. + +fn f() { + let x: fn~() = || (); //~ ERROR expected `(`, found `~` +} diff --git a/src/test/parse-fail/removed-syntax-larrow-init.rs b/src/test/parse-fail/removed-syntax-larrow-init.rs new file mode 100644 index 00000000000..1474cc9dd39 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-larrow-init.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. + +fn removed_moves() { + let mut x = 0; + let y <- x; + //~^ ERROR expected one of `!`, `:`, `;`, `=`, or `@`, found `<-` +} diff --git a/src/test/parse-fail/removed-syntax-larrow-move.rs b/src/test/parse-fail/removed-syntax-larrow-move.rs new file mode 100644 index 00000000000..552c9f2efa2 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-larrow-move.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. + +fn removed_moves() { + let mut x = 0; + let y = 0; + y <- x; + //~^ ERROR expected one of `!`, `.`, `::`, `;`, `{`, `}`, or an operator, found `<-` +} diff --git a/src/test/parse-fail/removed-syntax-mode.rs b/src/test/parse-fail/removed-syntax-mode.rs new file mode 100644 index 00000000000..b02de5ce08e --- /dev/null +++ b/src/test/parse-fail/removed-syntax-mode.rs @@ -0,0 +1,11 @@ +// 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. + +fn f(+x: isize) {} //~ ERROR unexpected token: `+` diff --git a/src/test/parse-fail/removed-syntax-mut-vec-expr.rs b/src/test/parse-fail/removed-syntax-mut-vec-expr.rs new file mode 100644 index 00000000000..30302bbd16e --- /dev/null +++ b/src/test/parse-fail/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. + +fn f() { + let v = [mut 1, 2, 3, 4]; + //~^ ERROR expected identifier, found keyword `mut` + //~^^ ERROR expected one of `!`, `,`, `.`, `::`, `;`, `]`, `{`, or an operator, found `1` +} diff --git a/src/test/parse-fail/removed-syntax-mut-vec-ty.rs b/src/test/parse-fail/removed-syntax-mut-vec-ty.rs new file mode 100644 index 00000000000..9a7570a92f0 --- /dev/null +++ b/src/test/parse-fail/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. + +type v = [mut isize]; + //~^ ERROR expected identifier, found keyword `mut` + //~^^ ERROR expected one of `(`, `+`, `::`, `;`, `<`, or `]`, found `isize` diff --git a/src/test/parse-fail/removed-syntax-ptr-lifetime.rs b/src/test/parse-fail/removed-syntax-ptr-lifetime.rs new file mode 100644 index 00000000000..44c65d98c0b --- /dev/null +++ b/src/test/parse-fail/removed-syntax-ptr-lifetime.rs @@ -0,0 +1,11 @@ +// 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. + +type bptr = &lifetime/isize; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `<`, found `/` diff --git a/src/test/parse-fail/removed-syntax-record.rs b/src/test/parse-fail/removed-syntax-record.rs new file mode 100644 index 00000000000..ae5a68575f7 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-record.rs @@ -0,0 +1,11 @@ +// 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. + +type t = { f: () }; //~ ERROR expected type, found `{` diff --git a/src/test/parse-fail/removed-syntax-static-fn.rs b/src/test/parse-fail/removed-syntax-static-fn.rs new file mode 100644 index 00000000000..caf939e7b8a --- /dev/null +++ b/src/test/parse-fail/removed-syntax-static-fn.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. + +struct S; + +impl S { + static fn f() {} + //~^ ERROR expected one of `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static` +} diff --git a/src/test/parse-fail/removed-syntax-uniq-mut-expr.rs b/src/test/parse-fail/removed-syntax-uniq-mut-expr.rs new file mode 100644 index 00000000000..c5559c4ea96 --- /dev/null +++ b/src/test/parse-fail/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. + +fn f() { + let a_box = box mut 42; + //~^ ERROR expected identifier, found keyword `mut` + //~^^ ERROR expected one of `!`, `.`, `::`, `;`, `{`, or an operator, found `42` +} diff --git a/src/test/parse-fail/removed-syntax-uniq-mut-ty.rs b/src/test/parse-fail/removed-syntax-uniq-mut-ty.rs new file mode 100644 index 00000000000..d1c2fc69f52 --- /dev/null +++ b/src/test/parse-fail/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. + +type mut_box = Box<mut isize>; + //~^ ERROR expected identifier, found keyword `mut` + //~^^ ERROR expected one of `(`, `+`, `,`, `::`, `<`, or `>`, found `isize` diff --git a/src/test/parse-fail/removed-syntax-with-1.rs b/src/test/parse-fail/removed-syntax-with-1.rs new file mode 100644 index 00000000000..c7f31045cb6 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-with-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. + +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/parse-fail/removed-syntax-with-2.rs b/src/test/parse-fail/removed-syntax-with-2.rs new file mode 100644 index 00000000000..83c6897dee3 --- /dev/null +++ b/src/test/parse-fail/removed-syntax-with-2.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. + +fn removed_with() { + struct S { + foo: (), + bar: (), + } + + let a = S { foo: (), bar: () }; + let b = S { foo: (), with a }; + //~^ ERROR expected `:`, found `a` +} diff --git a/src/test/parse-fail/reserved-be.rs b/src/test/parse-fail/reserved-be.rs new file mode 100644 index 00000000000..386d53cc16e --- /dev/null +++ b/src/test/parse-fail/reserved-be.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. + +fn main() { + let be = 0; + //~^ ERROR `be` is a reserved keyword +} diff --git a/src/test/parse-fail/struct-literal-in-for.rs b/src/test/parse-fail/struct-literal-in-for.rs new file mode 100644 index 00000000000..4bb5d5e6aa1 --- /dev/null +++ b/src/test/parse-fail/struct-literal-in-for.rs @@ -0,0 +1,28 @@ +// 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. + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + for x in Foo { + x: 3 //~ ERROR expected one of `!`, `.`, `::`, `;`, `{`, `}`, or an operator, found `:` + }.hi() { + println!("yo"); + } +} + diff --git a/src/test/parse-fail/struct-literal-in-if.rs b/src/test/parse-fail/struct-literal-in-if.rs new file mode 100644 index 00000000000..b2bc8a4901f --- /dev/null +++ b/src/test/parse-fail/struct-literal-in-if.rs @@ -0,0 +1,28 @@ +// 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. + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + if Foo { + x: 3 //~ ERROR expected one of `!`, `.`, `::`, `;`, `{`, `}`, or an operator, found `:` + }.hi() { + println!("yo"); + } +} + diff --git a/src/test/parse-fail/struct-literal-in-match-discriminant.rs b/src/test/parse-fail/struct-literal-in-match-discriminant.rs new file mode 100644 index 00000000000..e6948b7c7c9 --- /dev/null +++ b/src/test/parse-fail/struct-literal-in-match-discriminant.rs @@ -0,0 +1,24 @@ +// 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. + +struct Foo { + x: isize, +} + +fn main() { + match Foo { + x: 3 //~ ERROR expected one of `!`, `=>`, `@`, `if`, or `|`, found `:` + } { + Foo { + x: x + } => {} + } +} + diff --git a/src/test/parse-fail/struct-literal-in-while.rs b/src/test/parse-fail/struct-literal-in-while.rs new file mode 100644 index 00000000000..05fa3a8dd5f --- /dev/null +++ b/src/test/parse-fail/struct-literal-in-while.rs @@ -0,0 +1,28 @@ +// 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. + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + while Foo { + x: 3 //~ ERROR expected one of `!`, `.`, `::`, `;`, `{`, `}`, or an operator, found `:` + }.hi() { + println!("yo"); + } +} + diff --git a/src/test/parse-fail/struct-no-fields-enumlike.rs b/src/test/parse-fail/struct-no-fields-enumlike.rs new file mode 100644 index 00000000000..379d310a60b --- /dev/null +++ b/src/test/parse-fail/struct-no-fields-enumlike.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. + +struct Foo(); //~ ERROR unit-like struct definition should be written as `struct Foo;` + +fn main() {} diff --git a/src/test/parse-fail/struct-no-fields.rs b/src/test/parse-fail/struct-no-fields.rs new file mode 100644 index 00000000000..ee853ade18e --- /dev/null +++ b/src/test/parse-fail/struct-no-fields.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. + +struct Foo {} +//~^ ERROR: unit-like struct definition should be written as `struct Foo;` + +fn main() {} diff --git a/src/test/parse-fail/trait-keyword.rs b/src/test/parse-fail/trait-keyword.rs new file mode 100644 index 00000000000..e60be6c81eb --- /dev/null +++ b/src/test/parse-fail/trait-keyword.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. + +iface foo { } //~ ERROR iface + +fn main() {} diff --git a/src/test/parse-fail/unbalanced-doublequote.rs b/src/test/parse-fail/unbalanced-doublequote.rs new file mode 100644 index 00000000000..789cc886217 --- /dev/null +++ b/src/test/parse-fail/unbalanced-doublequote.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. + + +// error-pattern: unterminated double quote string + + +fn main() { + " +} diff --git a/src/test/parse-fail/unboxed-closure-sugar-used-on-struct-3.rs b/src/test/parse-fail/unboxed-closure-sugar-used-on-struct-3.rs new file mode 100644 index 00000000000..d86f55d5368 --- /dev/null +++ b/src/test/parse-fail/unboxed-closure-sugar-used-on-struct-3.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. + +// Test that parentheses form doesn't work in expression paths. + +struct Bar<A,R> { + f: A, r: R +} + +impl<A,B> Bar<A,B> { + fn new() -> Bar<A,B> { panic!() } +} + +fn bar() { + let b = Box::Bar::<isize,usize>::new(); // OK + + let b = Box::Bar::()::new(); + //~^ ERROR expected ident, found `(` +} + +fn main() { } + diff --git a/src/test/parse-fail/unsized.rs b/src/test/parse-fail/unsized.rs new file mode 100644 index 00000000000..92dbea0424b --- /dev/null +++ b/src/test/parse-fail/unsized.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. + +// Test syntax checks for `type` keyword. + +struct S1 for type; //~ ERROR expected `where`, `{`, `(`, or `;` after struct name, found `for` + +pub fn main() { +} diff --git a/src/test/parse-fail/use-as-where-use-ends-with-mod-sep.rs b/src/test/parse-fail/use-as-where-use-ends-with-mod-sep.rs new file mode 100644 index 00000000000..524fd01b94c --- /dev/null +++ b/src/test/parse-fail/use-as-where-use-ends-with-mod-sep.rs @@ -0,0 +1,12 @@ +// 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. + +use std::any:: as foo; //~ ERROR expected identifier, found keyword `as` +//~^ ERROR: expected one of `::`, `;`, or `as`, found `foo` diff --git a/src/test/parse-fail/use-ends-with-mod-sep.rs b/src/test/parse-fail/use-ends-with-mod-sep.rs new file mode 100644 index 00000000000..a375a5962a5 --- /dev/null +++ b/src/test/parse-fail/use-ends-with-mod-sep.rs @@ -0,0 +1,11 @@ +// 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. + +use std::any::; //~ ERROR expected identifier or `{` or `*`, found `;` diff --git a/src/test/parse-fail/use-mod-4.rs b/src/test/parse-fail/use-mod-4.rs new file mode 100644 index 00000000000..a8b551b5376 --- /dev/null +++ b/src/test/parse-fail/use-mod-4.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. + +use foo::self; +//~^ ERROR expected identifier, found keyword `self` + +fn main() {} + diff --git a/src/test/parse-fail/variadic-ffi-1.rs b/src/test/parse-fail/variadic-ffi-1.rs new file mode 100644 index 00000000000..34846ab496d --- /dev/null +++ b/src/test/parse-fail/variadic-ffi-1.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. + +extern { + fn printf(...); //~ ERROR: variadic function must be declared with at least one named argument + fn printf(..., foo: isize); //~ ERROR: `...` must be last in argument list for variadic function +} + +fn main() {} diff --git a/src/test/parse-fail/variadic-ffi-3.rs b/src/test/parse-fail/variadic-ffi-3.rs new file mode 100644 index 00000000000..331a4523934 --- /dev/null +++ b/src/test/parse-fail/variadic-ffi-3.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. + +fn foo(x: isize, ...) { + //~^ ERROR: only foreign functions are allowed to be variadic +} + +fn main() {} diff --git a/src/test/parse-fail/variadic-ffi-4.rs b/src/test/parse-fail/variadic-ffi-4.rs new file mode 100644 index 00000000000..62e985f44f7 --- /dev/null +++ b/src/test/parse-fail/variadic-ffi-4.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. + +extern "C" fn foo(x: isize, ...) { + //~^ ERROR: only foreign functions are allowed to be variadic +} + +fn main() {} |
