Review my error

My function definitions are in an external file. I’ve used mod and called the functions in main(). The function fun_with_return_() is the first one in the external file, and fun_with_return_2_() is the second function in the same file. However, I’m getting the error: “similarly named function fun_with_return_ defined here.”

Can you please help me rephrase this error explanation in a clearer and more professional way?

Could you show your main() code that’s producing this error? Try to give an MVCE.

Thanks @jwodder, I tried the same code in a new project, and it runs without errors. I wrote many functions in main.rs and in a second file. The error may have occurred because of that. If possible, could you please help me understand why the error occurred in the old package but not in the new one? I would be very thankful for your guidance

The error indicates that you tried to use a function that wasn’t defined but that had a name similar to `fun_with_return_`. This suggests that you slightly misspelled the name of the function when using it in the old package but not in the new one.

Note that this is not an error. It is a help message that is part of another error.

I’m guessing that you're using some IDE, and that this IDE has underlined some source code or otherwise put the help message next to the code it is pointing to not the error. This is not how Rust error messages are designed to be viewed, because the help message has been taken out of context of the rest of the error.

To understand the error properly, run cargo check and read it from top to bottom. It will print each error starting with error, and below each one there will be additional help: and note: messages meant to help you understand that error.

Whenever you encounter a confusing error, you should make sure you are viewing it with cargo check so you can see the error in the way rustc’s authors meant it to be seen.

After you’ve done that, if you are still confused, please share the entire error report with us, and tell us about how it is confusing, so we can help you with it.

4 Likes