mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
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.
This commit is contained in:
commit
f08f171530
@ -667,6 +667,7 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
|
|||||||
shadow::SHADOW_UNRELATED,
|
shadow::SHADOW_UNRELATED,
|
||||||
strings::STRING_ADD_ASSIGN,
|
strings::STRING_ADD_ASSIGN,
|
||||||
trait_bounds::TYPE_REPETITION_IN_BOUNDS,
|
trait_bounds::TYPE_REPETITION_IN_BOUNDS,
|
||||||
|
types::CAST_LOSSLESS,
|
||||||
types::CAST_POSSIBLE_TRUNCATION,
|
types::CAST_POSSIBLE_TRUNCATION,
|
||||||
types::CAST_POSSIBLE_WRAP,
|
types::CAST_POSSIBLE_WRAP,
|
||||||
types::CAST_PRECISION_LOSS,
|
types::CAST_PRECISION_LOSS,
|
||||||
@ -891,7 +892,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
|
|||||||
types::ABSURD_EXTREME_COMPARISONS,
|
types::ABSURD_EXTREME_COMPARISONS,
|
||||||
types::BORROWED_BOX,
|
types::BORROWED_BOX,
|
||||||
types::BOX_VEC,
|
types::BOX_VEC,
|
||||||
types::CAST_LOSSLESS,
|
|
||||||
types::CAST_PTR_ALIGNMENT,
|
types::CAST_PTR_ALIGNMENT,
|
||||||
types::CAST_REF_TO_MUT,
|
types::CAST_REF_TO_MUT,
|
||||||
types::CHAR_LIT_AS_U8,
|
types::CHAR_LIT_AS_U8,
|
||||||
@ -1074,7 +1074,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
|
|||||||
transmute::TRANSMUTE_PTR_TO_REF,
|
transmute::TRANSMUTE_PTR_TO_REF,
|
||||||
transmute::USELESS_TRANSMUTE,
|
transmute::USELESS_TRANSMUTE,
|
||||||
types::BORROWED_BOX,
|
types::BORROWED_BOX,
|
||||||
types::CAST_LOSSLESS,
|
|
||||||
types::CHAR_LIT_AS_U8,
|
types::CHAR_LIT_AS_U8,
|
||||||
types::OPTION_OPTION,
|
types::OPTION_OPTION,
|
||||||
types::TYPE_COMPLEXITY,
|
types::TYPE_COMPLEXITY,
|
||||||
|
@ -765,7 +765,7 @@ declare_clippy_lint! {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub CAST_LOSSLESS,
|
pub CAST_LOSSLESS,
|
||||||
complexity,
|
pedantic,
|
||||||
"casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`"
|
"casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ pub const ALL_LINTS: [Lint; 314] = [
|
|||||||
},
|
},
|
||||||
Lint {
|
Lint {
|
||||||
name: "cast_lossless",
|
name: "cast_lossless",
|
||||||
group: "complexity",
|
group: "pedantic",
|
||||||
desc: "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`",
|
desc: "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`",
|
||||||
deprecation: None,
|
deprecation: None,
|
||||||
module: "types",
|
module: "types",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// run-rustfix
|
// run-rustfix
|
||||||
|
|
||||||
#![allow(dead_code, unused_variables)]
|
#![allow(dead_code, unused_variables)]
|
||||||
|
#![warn(clippy::all, clippy::pedantic)]
|
||||||
|
|
||||||
// should not warn on lossy casting in constant types
|
// should not warn on lossy casting in constant types
|
||||||
// because not supported yet
|
// because not supported yet
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// run-rustfix
|
// run-rustfix
|
||||||
|
|
||||||
#![allow(dead_code, unused_variables)]
|
#![allow(dead_code, unused_variables)]
|
||||||
|
#![warn(clippy::all, clippy::pedantic)]
|
||||||
|
|
||||||
// should not warn on lossy casting in constant types
|
// should not warn on lossy casting in constant types
|
||||||
// because not supported yet
|
// because not supported yet
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: casting i32 to i64 may become silently lossy if you later change the type
|
error: casting i32 to i64 may become silently lossy if you later change the type
|
||||||
--> $DIR/types.rs:13:22
|
--> $DIR/types.rs:14:22
|
||||||
|
|
|
|
||||||
LL | let c_i64: i64 = c as i64;
|
LL | let c_i64: i64 = c as i64;
|
||||||
| ^^^^^^^^ help: try: `i64::from(c)`
|
| ^^^^^^^^ help: try: `i64::from(c)`
|
||||||
|
Loading…
Reference in New Issue
Block a user