#[warn(dead_code)] showing unnecessary x is never used warnings
huss4in opened this issue · 5 comments
Since testing in some exercises is done using tests modules, annoying function 'x' is never used warning
shows while and after solving the exercise...
Which could sometimes be annoying or even come before/hide more relevant code lints related to the main exercise issue:
A simple way to make it look cleaner is by adding #![allow(dead_code)]
to all files which have mod tests {
| #![allow(dead_code)]
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
let mut vec = vec;
vec.push(88);
vec
}
...
Or in a more generic/centralized way in Cargo.toml
[lints.rust]
usued = "allow"
Allowing dead code is just a workaround. The actual solution would be to tell Rust-Analyzer to consider the usage in tests.
Rustlings itself does so by passing --profile test
to the used Cargo commands. I will see if I can pass this option to Rust-Analyzer.
@alibektas is rust-analyzer.toml
ready for usage?
This issue can be resolved by setting check.extraArgs
to ["--profile", "test"]
.
To answer your question : It is honestly not completely ready as we keep making changes to config classes a lot but I think in your case it is safe to say that we are not going to make any changes to config keys check.*
.
Thanks for looking into the issue!
I would just like to shed some lights on the fact that using --profile test
doesn't solve all cases
Example in enums2
:
I understand that you might not want to globally turn off dead_code
lints.. or unused
which includes dead_code
and more declared but not used things..
As it might possibly be helpful in some exercises..
However, I just believe that they might not be that useful/important for someone new and trying to learn and might cause some confusion.
Let me know what you think?
And how do you suggest a better solution?
Thanks!