Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes cast-lossless to a pedantic lint #4539

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
shadow::SHADOW_UNRELATED,
strings::STRING_ADD_ASSIGN,
trait_bounds::TYPE_REPETITION_IN_BOUNDS,
types::CAST_LOSSLESS,
types::CAST_POSSIBLE_TRUNCATION,
types::CAST_POSSIBLE_WRAP,
types::CAST_PRECISION_LOSS,
Expand Down Expand Up @@ -890,7 +891,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
types::ABSURD_EXTREME_COMPARISONS,
types::BORROWED_BOX,
types::BOX_VEC,
types::CAST_LOSSLESS,
types::CAST_PTR_ALIGNMENT,
types::CAST_REF_TO_MUT,
types::CHAR_LIT_AS_U8,
Expand Down Expand Up @@ -1072,7 +1072,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
transmute::TRANSMUTE_PTR_TO_REF,
transmute::USELESS_TRANSMUTE,
types::BORROWED_BOX,
types::CAST_LOSSLESS,
types::CHAR_LIT_AS_U8,
types::OPTION_OPTION,
types::TYPE_COMPLEXITY,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ declare_clippy_lint! {
/// }
/// ```
pub CAST_LOSSLESS,
complexity,
pedantic,
"casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`"
}

Expand Down
2 changes: 1 addition & 1 deletion src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub const ALL_LINTS: [Lint; 313] = [
},
Lint {
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`",
deprecation: None,
module: "types",
Expand Down
1 change: 1 addition & 0 deletions tests/ui/types.fixed
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// run-rustfix

#![allow(dead_code, unused_variables)]
#![warn(clippy::all, clippy::pedantic)]

// should not warn on lossy casting in constant types
// because not supported yet
Expand Down
1 change: 1 addition & 0 deletions tests/ui/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// run-rustfix

#![allow(dead_code, unused_variables)]
#![warn(clippy::all, clippy::pedantic)]

// should not warn on lossy casting in constant types
// because not supported yet
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/types.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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;
| ^^^^^^^^ help: try: `i64::from(c)`
Expand Down