about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-12-01 06:06:06 +0000
committerbors <bors@rust-lang.org>2017-12-01 06:06:06 +0000
commitd1364a65c0e064ee12aea8d58aceb403b8200682 (patch)
tree4610cdc2a8f401adb2cca09a6594d52fd1c74299 /src/test
parent804b15be82ea668d943fab70195eb57a2f942d4b (diff)
parentcf9283ea9376525c59015a52c729e7a79f576426 (diff)
downloadrust-d1364a65c0e064ee12aea8d58aceb403b8200682.tar.gz
rust-d1364a65c0e064ee12aea8d58aceb403b8200682.zip
Auto merge of #45997 - estebank:pub-ident, r=nikomatsakis
Account for missing keyword in fn/struct definition

Fix #38911.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs3
-rw-r--r--src/test/parse-fail/doc-after-struct-field.rs10
-rw-r--r--src/test/parse-fail/doc-before-struct-rbrace-1.rs2
-rw-r--r--src/test/parse-fail/doc-before-struct-rbrace-2.rs2
-rw-r--r--src/test/parse-fail/issue-22647.rs1
-rw-r--r--src/test/parse-fail/issue-37234.rs2
-rw-r--r--src/test/parse-fail/mut-patterns.rs1
-rw-r--r--src/test/parse-fail/pat-lt-bracket-5.rs2
-rw-r--r--src/test/ui/pub/pub-restricted-error.rs2
-rw-r--r--src/test/ui/suggestions/pub-ident-fn-2.rs16
-rw-r--r--src/test/ui/suggestions/pub-ident-fn-2.stderr12
-rw-r--r--src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs14
-rw-r--r--src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr8
-rw-r--r--src/test/ui/suggestions/pub-ident-fn-or-struct.rs14
-rw-r--r--src/test/ui/suggestions/pub-ident-fn-or-struct.stderr8
-rw-r--r--src/test/ui/suggestions/pub-ident-fn.rs16
-rw-r--r--src/test/ui/suggestions/pub-ident-fn.stderr12
-rw-r--r--src/test/ui/suggestions/pub-ident-struct.rs14
-rw-r--r--src/test/ui/suggestions/pub-ident-struct.stderr12
19 files changed, 144 insertions, 7 deletions
diff --git a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs
index b03409c9c28..93790f59372 100644
--- a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs
+++ b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs
@@ -17,7 +17,8 @@ extern crate derive_bad;
 #[derive(
     A
 )]
-//~^^ ERROR: proc-macro derive produced unparseable tokens
+//~^^ ERROR proc-macro derive produced unparseable tokens
+//~| ERROR expected `:`, found `}`
 struct A;
 
 fn main() {}
diff --git a/src/test/parse-fail/doc-after-struct-field.rs b/src/test/parse-fail/doc-after-struct-field.rs
index 1aa6af5b78f..a2c60151ac7 100644
--- a/src/test/parse-fail/doc-after-struct-field.rs
+++ b/src/test/parse-fail/doc-after-struct-field.rs
@@ -9,12 +9,20 @@
 // except according to those terms.
 
 // compile-flags: -Z continue-parse-after-error
+
 struct X {
     a: u8 /** document a */,
     //~^ ERROR found a documentation comment that doesn't document anything
     //~| HELP maybe a comment was intended
 }
 
+struct Y {
+    a: u8 /// document a
+    //~^ ERROR found a documentation comment that doesn't document anything
+    //~| HELP maybe a comment was intended
+}
+
 fn main() {
-    let y = X {a = 1};
+    let x = X { a: 1 };
+    let y = Y { a: 1 };
 }
diff --git a/src/test/parse-fail/doc-before-struct-rbrace-1.rs b/src/test/parse-fail/doc-before-struct-rbrace-1.rs
index 5ba83190c8e..6d9b4b05ad9 100644
--- a/src/test/parse-fail/doc-before-struct-rbrace-1.rs
+++ b/src/test/parse-fail/doc-before-struct-rbrace-1.rs
@@ -17,5 +17,5 @@ struct X {
 }
 
 fn main() {
-    let y = X {a = 1};
+    let y = X {a: 1};
 }
