Change:
<!-- Thank you for filing a bug report! Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. If you cannot produce a minimal reproduction case (something that would work in isolation), please provide the steps or even link to a repository that causes the problematic output to occur. --Given the following code: <!-- Please provide a link to --The current output is: Ideally the error message should suggest replacing or with . <!-- If the problem is not self-explanatory, please provide a rationale for the change. --<!-- If dramatically different output is caused by small changes, consider also adding them here. If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. The output might also be different depending on the Edition. --<!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim
New to rustc community and wants to contribute code. there any options to debug rustc which line of which file the error abort happens? can I dump the hierarchy tree for debugging use? C++ we usually use env for compiler debugging. How do rustc often use? Very newbie questions, thank you in advance.
label +E-easy +E-mentor Welcome to Rust! This might be some help -- This issue is very similar to , so take a peek at the diff there. IMO the following tokens are enough to check against function (Julia/JavaScript/etc) func (Go) fun (Kotlin) def (Python) Have fun! <3
Instructions -- Add a check if prevtoken is either ///etc Emit a message, something along the lines of "use instead of <prevtokento make a function" using , there are a few usages of this in the same file so those might be good examples. Add tests for this in -- Ideally each suggestion would have a test. Should be helpful to take as a reference
We can include if necessary.
Hi guys, another rust newbie looking for something easy to get started here. are you still on this or could go with my attempt here?
ypprog does seem to be active and it hasn't been that long, if you'd like you can pick another issue. =) Try going through the E-Easy and/or E-Mentor category for easy issues. However, to clarify, if an issue which is claimed doesn't seem to have any work done for a long period of time (A month or so is a good amount of time) -- Feel free to ping the assignee to confirm and handle it accordingly.
With these changes, I also think it is important to implement improved error messages for when a user puts the return type at the start of the function instead of the end. Given this code: The error output is:
I feel like adding might also be helpful for C++ developers :)
Is this still being worked on?
release-assignment
claim

Discussion:
appl, ); } <ins> if ["def", "fun", "func", "function"].contains(&symbol.as_str()) { err.span_suggestion_short( self.prev_token.span, &format!("write `fn` instead of `{symbol}` to declare a function"), "fn", appl, ); } </ins> } // Add suggestion for a missing closing angle bracket if '>' is included in expected_tokens

<ins> // 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() {} </ins>

<ins> 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 </ins>

<ins> // 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() {} </ins>

<ins> 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 </ins>

<ins> // 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() {} </ins>

<ins> 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 </ins>

<ins> // 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() {} </ins>

<ins> 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 </ins>