Rollup merge of #100750 - akabinds:akabinds/improved-invalid-function-qual-error, r=davidtwco
improved diagnostic for function defined with `def`, `fun`, `func`, or `function` instead of `fn` Closes #99751
This commit is contained in:
commit
af89769c82
9 changed files with 89 additions and 0 deletions
10
src/test/ui/parser/fn-defined-using-def.rs
Normal file
10
src/test/ui/parser/fn-defined-using-def.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Check what happens when `def` is used to define a function, instead of `fn`
|
||||
// edition:2021
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
def foo() {}
|
||||
//~^ ERROR expected one of `!` or `::`, found `foo`
|
||||
//~^^ HELP write `fn` instead of `def` to declare a function
|
||||
|
||||
fn main() {}
|
||||
10
src/test/ui/parser/fn-defined-using-def.stderr
Normal file
10
src/test/ui/parser/fn-defined-using-def.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: expected one of `!` or `::`, found `foo`
|
||||
--> $DIR/fn-defined-using-def.rs:6:5
|
||||
|
|
||||
LL | def foo() {}
|
||||
| --- ^^^ expected one of `!` or `::`
|
||||
| |
|
||||
| help: write `fn` instead of `def` to declare a function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
10
src/test/ui/parser/fn-defined-using-fun.rs
Normal file
10
src/test/ui/parser/fn-defined-using-fun.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Check what happens when `fun` is used to define a function, instead of `fn`
|
||||
// edition:2021
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
fun foo() {}
|
||||
//~^ ERROR expected one of `!` or `::`, found `foo`
|
||||
//~^^ HELP write `fn` instead of `fun` to declare a function
|
||||
|
||||
fn main() {}
|
||||
10
src/test/ui/parser/fn-defined-using-fun.stderr
Normal file
10
src/test/ui/parser/fn-defined-using-fun.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: expected one of `!` or `::`, found `foo`
|
||||
--> $DIR/fn-defined-using-fun.rs:6:5
|
||||
|
|
||||
LL | fun foo() {}
|
||||
| --- ^^^ expected one of `!` or `::`
|
||||
| |
|
||||
| help: write `fn` instead of `fun` to declare a function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
10
src/test/ui/parser/fn-defined-using-func.rs
Normal file
10
src/test/ui/parser/fn-defined-using-func.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Check what happens when `func` is used to define a function, instead of `fn`
|
||||
// edition:2021
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
func foo() {}
|
||||
//~^ ERROR expected one of `!` or `::`, found `foo`
|
||||
//~^^ HELP write `fn` instead of `func` to declare a function
|
||||
|
||||
fn main() {}
|
||||
10
src/test/ui/parser/fn-defined-using-func.stderr
Normal file
10
src/test/ui/parser/fn-defined-using-func.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: expected one of `!` or `::`, found `foo`
|
||||
--> $DIR/fn-defined-using-func.rs:6:6
|
||||
|
|
||||
LL | func foo() {}
|
||||
| ---- ^^^ expected one of `!` or `::`
|
||||
| |
|
||||
| help: write `fn` instead of `func` to declare a function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
10
src/test/ui/parser/fn-defined-using-function.rs
Normal file
10
src/test/ui/parser/fn-defined-using-function.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Check what happens when `function` is used to define a function, instead of `fn`
|
||||
// edition:2021
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
function foo() {}
|
||||
//~^ ERROR expected one of `!` or `::`, found `foo`
|
||||
//~^^ HELP write `fn` instead of `function` to declare a function
|
||||
|
||||
fn main() {}
|
||||
10
src/test/ui/parser/fn-defined-using-function.stderr
Normal file
10
src/test/ui/parser/fn-defined-using-function.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: expected one of `!` or `::`, found `foo`
|
||||
--> $DIR/fn-defined-using-function.rs:6:10
|
||||
|
|
||||
LL | function foo() {}
|
||||
| -------- ^^^ expected one of `!` or `::`
|
||||
| |
|
||||
| help: write `fn` instead of `function` to declare a function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue