]> 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 3848bca3207596fd6d16901b5a425e109a88f093..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"));
 
@@ -57,6 +66,14 @@ pub fn checked_conversion() {
     let _ = value <= (u32::MAX as i64) && value >= 0;
 }
 
+pub struct FromOverInto(String);
+
+impl Into<FromOverInto> for String {
+    fn into(self) -> FromOverInto {
+        FromOverInto(self)
+    }
+}
+
 pub fn filter_map_next() {
     let a = ["1", "lol", "3", "NaN", "5"];
 
@@ -82,7 +99,7 @@ pub fn manual_range_contains() {
 }
 
 pub fn use_self() {
-    struct Foo {}
+    struct Foo;
 
     impl Foo {
         fn new() -> Foo {
@@ -115,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();
@@ -130,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!";
@@ -144,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!";
@@ -158,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!";