Rollup merge of #56248 - estebank:suggest-bare-pub, r=petrochenkov

Suggest an appropriate token when encountering `pub Ident<'a>`

Fix #55403. Follow up to #45997.
This commit is contained in:
Mazdak Farrokhzad 2018-12-08 08:43:43 +01:00 committed by GitHub
commit ac15b4f4bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 124 additions and 31 deletions

View file

@ -9,7 +9,7 @@
// except according to those terms.
pub foo(s: usize) { bar() }
//~^ ERROR missing `fn` for method definition
//~^ ERROR missing `fn` for function definition
fn main() {
foo(2);

View file

@ -1,9 +1,9 @@
error: missing `fn` for method definition
error: missing `fn` for function definition
--> $DIR/pub-ident-fn-2.rs:11:4
|
LL | pub foo(s: usize) { bar() }
| ^
help: add `fn` here to parse `foo` as a public method
help: add `fn` here to parse `foo` as a public function
|
LL | pub fn foo(s: usize) { bar() }
| ^^

View file

@ -9,6 +9,6 @@
// except according to those terms.
pub S();
//~^ ERROR missing `fn` or `struct` for method or struct definition
//~^ ERROR missing `fn` or `struct` for function or struct definition
fn main() {}

View file

@ -1,4 +1,4 @@
error: missing `fn` or `struct` for method or struct definition
error: missing `fn` or `struct` for function or struct definition
--> $DIR/pub-ident-fn-or-struct-2.rs:11:4
|
LL | pub S();

View file

@ -9,6 +9,6 @@
// except according to those terms.
pub S (foo) bar
//~^ ERROR missing `fn` or `struct` for method or struct definition
//~^ ERROR missing `fn` or `struct` for function or struct definition
fn main() {}

View file

@ -1,4 +1,4 @@
error: missing `fn` or `struct` for method or struct definition
error: missing `fn` or `struct` for function or struct definition
--> $DIR/pub-ident-fn-or-struct.rs:11:4
|
LL | pub S (foo) bar

View file

@ -0,0 +1,6 @@
pub bar<'a>(&self, _s: &'a usize) -> bool { true }
//~^ ERROR missing `fn` for method definition
fn main() {
bar(2);
}

View file

@ -0,0 +1,12 @@
error: missing `fn` for method definition
--> $DIR/pub-ident-fn-with-lifetime-2.rs:1:4
|
LL | pub bar<'a>(&self, _s: &'a usize) -> bool { true }
| ^^^
help: add `fn` here to parse `bar` as a public method
|
LL | pub fn bar<'a>(&self, _s: &'a usize) -> bool { true }
| ^^
error: aborting due to previous error

View file

@ -0,0 +1,6 @@
pub foo<'a>(_s: &'a usize) -> bool { true }
//~^ ERROR missing `fn` for function definition
fn main() {
foo(2);
}

View file

@ -0,0 +1,12 @@
error: missing `fn` for function definition
--> $DIR/pub-ident-fn-with-lifetime.rs:1:4
|
LL | pub foo<'a>(_s: &'a usize) -> bool { true }
| ^^^
help: add `fn` here to parse `foo` as a public function
|
LL | pub fn foo<'a>(_s: &'a usize) -> bool { true }
| ^^
error: aborting due to previous error

View file

@ -11,7 +11,7 @@
// run-rustfix
pub fn foo(_s: usize) -> bool { true }
//~^ ERROR missing `fn` for method definition
//~^ ERROR missing `fn` for function definition
fn main() {
foo(2);

View file

@ -11,7 +11,7 @@
// run-rustfix
pub foo(_s: usize) -> bool { true }
//~^ ERROR missing `fn` for method definition
//~^ ERROR missing `fn` for function definition
fn main() {
foo(2);

View file

@ -1,9 +1,9 @@
error: missing `fn` for method definition
error: missing `fn` for function definition
--> $DIR/pub-ident-fn.rs:13:4
|
LL | pub foo(_s: usize) -> bool { true }
| ^^^
help: add `fn` here to parse `foo` as a public method
help: add `fn` here to parse `foo` as a public function
|
LL | pub fn foo(_s: usize) -> bool { true }
| ^^

View file

@ -0,0 +1,4 @@
pub S<'a> {
//~^ ERROR missing `struct` for struct definition
}
fn main() {}

View file

@ -0,0 +1,12 @@
error: missing `struct` for struct definition
--> $DIR/pub-ident-struct-with-lifetime.rs:1:4
|
LL | pub S<'a> {
| ^
help: add `struct` here to parse `S` as a public struct
|
LL | pub struct S<'a> {
| ^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,5 @@
fn main() {
}
pub foo<'a>
//~^ ERROR missing `fn` or `struct` for function or struct definition

View file

@ -0,0 +1,8 @@
error: missing `fn` or `struct` for function or struct definition
--> $DIR/pub-ident-with-lifetime-incomplete.rs:4:4
|
LL | pub foo<'a>
| ^^^
error: aborting due to previous error