Skip to content

Commit 8c2047f

Browse files
committed
implemented as_conversions lint
1 parent b4f1769 commit 8c2047f

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ Released 2018-09-13
929929
[`absurd_extreme_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
930930
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
931931
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
932+
[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
932933
[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
933934
[`assign_op_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
934935
[`assign_ops`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_ops

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
88

9-
[There are 333 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are 334 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1010

1111
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
1212

clippy_lints/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ mod utils;
156156
// begin lints modules, do not remove this comment, it’s used in `update_lints`
157157
pub mod approx_const;
158158
pub mod arithmetic;
159+
pub mod as_conversions;
159160
pub mod assertions_on_constants;
160161
pub mod assign_ops;
161162
pub mod attrs;
@@ -447,6 +448,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
447448
&approx_const::APPROX_CONSTANT,
448449
&arithmetic::FLOAT_ARITHMETIC,
449450
&arithmetic::INTEGER_ARITHMETIC,
451+
&as_conversions::AS_CONVERSIONS,
450452
&assertions_on_constants::ASSERTIONS_ON_CONSTANTS,
451453
&assign_ops::ASSIGN_OP_PATTERN,
452454
&assign_ops::MISREFACTORED_ASSIGN_OP,
@@ -951,6 +953,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
951953
store.register_late_pass(|| box mutable_debug_assertion::DebugAssertWithMutCall);
952954
store.register_late_pass(|| box exit::Exit);
953955
store.register_late_pass(|| box to_digit_is_some::ToDigitIsSome);
956+
store.register_early_pass(|| box as_conversions::AsConversions);
954957

955958
store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
956959
LintId::of(&arithmetic::FLOAT_ARITHMETIC),
@@ -987,6 +990,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
987990
]);
988991

989992
store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
993+
LintId::of(&as_conversions::AS_CONVERSIONS),
990994
LintId::of(&attrs::INLINE_ALWAYS),
991995
LintId::of(&checked_conversions::CHECKED_CONVERSIONS),
992996
LintId::of(&copies::MATCH_SAME_ARMS),

src/lintlist/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub use lint::Lint;
66
pub use lint::LINT_LEVELS;
77

88
// begin lint list, do not remove this comment, it’s used in `update_lints`
9-
pub const ALL_LINTS: [Lint; 333] = [
9+
pub const ALL_LINTS: [Lint; 334] = [
1010
Lint {
1111
name: "absurd_extreme_comparisons",
1212
group: "correctness",
@@ -28,6 +28,13 @@ pub const ALL_LINTS: [Lint; 333] = [
2828
deprecation: None,
2929
module: "approx_const",
3030
},
31+
Lint {
32+
name: "as_conversions",
33+
group: "pedantic",
34+
desc: "a potentially dangerous silent `as` conversion",
35+
deprecation: None,
36+
module: "as_conversions",
37+
},
3138
Lint {
3239
name: "assertions_on_constants",
3340
group: "style",

tests/ui/types.fixed

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

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

66
// should not warn on lossy casting in constant types
77
// because not supported yet

tests/ui/types.rs

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

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

66
// should not warn on lossy casting in constant types
77
// because not supported yet

0 commit comments

Comments
 (0)