]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/redundant_field_names.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / redundant_field_names.rs
index 8a17ab0c9b67229b2d44e618df375a094c58ca74..60569372e5d71af0780a9cd2f77d8a5b4ba3b4ea 100644 (file)
@@ -1,6 +1,20 @@
-#![warn(redundant_field_names)]
+// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![warn(clippy::redundant_field_names)]
 #![allow(unused_variables)]
-#![feature(inclusive_range,inclusive_range_syntax)]
+#![feature(inclusive_range, inclusive_range_fields, inclusive_range_methods)]
+
+#[macro_use]
+extern crate derive_new;
+
+use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive};
 
 mod foo {
     pub const BAR: u8 = 0;
@@ -14,6 +28,11 @@ struct Person {
     foo: u8,
 }
 
+#[derive(new)]
+pub struct S {
+    v: String,
+}
+
 fn main() {
     let gender: u8 = 42;
     let age = 0;
@@ -24,12 +43,12 @@ fn main() {
         gender: gender,
         age: age,
 
-        name, //should be ok
-        buzz: fizz, //should be ok
+        name,          //should be ok
+        buzz: fizz,    //should be ok
         foo: foo::BAR, //should be ok
     };
 
-    // Range syntax
+    // Range expressions
     let (start, end) = (0, 0);
 
     let _ = start..;
@@ -39,10 +58,23 @@ fn main() {
     let _ = ..=end;
     let _ = start..=end;
 
-    // TODO: the following should be linted
-    let _ = ::std::ops::RangeFrom { start: start };
-    let _ = ::std::ops::RangeTo { end: end };
-    let _ = ::std::ops::Range { start: start, end: end };
-    let _ = ::std::ops::RangeInclusive { start: start, end: end };
-    let _ = ::std::ops::RangeToInclusive { end: end };
+    // Issue #2799
+    let _: Vec<_> = (start..end).collect();
+
+    // hand-written Range family structs are linted
+    let _ = RangeFrom { start: start };
+    let _ = RangeTo { end: end };
+    let _ = Range { start: start, end: end };
+    let _ = RangeInclusive::new(start, end);
+    let _ = RangeToInclusive { end: end };
+}
+
+fn issue_3476() {
+    fn foo<T>() {}
+
+    struct S {
+        foo: fn(),
+    }
+
+    S { foo: foo::<i32> };
 }