Add `warning` for unused `import`s
use foo::bar;
use baz::qux; <-- warning: unused import
fn main() {
let bar = bar::new();
}
I plan to take a look into this following #1213 as a way to familiarise with dead code analysis, but won't assign to myself until then in case someone else wants to pick this up in the meantime.
I did some digging:
Dead code analysis is performed on the typed ast. We remove import statements from the typed AST and say they are SideEffects, or noops, during type checking. As the node is effectively removed from the tree, we no longer can add it to the graph for dead code analysis. In order to warn on unused imports, we need to transfer import statements into the typed tree. Then we can add them as a node to the control flow graph and connect to them if their defined content is ever used.
cc @mitchmindtree if you still plan on taking this one, your work in #1578 could end up impacting how import statements are represented and thusly could impact this issue.
Can I contribute to this one? I am a well expereinced developer. eta 5hours
Hi,
I’m Manasseh, and I’d like to take on this task! I’m a Rustacean with 3 years of experience and a strong grip on programming principles. Since this is a Sway compiler written in Rust, I can add a warning for unused imports like baz::qux in the example. I’ll make sure it’s clean, follows Rust standards, and helps developers spot issues fast. Let me handle this. I’ll do it solid and smart!
Thanks,
Manasseh
Can I work on this, please?
I understand that this is a compiler and this issue requires that I implement to display warnings for unused variables when compiling a sway program.
Can I take this from here?
Hello, could I work on this?
Following up on my work on #7042 and #7043, I'd like to continue fixing issues on Sway, please assign me.