]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/min_rust_version_attr.rs
Auto merge of #8619 - pitaj:fix-6973, r=giraffate
[rust.git] / tests / ui / min_rust_version_attr.rs
index 0f47f1cbc4026cb77c88eb4e70612e83ba70a60c..f83c3e0e281ca29ccad4714e491feb26a6b18f5e 100644 (file)
@@ -4,6 +4,15 @@
 
 use std::ops::{Deref, RangeFrom};
 
+fn approx_const() {
+    let log2_10 = 3.321928094887362;
+    let log10_2 = 0.301029995663981;
+}
+
+fn cloned_instead_of_copied() {
+    let _ = [1].iter().cloned();
+}
+
 fn option_as_ref_deref() {
     let mut opt = Some(String::from("123"));
 
@@ -90,7 +99,7 @@ pub fn manual_range_contains() {
 }
 
 pub fn use_self() {
-    struct Foo {}
+    struct Foo;
 
     impl Foo {
         fn new() -> Foo {
@@ -123,6 +132,29 @@ fn missing_const_for_fn() -> i32 {
     1
 }
 
+fn unnest_or_patterns() {
+    struct TS(u8, u8);
+    if let TS(0, x) | TS(1, x) = TS(0, 0) {}
+}
+
+#[cfg_attr(rustfmt, rustfmt_skip)]
+fn deprecated_cfg_attr() {}
+
+#[warn(clippy::cast_lossless)]
+fn int_from_bool() -> u8 {
+    true as u8
+}
+
+fn err_expect() {
+    let x: Result<u32, &str> = Ok(10);
+    x.err().expect("Testing expect_err");
+}
+
+fn cast_abs_to_unsigned() {
+    let x: i32 = 10;
+    assert_eq!(10u32, x.abs() as u32);
+}
+
 fn main() {
     filter_map_next();
     checked_conversion();
@@ -138,11 +170,15 @@ fn main() {
     replace_with_default();
     map_unwrap_or();
     missing_const_for_fn();
+    unnest_or_patterns();
+    int_from_bool();
+    err_expect();
+    cast_abs_to_unsigned();
 }
 
-mod meets_msrv {
+mod just_under_msrv {
     #![feature(custom_inner_attributes)]
-    #![clippy::msrv = "1.45.0"]
+    #![clippy::msrv = "1.44.0"]
 
     fn main() {
         let s = "hello, world!";
@@ -152,9 +188,9 @@ fn main() {
     }
 }
 
-mod just_under_msrv {
+mod meets_msrv {
     #![feature(custom_inner_attributes)]
-    #![clippy::msrv = "1.46.0"]
+    #![clippy::msrv = "1.45.0"]
 
     fn main() {
         let s = "hello, world!";
@@ -166,7 +202,7 @@ fn main() {
 
 mod just_above_msrv {
     #![feature(custom_inner_attributes)]
-    #![clippy::msrv = "1.44.0"]
+    #![clippy::msrv = "1.46.0"]
 
     fn main() {
         let s = "hello, world!";