diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2017-11-21 08:03:02 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2017-11-24 07:34:32 -0800 |
| commit | c82e9e8e1e634250b901b69808f65fbe5f3312c3 (patch) | |
| tree | e84815f5482ca3dd0ed07b58198a51f2fc1ef8ef /src/test | |
| parent | 7c0387e36a1dab95492de61a2f26262a4526c286 (diff) | |
| download | rust-c82e9e8e1e634250b901b69808f65fbe5f3312c3.tar.gz rust-c82e9e8e1e634250b901b69808f65fbe5f3312c3.zip | |
Do not attemt to continue parsing after `pub ident`
Try to identify the following code in order to provide better diagnostics, but return the error to bail out early during the parse.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/pub/pub-restricted-error.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/suggestions/pub-ident-fn-2.rs (renamed from src/test/ui/suggestions/pub-ident-missing-kw-unclosed-block.rs) | 30 | ||||
| -rw-r--r-- | src/test/ui/suggestions/pub-ident-fn-2.stderr | 13 | ||||
| -rw-r--r-- | src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs (renamed from src/test/ui/suggestions/pub-ident-missing-kw.rs) | 30 | ||||
| -rw-r--r-- | src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/suggestions/pub-ident-fn-or-struct.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/suggestions/pub-ident-fn-or-struct.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/suggestions/pub-ident-missing-kw-unclosed-block.stderr | 36 | ||||
| -rw-r--r-- | src/test/ui/suggestions/pub-ident-missing-kw.stderr | 69 |
9 files changed, 48 insertions, 161 deletions
diff --git a/src/test/ui/pub/pub-restricted-error.rs b/src/test/ui/pub/pub-restricted-error.rs index 99af031899a..7f300ed2342 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, } - +fn main() {} diff --git a/src/test/ui/suggestions/pub-ident-missing-kw-unclosed-block.rs b/src/test/ui/suggestions/pub-ident-fn-2.rs index ceaaa0315d2..40c50a4b8dd 100644 --- a/src/test/ui/suggestions/pub-ident-missing-kw-unclosed-block.rs +++ b/src/test/ui/suggestions/pub-ident-fn-2.rs @@ -8,32 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub Struct { - y: usize, -} - -pub Y { - x: usize, - - -pub struct X { - foo(); -} - -pub Z { - x->foo(), -} - -pub foo(foo) { - foo -} +pub foo(s: usize) { bar() } -pub struct X { - foo(); +fn main() { + foo(2); } - -pub Z { - x->foo(), -} - -fn main(){} 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..43b81efbf4c --- /dev/null +++ b/src/test/ui/suggestions/pub-ident-fn-2.stderr @@ -0,0 +1,13 @@ +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-missing-kw.rs b/src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs index e2a7c394ec9..6b5ae19e6ff 100644 --- a/src/test/ui/suggestions/pub-ident-missing-kw.rs +++ b/src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs @@ -8,32 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub Struct { - y: usize, -} +pub S(); -pub Y { - x: usize, -} - -pub struct X { - foo(); -} - -pub Z { - x->foo(), -} - -pub foo(foo) { - foo -} - -pub struct X { - foo(); -} - -pub Z { - x->foo(), -} - -fn main(){} +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..e8636f67e0b --- /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(); + | ^ + +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..8bb1c6afcbb --- /dev/null +++ b/src/test/ui/suggestions/pub-ident-fn-or-struct.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub S (foo) bar + +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..dc391c1113d --- /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 + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/suggestions/pub-ident-missing-kw-unclosed-block.stderr b/src/test/ui/suggestions/pub-ident-missing-kw-unclosed-block.stderr deleted file mode 100644 index a580aaac8de..00000000000 --- a/src/test/ui/suggestions/pub-ident-missing-kw-unclosed-block.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error: this file contains an un-closed delimiter - --> $DIR/pub-ident-missing-kw-unclosed-block.rs:29:13 - | -39 | fn main(){} - | ^ - | -help: did you mean to close this delimiter? - --> $DIR/pub-ident-missing-kw-unclosed-block.rs:5:7 - | -15 | pub Y { - | ^ - -error: missing `struct` for struct definition - --> $DIR/pub-ident-missing-kw-unclosed-block.rs:1:4 - | -11 | pub Struct { - | ^ - | -help: add `struct` here to parse `Struct` as a public struct - | -11 | pub struct Struct { - | ^^^^^^ - -error: missing `struct` for struct definition - --> $DIR/pub-ident-missing-kw-unclosed-block.rs:5:4 - | -15 | pub Y { - | ^ - | -help: add `struct` here to parse `Y` as a public struct - | -15 | pub struct Y { - | ^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/suggestions/pub-ident-missing-kw.stderr b/src/test/ui/suggestions/pub-ident-missing-kw.stderr deleted file mode 100644 index 23ac4eca2b4..00000000000 --- a/src/test/ui/suggestions/pub-ident-missing-kw.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error: missing `struct` for struct definition - --> $DIR/pub-ident-missing-kw.rs:11:4 - | -11 | pub Struct { - | ^ - | -help: add `struct` here to parse `Struct` as a public struct - | -11 | pub struct Struct { - | ^^^^^^ - -error: missing `struct` for struct definition - --> $DIR/pub-ident-missing-kw.rs:15:4 - | -15 | pub Y { - | ^ - | -help: add `struct` here to parse `Y` as a public struct - | -15 | pub struct Y { - | ^^^^^^ - -error: expected `:`, found `(` - --> $DIR/pub-ident-missing-kw.rs:20:8 - | -20 | foo(); - | ^ - -error: missing `struct` for struct definition - --> $DIR/pub-ident-missing-kw.rs:23:4 - | -23 | pub Z { - | ^ - | -help: add `struct` here to parse `Z` as a public struct - | -23 | pub struct Z { - | ^^^^^^ - -error: missing `fn` for fn definition - --> $DIR/pub-ident-missing-kw.rs:27:4 - | -27 | pub foo(foo) { - | ^ - | -help: add `fn` here to parse `foo` as a public fn - | -27 | pub fn foo(foo) { - | ^^ - -error: expected `:`, found `(` - --> $DIR/pub-ident-missing-kw.rs:32:8 - | -32 | foo(); - | ^ - -error: missing `struct` for struct definition - --> $DIR/pub-ident-missing-kw.rs:35:4 - | -35 | pub Z { - | ^ - | -help: add `struct` here to parse `Z` as a public struct - | -35 | pub struct Z { - | ^^^^^^ - -error: aborting due to 7 previous errors - |
