Skip to content

Commit f08f171

Browse files
committed
Auto merge of #4539 - jolson88:cast-lossless-pedantic, r=flip1995
Changes cast-lossless to a pedantic lint As discussed in #4528, this moves the cast-lossless lint from `all` to `pedantic`. I couldn't tell from description alone if it should also be removed from the complexity category, so I left it as part of complexity for now. I didn't see any impact to the tests from this change, but I could be wrong (as this is my first PR). fixes #4528 changelog: Moves cast-lossless from default to checking only as a `pedantic` lint.
2 parents f783ff3 + 6f1f413 commit f08f171

File tree

6 files changed

+6
-5
lines changed

6 files changed

+6
-5
lines changed

clippy_lints/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
667667
shadow::SHADOW_UNRELATED,
668668
strings::STRING_ADD_ASSIGN,
669669
trait_bounds::TYPE_REPETITION_IN_BOUNDS,
670+
types::CAST_LOSSLESS,
670671
types::CAST_POSSIBLE_TRUNCATION,
671672
types::CAST_POSSIBLE_WRAP,
672673
types::CAST_PRECISION_LOSS,
@@ -891,7 +892,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
891892
types::ABSURD_EXTREME_COMPARISONS,
892893
types::BORROWED_BOX,
893894
types::BOX_VEC,
894-
types::CAST_LOSSLESS,
895895
types::CAST_PTR_ALIGNMENT,
896896
types::CAST_REF_TO_MUT,
897897
types::CHAR_LIT_AS_U8,
@@ -1074,7 +1074,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
10741074
transmute::TRANSMUTE_PTR_TO_REF,
10751075
transmute::USELESS_TRANSMUTE,
10761076
types::BORROWED_BOX,
1077-
types::CAST_LOSSLESS,
10781077
types::CHAR_LIT_AS_U8,
10791078
types::OPTION_OPTION,
10801079
types::TYPE_COMPLEXITY,

clippy_lints/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ declare_clippy_lint! {
765765
/// }
766766
/// ```
767767
pub CAST_LOSSLESS,
768-
complexity,
768+
pedantic,
769769
"casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`"
770770
}
771771

src/lintlist/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub const ALL_LINTS: [Lint; 314] = [
121121
},
122122
Lint {
123123
name: "cast_lossless",
124-
group: "complexity",
124+
group: "pedantic",
125125
desc: "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`",
126126
deprecation: None,
127127
module: "types",

tests/ui/types.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-rustfix
22

33
#![allow(dead_code, unused_variables)]
4+
#![warn(clippy::all, clippy::pedantic)]
45

56
// should not warn on lossy casting in constant types
67
// because not supported yet

tests/ui/types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-rustfix
22

33
#![allow(dead_code, unused_variables)]
4+
#![warn(clippy::all, clippy::pedantic)]
45

56
// should not warn on lossy casting in constant types
67
// because not supported yet

tests/ui/types.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: casting i32 to i64 may become silently lossy if you later change the type
2-
--> $DIR/types.rs:13:22
2+
--> $DIR/types.rs:14:22
33
|
44
LL | let c_i64: i64 = c as i64;
55
| ^^^^^^^^ help: try: `i64::from(c)`

0 commit comments

Comments
 (0)