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:
commit
ac15b4f4bd
18 changed files with 124 additions and 31 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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() }
|
||||
| ^^
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
6
src/test/ui/pub/pub-ident-fn-with-lifetime-2.rs
Normal file
6
src/test/ui/pub/pub-ident-fn-with-lifetime-2.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
pub bar<'a>(&self, _s: &'a usize) -> bool { true }
|
||||
//~^ ERROR missing `fn` for method definition
|
||||
|
||||
fn main() {
|
||||
bar(2);
|
||||
}
|
||||
12
src/test/ui/pub/pub-ident-fn-with-lifetime-2.stderr
Normal file
12
src/test/ui/pub/pub-ident-fn-with-lifetime-2.stderr
Normal 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
|
||||
|
||||
6
src/test/ui/pub/pub-ident-fn-with-lifetime.rs
Normal file
6
src/test/ui/pub/pub-ident-fn-with-lifetime.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
pub foo<'a>(_s: &'a usize) -> bool { true }
|
||||
//~^ ERROR missing `fn` for function definition
|
||||
|
||||
fn main() {
|
||||
foo(2);
|
||||
}
|
||||
12
src/test/ui/pub/pub-ident-fn-with-lifetime.stderr
Normal file
12
src/test/ui/pub/pub-ident-fn-with-lifetime.stderr
Normal 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
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
| ^^
|
||||
|
|
|
|||
4
src/test/ui/pub/pub-ident-struct-with-lifetime.rs
Normal file
4
src/test/ui/pub/pub-ident-struct-with-lifetime.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
pub S<'a> {
|
||||
//~^ ERROR missing `struct` for struct definition
|
||||
}
|
||||
fn main() {}
|
||||
12
src/test/ui/pub/pub-ident-struct-with-lifetime.stderr
Normal file
12
src/test/ui/pub/pub-ident-struct-with-lifetime.stderr
Normal 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
|
||||
|
||||
5
src/test/ui/pub/pub-ident-with-lifetime-incomplete.rs
Normal file
5
src/test/ui/pub/pub-ident-with-lifetime-incomplete.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
}
|
||||
|
||||
pub foo<'a>
|
||||
//~^ ERROR missing `fn` or `struct` for function or struct definition
|
||||
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue