I'm ambivalent about Rust, but its best feature compared to C++ is a universal package manager and build system. I like vcpkg well enough, but it's not Cargo, it can't be.
I'm ambivalent about Rust, but its best feature compared to C++ is a universal package manager and build system. I like vcpkg well enough, but it's not Cargo, it can't be.
If they're unused, then they're not helping with debugging either...
It's quite a bizarre reason
At least this is how it works in C and C++.
#![allow(dead_code)]
at the root of the crateI'm not sure what you mean by "optimizing away unused variables", so I'm interpreting it as variables that are literally unused after declaration.
I believe you're confusing Rust with Go. In Rust, an unused variable is just a warning, unless you explicitly asked the compiler to turn that warning (or all warnings) into an error.
What you cannot have, is uninitialized variables which are used.
And as someone else said, if all you want is unused variables without warnings, you can say at the top of the root of the crate (`main.rs` or `lib.rs`):
#![allow(dead_code)]Rust actually does allow uninitialized variables, even in safe code. But it'll be a compiler error if you try to use them in any way before initializing them, so this is mostly just a curiosity: https://play.rust-lang.org/?version=stable&mode=debug&editio...
If we get a C++ Copilot as "borrow checker" that is already quite an improvement, even if not perfect.
Hmm, another idea: what if a language's compiler itself use an LLM to find invariants and issues (like race conditions) in the code?
In any case, taken to the extreme, the language won't matter any longer, beyond some druids with the knowledge to implement Star Trek like computing models.
We will be left to architect roles.