Skip to content

Commit 6f1f413

Browse files
committed
Changes cast-lossless to a pedantic lint
Fixes #4528
1 parent 535bc1d commit 6f1f413

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,
@@ -890,7 +891,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
890891
types::ABSURD_EXTREME_COMPARISONS,
891892
types::BORROWED_BOX,
892893
types::BOX_VEC,
893-
types::CAST_LOSSLESS,
894894
types::CAST_PTR_ALIGNMENT,
895895
types::CAST_REF_TO_MUT,
896896
types::CHAR_LIT_AS_U8,
@@ -1072,7 +1072,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
10721072
transmute::TRANSMUTE_PTR_TO_REF,
10731073
transmute::USELESS_TRANSMUTE,
10741074
types::BORROWED_BOX,
1075-
types::CAST_LOSSLESS,
10761075
types::CHAR_LIT_AS_U8,
10771076
types::OPTION_OPTION,
10781077
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; 313] = [
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)