]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/cast.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / cast.rs
index cf85a5ca931dd1e560134cf39304659254af3b43..e6031e9adaeb66c084d8c96cb421d9d5ee186d91 100644 (file)
@@ -1,13 +1,13 @@
 #![feature(repr128)]
 #![allow(incomplete_features)]
-
-#[warn(
+#![warn(
     clippy::cast_precision_loss,
     clippy::cast_possible_truncation,
     clippy::cast_sign_loss,
     clippy::cast_possible_wrap
 )]
-#[allow(clippy::cast_abs_to_unsigned, clippy::no_effect, clippy::unnecessary_operation)]
+#![allow(clippy::cast_abs_to_unsigned, clippy::no_effect, clippy::unnecessary_operation)]
+
 fn main() {
     // Test clippy::cast_precision_loss
     let x0 = 1i32;
@@ -252,3 +252,11 @@ fn test(self) {
         }
     }
 }
+
+fn avoid_subtract_overflow(q: u32) {
+    let c = (q >> 16) as u8;
+    c as usize;
+
+    let c = (q / 1000) as u8;
+    c as usize;
+}