Skip to content

Commit 4647e7a

Browse files
committed
implemented as_conversions lint
1 parent cc35165 commit 4647e7a

File tree

6 files changed

+18
-2
lines changed

6 files changed

+18
-2
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

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

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

9+
<<<<<<< HEAD
910
[There are 337 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
11+
=======
12+
[There are 334 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
13+
>>>>>>> implemented `as_conversions` lint
1014
1115
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
1216

clippy_lints/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ mod utils;
155155
// begin lints modules, do not remove this comment, it’s used in `update_lints`
156156
pub mod approx_const;
157157
pub mod arithmetic;
158+
pub mod as_conversions;
158159
pub mod assertions_on_constants;
159160
pub mod assign_ops;
160161
pub mod attrs;
@@ -448,6 +449,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
448449
&approx_const::APPROX_CONSTANT,
449450
&arithmetic::FLOAT_ARITHMETIC,
450451
&arithmetic::INTEGER_ARITHMETIC,
452+
&as_conversions::AS_CONVERSIONS,
451453
&assertions_on_constants::ASSERTIONS_ON_CONSTANTS,
452454
&assign_ops::ASSIGN_OP_PATTERN,
453455
&assign_ops::MISREFACTORED_ASSIGN_OP,
@@ -959,6 +961,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
959961
store.register_late_pass(|| box to_digit_is_some::ToDigitIsSome);
960962
let array_size_threshold = conf.array_size_threshold;
961963
store.register_late_pass(move || box large_stack_arrays::LargeStackArrays::new(array_size_threshold));
964+
store.register_early_pass(|| box as_conversions::AsConversions);
962965

963966
store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
964967
LintId::of(&arithmetic::FLOAT_ARITHMETIC),
@@ -995,6 +998,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
995998
]);
996999

9971000
store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
1001+
LintId::of(&as_conversions::AS_CONVERSIONS),
9981002
LintId::of(&attrs::INLINE_ALWAYS),
9991003
LintId::of(&checked_conversions::CHECKED_CONVERSIONS),
10001004
LintId::of(&copies::MATCH_SAME_ARMS),

src/lintlist/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ pub const ALL_LINTS: [Lint; 337] = [
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)