mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 01:17:16 +00:00
b0edbca0e6
Add a lint to detect cast to unsigned for abs() and suggest unsigned_abs() to avoid panic when called on MIN.
37 lines
1.2 KiB
Text
37 lines
1.2 KiB
Text
error: stripping a prefix manually
|
|
--> $DIR/min_rust_version_attr.rs:198:24
|
|
|
|
|
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: `-D clippy::manual-strip` implied by `-D warnings`
|
|
note: the prefix was tested here
|
|
--> $DIR/min_rust_version_attr.rs:197:9
|
|
|
|
|
LL | if s.starts_with("hello, ") {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: try using the `strip_prefix` method
|
|
|
|
|
LL ~ if let Some(<stripped>) = s.strip_prefix("hello, ") {
|
|
LL ~ assert_eq!(<stripped>.to_uppercase(), "WORLD!");
|
|
|
|
|
|
|
error: stripping a prefix manually
|
|
--> $DIR/min_rust_version_attr.rs:210:24
|
|
|
|
|
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: the prefix was tested here
|
|
--> $DIR/min_rust_version_attr.rs:209:9
|
|
|
|
|
LL | if s.starts_with("hello, ") {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: try using the `strip_prefix` method
|
|
|
|
|
LL ~ if let Some(<stripped>) = s.strip_prefix("hello, ") {
|
|
LL ~ assert_eq!(<stripped>.to_uppercase(), "WORLD!");
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|