Rust

Rust

Made by DeepSource
Syntax Error RS-E1000
Bug risk
Critical

Encountered a syntax error.

Found explicit self-assignment RS-W1013
Bug risk
Major

Self-assignments are redundant and are unlikely to be intentional. This is probably the result of a copy-paste.

Found .clone() call on a double reference RS-W1100
Bug risk
Major

Calling .clone() clone on a &&T copies the inner &T and not the underlying T.

Found invalid regex RS-E1002
Bug risk
Critical

Encountered invalid regex syntax in Regex::new or RegexBuilder::new. Refer to the occurrence message for more details.

Found trivial or undefined modulus operation RS-W1005
Bug risk
Minor

The remainder of a division by 1 is always 0. On the other hand, the remainder of a division by -1 is may cause panics/overflows if the dividend is the lower bound of its integral type.

Found if block with identical else block RS-W1008
Bug risk
Minor
Autofix

if-else expressions with the same if and else parts are probably a result of a copy-paste. The result of the expression is independent of the condition.

Found consecutive if expressions with the same condition RS-W1009
Bug risk
Minor

Consecutive if statements with the same condition are probably the result of a copy-paste. This checker ignores function calls as they could have side-effects.

Found string literal in env functions RS-W1015
Bug risk
Major

Calls to the std::env functions that use string literals instead of a static strings can lead to bugs due to spelling errors.

Called unwrap on option_env! macro RS-W1016
Bug risk
Major

Unwrapping the result of the option_env! macro will panic at runtime if the environment variable does not exist. The env! macro catches this at compile time.

Found builtin-type shadow RS-W1028
Bug risk
Major

Generic type parameters or pattern captures that have the same name as certain builtin-types can cause unexpected errors.

Usage of fs::create_dir RS-W1032
Bug risk
Minor

fs::create_dir_all is preferable over fs::create_dir as it creates all missing components in the provided path without erroring out.

Extending string with another using chars RS-W1095
Bug risk
Minor

Extending one String with another is possible through .extend(s.chars()). However, this is better expressed using push_str(s).

Found comparison with NaN RS-E1012
Bug risk
Major
Autofix

Comparing a floating point with NaN using == or != is redundant. NaN cannot be compared to anything, not even itself. Use .is_nan() instead.

Called mem::forget or mem::drop on a reference RS-E1010
Bug risk
Major

Calling std::mem::forget (or std::mem::drop) on a reference will forget (or drop) the reference itself, which effectively does nothing. The underlying reference value will remain unaffected.

Called mem::forget or mem::drop on a Copy type RS-E1011
Bug risk
Major

For types that implement the Copy trait, std::mem::forget (or std::mem::drop) effectively does nothing because the type is copied into the function call, and the newly copied type is forgotten (or dropped). Additionally, Copy types do not have destructors; there is nothing for std::mem::forget or (or std::mem::drop) to do.

Comparing unit values RS-E1016
Bug risk
Major

The unit value is always equal to itself. Comparisons against the unit value are probably the result of accidental semicolons.

Found potentially incomplete ASCII range RS-W1086
Bug risk
Major
Autofix

Letter ranges can be constructed by using the inclusive or exclusive range operators. However, ranges from 'a' to 'z' (or '1' to '9') constructed with the exclusive range operator exclude the upper bound: 'z' (or '9'), because such ranges are half open.

Found manual approximation of known floating constant RS-W1207
Bug risk
Major

Several mathematical values such as π (pi) or τ (tau) have highly accurate constants defined in the standard library. Consider using these values directly to reduce manual error.

Found occurrence of .step_by(0) RS-E1003
Bug risk
Critical

Calling .step_by(0) on an iterator panics. Consider using panic! if this is intentional.

Iterating over Option type RS-E1004
Bug risk
Critical

Calling .next() on an iterator produces an Option<T>, which also implements IntoIterator. This is probably a mistake, consider revisiting this for loop.