Suggest an appropriate token when encountering pub Ident<'a>
This commit is contained in:
parent
3dde9e1322
commit
0952856e6c
7 changed files with 75 additions and 11 deletions
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 method 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 method 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 method
|
||||
|
|
||||
LL | pub fn foo<'a>(_s: &'a usize) -> bool { true }
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
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 method or struct definition
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: missing `fn` or `struct` for method 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