diff --git a/src/test/parse-fail/doc-before-struct-rbrace-2.rs b/src/test/parse-fail/doc-before-struct-rbrace-2.rs
index 643e4aa17a1..63b2f963799 100644
--- a/src/test/parse-fail/doc-before-struct-rbrace-2.rs
+++ b/src/test/parse-fail/doc-before-struct-rbrace-2.rs
@@ -16,5 +16,5 @@ struct X {
 }
 
 fn main() {
-    let y = X {a = 1};
+    let y = X {a: 1};
 }
diff --git a/src/test/parse-fail/issue-22647.rs b/src/test/parse-fail/issue-22647.rs
index 1ace57edba3..3da9d1a8712 100644
--- a/src/test/parse-fail/issue-22647.rs
+++ b/src/test/parse-fail/issue-22647.rs
@@ -16,6 +16,7 @@ fn main() {
         println!("Y {}",x);
         return x;
     };
+    //~^ ERROR expected item, found `;`
 
     caller(bar_handler);
 }
diff --git a/src/test/parse-fail/issue-37234.rs b/src/test/parse-fail/issue-37234.rs
index 651e11d9d21..93a1468bf7b 100644
--- a/src/test/parse-fail/issue-37234.rs
+++ b/src/test/parse-fail/issue-37234.rs
@@ -11,7 +11,7 @@
 macro_rules! failed {
     () => {{
         let x = 5 ""; //~ ERROR found `""`
-    }} //~ ERROR macro expansion ignores token `}`
+    }}
 }
 
 fn main() {
diff --git a/src/test/parse-fail/mut-patterns.rs b/src/test/parse-fail/mut-patterns.rs
index 71d826c67f8..ffb45597552 100644
--- a/src/test/parse-fail/mut-patterns.rs
+++ b/src/test/parse-fail/mut-patterns.rs
@@ -15,4 +15,5 @@
 pub fn main() {
     struct Foo { x: isize }
     let mut Foo { x: x } = Foo { x: 3 }; //~ ERROR: expected one of `:`, `;`, `=`, or `@`, found `{`
+    //~^ ERROR expected item, found `=`
 }
diff --git a/src/test/parse-fail/pat-lt-bracket-5.rs b/src/test/parse-fail/pat-lt-bracket-5.rs
index 3345845eee9..421d7a05bef 100644
--- a/src/test/parse-fail/pat-lt-bracket-5.rs
+++ b/src/test/parse-fail/pat-lt-bracket-5.rs
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 fn main() {
-    let v[0] = v[1]; //~ error: expected one of `:`, `;`, `=`, or `@`, found `[`
+    let v[0] = v[1]; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[`
 }
diff --git a/src/test/ui/pub/pub-restricted-error.rs b/src/test/ui/pub/pub-restricted-error.rs
index dfc927f2cb5..4822d01a591 100644
--- a/src/test/ui/pub/pub-restricted-error.rs
+++ b/src/test/ui/pub/pub-restricted-error.rs
@@ -16,4 +16,4 @@ struct Foo {
     pub(crate) () foo: usize, //~ ERROR expected identifier
 }
 
-
+fn main() {}
diff --git a/src/test/ui/suggestions/pub-ident-fn-2.rs b/src/test/ui/suggestions/pub-ident-fn-2.rs
new file mode 100644
index 00000000000..44884bfcdfd
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-fn-2.rs
@@ -0,0 +1,16 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub foo(s: usize) { bar() }
+//~^ ERROR missing `fn` for method definition
+
+fn main() {
+    foo(2);
+}
diff --git a/src/test/ui/suggestions/pub-ident-fn-2.stderr b/src/test/ui/suggestions/pub-ident-fn-2.stderr
new file mode 100644
index 00000000000..7d3abceb11b
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-fn-2.stderr
@@ -0,0 +1,12 @@
+error: missing `fn` for method definition
+  --> $DIR/pub-ident-fn-2.rs:11:4
+   |
+11 | pub foo(s: usize) { bar() }
+   |    ^
+help: add `fn` here to parse `foo` as a public method
+   |
+11 | pub fn foo(s: usize) { bar() }
+   |     ^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs b/src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs
new file mode 100644
index 00000000000..1ccadc8a40b
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs
@@ -0,0 +1,14 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub S();
+//~^ ERROR missing `fn` or `struct` for method or struct definition
+
+fn main() {}
diff --git a/src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr b/src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr
new file mode 100644
index 00000000000..68dea2aec3a
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr
@@ -0,0 +1,8 @@
+error: missing `fn` or `struct` for method or struct definition
+  --> $DIR/pub-ident-fn-or-struct-2.rs:11:4
+   |
+11 | pub S();
+   | ---^- help: if you meant to call a macro, write instead: `S!`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/suggestions/pub-ident-fn-or-struct.rs b/src/test/ui/suggestions/pub-ident-fn-or-struct.rs
new file mode 100644
index 00000000000..0664918945b
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-fn-or-struct.rs
@@ -0,0 +1,14 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub S (foo) bar
+//~^ ERROR missing `fn` or `struct` for method or struct definition
+
+fn main() {}
diff --git a/src/test/ui/suggestions/pub-ident-fn-or-struct.stderr b/src/test/ui/suggestions/pub-ident-fn-or-struct.stderr
new file mode 100644
index 00000000000..0c19f776bd1
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-fn-or-struct.stderr
@@ -0,0 +1,8 @@
+error: missing `fn` or `struct` for method or struct definition
+  --> $DIR/pub-ident-fn-or-struct.rs:11:4
+   |
+11 | pub S (foo) bar
+   | ---^- help: if you meant to call a macro, write instead: `S!`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/suggestions/pub-ident-fn.rs b/src/test/ui/suggestions/pub-ident-fn.rs
new file mode 100644
index 00000000000..1d641996420
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-fn.rs
@@ -0,0 +1,16 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub   foo(s: usize) -> bool { true }
+//~^ ERROR missing `fn` for method definition
+
+fn main() {
+    foo(2);
+}
diff --git a/src/test/ui/suggestions/pub-ident-fn.stderr b/src/test/ui/suggestions/pub-ident-fn.stderr
new file mode 100644
index 00000000000..d36b9b127e0
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-fn.stderr
@@ -0,0 +1,12 @@
+error: missing `fn` for method definition
+  --> $DIR/pub-ident-fn.rs:11:4
+   |
+11 | pub   foo(s: usize) -> bool { true }
+   |    ^^^
+help: add `fn` here to parse `foo` as a public method
+   |
+11 | pub fn foo(s: usize) -> bool { true }
+   |     ^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/suggestions/pub-ident-struct.rs b/src/test/ui/suggestions/pub-ident-struct.rs
new file mode 100644
index 00000000000..d08d498f87a
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-struct.rs
@@ -0,0 +1,14 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub S {
+//~^ ERROR missing `struct` for struct definition
+}
+fn main() {}
diff --git a/src/test/ui/suggestions/pub-ident-struct.stderr b/src/test/ui/suggestions/pub-ident-struct.stderr
new file mode 100644
index 00000000000..36ef3072722
--- /dev/null
+++ b/src/test/ui/suggestions/pub-ident-struct.stderr
@@ -0,0 +1,12 @@
+error: missing `struct` for struct definition
+  --> $DIR/pub-ident-struct.rs:11:4
+   |
+11 | pub S {
+   |    ^
+help: add `struct` here to parse `S` as a public struct
+   |
+11 | pub struct S {
+   |     ^^^^^^
+
+error: aborting due to previous error
+