Rust - dead_code lint Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Rust is a systems programming language that has some unique features which include warning if there are unused variables or unused functions. To do this, the Rust compiler provides the users with a dead code lint which warns us about unused codes, and by the usage of the #[allow(dead_code)], it eliminates any unused variables/functions error. Example 1: Rust // Rust code fn outer_func_one() { println!("this is the first outer function"); } fn outer_func_two(){ println!("this is the second outer function"); } fn main() { outer_func_one(); } Output: Â Explanation: In this example, we have created two functions: outer_func_one() and outer_func_two(). We are calling the outer_func_one from the main method but we never use the outer_func_two. Due to this Rust compiler throws us a warning that the outer_func_two() is never used and suggests we handle warn dead code by default error. Example 2: Rust fn outer_func_one() { println!("this is the first outer function"); } #[allow(dead_code)] fn outer_func_two(){ println!("this is the second outer function"); } fn main() { outer_func_one(); } Output: Â Explanation: Continuing from Example 1, handle the warn dead code by adding #[allow(dead_code)] attribute, the lints are disabled. Comment More infoAdvertise with us Next Article Rust - dead_code lint S sayanc170 Follow Improve Article Tags : Technical Scripter Rust Technical Scripter 2022 Rust functions Similar Reads Dead Code Elimination In software development, optimizing program efficiency and maintaining correct code are crucial goals. Dead code elimination, an essential technique employed by compilers and interpreters, plays a significant role in achieving these objectives. This article explores the concept of dead code eliminat 3 min read Rust - Comments In Rust programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. Comments are statements that are not executed by the compiler and interpreter. To write comments in Rust, we have two types of comments as in any other programming language. No 2 min read Conditionals in Rust Conditional Statements are the decision-making statements based on given conditions. Conditional statements are common in programming languages and rust has them and unlike many of them, the boolean condition doesn't need to be surrounded by parentheses but is better to use, and each condition is fo 3 min read Rust - Constants Constants are the value that can not be changed after assigning them. If we created a constant, then there is no way of changing its value. The keyword for declaring constant is const. In Rust, constants must be explicitly typed. Â The below syntax is used to initialize a constant value: Syntax : con 1 min read Rust - Operator Overloading In Rust, we have a concept of operator overloading. This is generally performed by Traits. For making use of operator overloading, we import core::ops in Rust. Core:: ops is a module in Rust that allows the traits to overload the operators in our code. By default, most of the traits are automaticall 2 min read Like