RS.CLIPPY.CONST_IS_EMPTY

Is_empty() called on strings known at compile time

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: const_is_empty. Copyright ©2025 The Rust Team. All rights reserved.

What it does

It identifies calls to .is_empty() on constant values.

Why is this bad?

String literals and constant values are known at compile time. Checking if they are empty will always return the same value. This might not be the intention of the expression.

Example

let value = "";
if value.is_empty() {
    println!("the string is empty");
}

Use instead:

println!("the string is empty");