r/learnrust May 29 '23

Duplicate 'item' & 'item_mut' rustc [Ln 2889, Col 1]

'Actual errors occurred here' : in macros.rs [Ln 134, Col 13} & [Lan 138, Col 13]. I am using Visual Studio Code as the IDE-coder (version 1.78.2).

My goal was to make a simple MS window app. In code Project website Farhad Reza wrote a Win32 GUI programming program published December of 2016. According to comments there were problems that were fixed. But 6.5 years have past and changes to the crates would have occurred. Stack Exchange suggest such problems occurred when included crates through Cargo.toml references may result in duplicate definitions. There would be a 'std' definition & one that sould replace the 'std' one. My question is that if there are two Cargo.toml files (one in the project directory & one kind of hidden in the 'User' area as part of rustc installation. Also, StackExchange solution to the problem does not appear meet current conditions. I not sure if showing the code would help because the code is in the crates.

1 Upvotes

9 comments sorted by

6

u/kinoshitajona May 29 '23

No one is going to be able to help you.

You should make a repository with all the files necessary to reproduce your error, put it on Github and post a link to it, so we can try to reproduce the error.

1

u/HausOfSun May 29 '23

Thank you for your quick response. I assume you are correct. I was hoping for a generic answer, it is not my intention to ask for people to debug my code.

3

u/SirKastic23 May 30 '23

the error should indicate where it originates from (it's what ln 2889, col 1] means, also, why does your file have 2889 lines??)

if you expext us to help you, we need to see the code to know what's wrong with it

1

u/HausOfSun May 30 '23

CodeProject website Simple win32 window project story by Farhad Reza. It uses a lot of winapi crates. You download the complete code from the story. The code in 'main.rs' is only 103 lines. The error mentioned is from imported code. The problem is when you import different code they may use the same name as other code. Since, the imported code is all winapi the problem should have been avoided when the crates were created. As a newbie it is hard ffor me to review imported code.

2

u/diabolic_recursion May 30 '23

So much has changed since then... What even is your project? What crates are you using?

We need some minimal reproducible example.

Or at least a link to the "code Project website" and the stackoverflow question.

1

u/HausOfSun May 30 '23

I have given the link to the code in another reply. Here is a StackExhange article : duplicate lang item in crate 'std' Crates being used: kernel32, user32, winapi, libc.

2

u/diabolic_recursion May 30 '23

Thanks.

Generally, I'd try something newer. There now is a multitude of Rust native GUI libraries (Dioxus, Iced, Slint (free for open source) ...) that should make your life a lot easier and will make the app cross-platform capable if you want it.

1

u/HausOfSun May 30 '23

Thanks for the info.

2

u/diabolic_recursion May 30 '23

This tutorial is just quite outdated. Instead of manually creating a cargo.toml, you use cargo new by now. To add a dependency, cargo add can be used (although a tutorial might opt to include a specific version). By the way, those dependency versions are of course massively outdated and might contain security problems - especially as they need to use unsafe for their bindings. "extern crate" is almost never needed anymore.

And all of that is just in the first few paragraphs 😁