2019-01-13 18:48:54 +01:00
|
|
|
// run-rustfix
|
2018-07-28 17:34:52 +02:00
|
|
|
#![warn(clippy::redundant_field_names)]
|
2019-01-13 18:48:54 +01:00
|
|
|
#![allow(clippy::no_effect, dead_code, unused_variables)]
|
2018-03-05 09:30:07 +01:00
|
|
|
|
2018-03-11 05:57:28 +01:00
|
|
|
#[macro_use]
|
|
|
|
extern crate derive_new;
|
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive};
|
2018-02-10 21:13:17 +01:00
|
|
|
|
|
|
|
mod foo {
|
|
|
|
pub const BAR: u8 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Person {
|
|
|
|
gender: u8,
|
|
|
|
age: u8,
|
2018-02-11 10:50:19 +01:00
|
|
|
name: u8,
|
2018-02-10 21:13:17 +01:00
|
|
|
buzz: u64,
|
|
|
|
foo: u8,
|
|
|
|
}
|
|
|
|
|
2018-03-11 05:57:28 +01:00
|
|
|
#[derive(new)]
|
|
|
|
pub struct S {
|
|
|
|
v: String,
|
|
|
|
}
|
|
|
|
|
2018-02-10 21:13:17 +01:00
|
|
|
fn main() {
|
|
|
|
let gender: u8 = 42;
|
|
|
|
let age = 0;
|
|
|
|
let fizz: u64 = 0;
|
2018-02-11 10:50:19 +01:00
|
|
|
let name: u8 = 0;
|
2018-02-10 21:13:17 +01:00
|
|
|
|
|
|
|
let me = Person {
|
|
|
|
gender: gender,
|
|
|
|
age: age,
|
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
name, //should be ok
|
|
|
|
buzz: fizz, //should be ok
|
2018-02-10 21:13:17 +01:00
|
|
|
foo: foo::BAR, //should be ok
|
|
|
|
};
|
2018-03-05 06:31:37 +01:00
|
|
|
|
2018-03-05 09:30:07 +01:00
|
|
|
// Range expressions
|
2018-03-05 06:31:37 +01:00
|
|
|
let (start, end) = (0, 0);
|
|
|
|
|
|
|
|
let _ = start..;
|
|
|
|
let _ = ..end;
|
|
|
|
let _ = start..end;
|
|
|
|
|
|
|
|
let _ = ..=end;
|
|
|
|
let _ = start..=end;
|
|
|
|
|
2018-08-14 07:27:56 +02:00
|
|
|
// Issue #2799
|
|
|
|
let _: Vec<_> = (start..end).collect();
|
|
|
|
|
2018-03-05 09:30:07 +01:00
|
|
|
// hand-written Range family structs are linted
|
|
|
|
let _ = RangeFrom { start: start };
|
|
|
|
let _ = RangeTo { end: end };
|
|
|
|
let _ = Range { start: start, end: end };
|
2018-05-03 15:52:44 +02:00
|
|
|
let _ = RangeInclusive::new(start, end);
|
2018-03-05 09:30:07 +01:00
|
|
|
let _ = RangeToInclusive { end: end };
|
2018-02-10 21:13:17 +01:00
|
|
|
}
|
2018-12-11 15:33:23 +01:00
|
|
|
|
|
|
|
fn issue_3476() {
|
2018-12-27 16:17:45 +01:00
|
|
|
fn foo<T>() {}
|
2018-12-11 15:33:23 +01:00
|
|
|
|
|
|
|
struct S {
|
|
|
|
foo: fn(),
|
|
|
|
}
|
|
|
|
|
|
|
|
S { foo: foo::<i32> };
|
|
|
|
}
|