This repository was archived by the owner on Jun 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
This repository was archived by the owner on Jun 2, 2020. It is now read-only.
You can create Functions named with keywords. Breaks on compilation. #426
Copy link
Copy link
Open
Description
Steps to reproduce
cargo func new-app some_app_name
cd some_app_name
cargo func new http -n do
cargo func run
Expected behavior
Any time that a user tries to make a function named after a Rust keyword, they should get a warning and suggestion to try something different and replace the keyword with the escaped version (e.g. do
-> r#do
).
Actual behavior
error: expected identifier, found reserved keyword `do`
--> src\functions\mod.rs:4:5
|
4 | mod do;
| ^^ expected identifier, found reserved keyword
help: you can escape reserved keywords to use them as identifiers
|
4 | mod r#do;
| ^^^^ error: expected identifier, found reserved keyword `do`
--> src\functions\do.rs:7:8
|
7 | pub fn do(req: HttpRequest) -> HttpResponse {
| ^^ expected identifier, found reserved keyword
help: you can escape reserved keywords to use them as identifiers
|
7 | pub fn r#do(req: HttpRequest) -> HttpResponse {
| ^^^^ error: expected expression, found reserved keyword `do`
--> src\functions\mod.rs:8:6
|
8 | &do::DO_FUNCTION,
| ^^ expected expression error: aborting due to 3 previous errors error: could not compile `some_app_name`. To learn more, run the command again with --verbose. error: cargo failed with exit code 101.
peterhuene
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working