Skip to content

Commit c99b67c

Browse files
authored
Merge pull request #1999 from sunfishcode/master
Enable the cast_lossless warning by default.
2 parents 6bc7893 + 1ea7011 commit c99b67c

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ name
198198
[box_vec](https://github.com/rust-lang-nursery/rust-clippy/wiki#box_vec) | warn | usage of `Box<Vec<T>>`, vector elements are already on the heap
199199
[boxed_local](https://github.com/rust-lang-nursery/rust-clippy/wiki#boxed_local) | warn | using `Box<T>` where unnecessary
200200
[builtin_type_shadow](https://github.com/rust-lang-nursery/rust-clippy/wiki#builtin_type_shadow) | warn | shadowing a builtin type
201-
[cast_lossless](https://github.com/rust-lang-nursery/rust-clippy/wiki#cast_lossless) | allow | casts using `as` that are known to be lossless, e.g. `x as u64` where `x: u8`
201+
[cast_lossless](https://github.com/rust-lang-nursery/rust-clippy/wiki#cast_lossless) | warn | casts using `as` that are known to be lossless, e.g. `x as u64` where `x: u8`
202202
[cast_possible_truncation](https://github.com/rust-lang-nursery/rust-clippy/wiki#cast_possible_truncation) | allow | casts that may cause truncation of the value, e.g. `x as u8` where `x: u32`, or `x as i32` where `x: f32`
203203
[cast_possible_wrap](https://github.com/rust-lang-nursery/rust-clippy/wiki#cast_possible_wrap) | allow | casts that may cause wrapping around the value, e.g. `x as i32` where `x: u32` and `x > i32::MAX`
204204
[cast_precision_loss](https://github.com/rust-lang-nursery/rust-clippy/wiki#cast_precision_loss) | allow | casts that cause loss of precision, e.g. `x as f32` where `x: u64`

clippy_lints/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
358358
shadow::SHADOW_UNRELATED,
359359
strings::STRING_ADD,
360360
strings::STRING_ADD_ASSIGN,
361-
types::CAST_LOSSLESS,
362361
types::CAST_POSSIBLE_TRUNCATION,
363362
types::CAST_POSSIBLE_WRAP,
364363
types::CAST_PRECISION_LOSS,
@@ -530,6 +529,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
530529
types::ABSURD_EXTREME_COMPARISONS,
531530
types::BORROWED_BOX,
532531
types::BOX_VEC,
532+
types::CAST_LOSSLESS,
533533
types::CHAR_LIT_AS_U8,
534534
types::LET_UNIT_VALUE,
535535
types::LINKEDLIST,

clippy_lints/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ declare_lint! {
499499
/// ```
500500
declare_lint! {
501501
pub CAST_LOSSLESS,
502-
Allow,
502+
Warn,
503503
"casts using `as` that are known to be lossless, e.g. `x as u64` where `x: u8`"
504504
}
505505

tests/ui/absurd-extreme-comparisons.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ pub struct U(u64);
3838

3939
impl PartialEq<u32> for U {
4040
fn eq(&self, other: &u32) -> bool {
41-
self.eq(&U(*other as u64))
41+
self.eq(&U(u64::from(*other)))
4242
}
4343
}
4444
impl PartialOrd<u32> for U {
4545
fn partial_cmp(&self, other: &u32) -> Option<Ordering> {
46-
self.partial_cmp(&U(*other as u64))
46+
self.partial_cmp(&U(u64::from(*other)))
4747
}
4848
}
4949

tests/ui/float_cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![plugin(clippy)]
33

44
#![warn(float_cmp)]
5-
#![allow(unused, no_effect, unnecessary_operation)]
5+
#![allow(unused, no_effect, unnecessary_operation, cast_lossless)]
66

77
use std::ops::Add;
88

tests/ui/invalid_upcast_comparisons.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![plugin(clippy)]
33

44
#![warn(invalid_upcast_comparisons)]
5-
#![allow(unused, eq_op, no_effect, unnecessary_operation)]
5+
#![allow(unused, eq_op, no_effect, unnecessary_operation, cast_lossless)]
66

77
fn mk_value<T>() -> T { unimplemented!() }
88

0 commit comments

Comments
 (0)