2023-09-13 13:58:47 -05:00
|
|
|
//@aux-build:proc_macros.rs
|
2019-01-13 11:48:54 -06:00
|
|
|
#![warn(clippy::redundant_field_names)]
|
2023-02-10 07:01:19 -06:00
|
|
|
#![allow(clippy::extra_unused_type_parameters, clippy::no_effect, dead_code, unused_variables)]
|
2019-01-13 11:48:54 -06:00
|
|
|
|
|
|
|
#[macro_use]
|
2023-09-13 13:58:47 -05:00
|
|
|
extern crate proc_macros;
|
2019-01-13 11:48:54 -06:00
|
|
|
|
|
|
|
use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive};
|
|
|
|
|
|
|
|
mod foo {
|
|
|
|
pub const BAR: u8 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Person {
|
|
|
|
gender: u8,
|
|
|
|
age: u8,
|
|
|
|
name: u8,
|
|
|
|
buzz: u64,
|
|
|
|
foo: u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct S {
|
2024-03-07 06:19:33 -06:00
|
|
|
v: usize,
|
2019-01-13 11:48:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let gender: u8 = 42;
|
|
|
|
let age = 0;
|
|
|
|
let fizz: u64 = 0;
|
|
|
|
let name: u8 = 0;
|
|
|
|
|
|
|
|
let me = Person {
|
|
|
|
gender,
|
|
|
|
age,
|
|
|
|
|
|
|
|
name, //should be ok
|
|
|
|
buzz: fizz, //should be ok
|
|
|
|
foo: foo::BAR, //should be ok
|
|
|
|
};
|
|
|
|
|
|
|
|
// Range expressions
|
|
|
|
let (start, end) = (0, 0);
|
|
|
|
|
|
|
|
let _ = start..;
|
|
|
|
let _ = ..end;
|
|
|
|
let _ = start..end;
|
|
|
|
|
|
|
|
let _ = ..=end;
|
|
|
|
let _ = start..=end;
|
|
|
|
|
|
|
|
// Issue #2799
|
|
|
|
let _: Vec<_> = (start..end).collect();
|
|
|
|
|
|
|
|
// hand-written Range family structs are linted
|
|
|
|
let _ = RangeFrom { start };
|
|
|
|
let _ = RangeTo { end };
|
|
|
|
let _ = Range { start, end };
|
|
|
|
let _ = RangeInclusive::new(start, end);
|
|
|
|
let _ = RangeToInclusive { end };
|
2023-09-13 13:58:47 -05:00
|
|
|
|
|
|
|
external! {
|
2024-03-07 06:19:33 -06:00
|
|
|
let v = 1;
|
2023-09-13 13:58:47 -05:00
|
|
|
let _ = S {
|
|
|
|
v: v
|
|
|
|
};
|
|
|
|
}
|
2024-03-07 06:19:33 -06:00
|
|
|
|
|
|
|
let v = 2;
|
|
|
|
macro_rules! internal {
|
|
|
|
($i:ident) => {
|
|
|
|
let _ = S { v };
|
|
|
|
let _ = S { $i: v };
|
|
|
|
let _ = S { v: $i };
|
|
|
|
let _ = S { $i: $i };
|
|
|
|
};
|
|
|
|
}
|
|
|
|
internal!(v);
|
2019-01-13 11:48:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn issue_3476() {
|
|
|
|
fn foo<T>() {}
|
|
|
|
|
|
|
|
struct S {
|
|
|
|
foo: fn(),
|
|
|
|
}
|
|
|
|
|
|
|
|
S { foo: foo::<i32> };
|
|
|
|
}
|
2022-10-23 08:18:45 -05:00
|
|
|
|
2022-12-01 11:29:38 -06:00
|
|
|
#[clippy::msrv = "1.16"]
|
2022-10-23 08:18:45 -05:00
|
|
|
fn msrv_1_16() {
|
|
|
|
let start = 0;
|
|
|
|
let _ = RangeFrom { start: start };
|
|
|
|
}
|
|
|
|
|
2022-12-01 11:29:38 -06:00
|
|
|
#[clippy::msrv = "1.17"]
|
2022-10-23 08:18:45 -05:00
|
|
|
fn msrv_1_17() {
|
|
|
|
let start = 0;
|
|
|
|
let _ = RangeFrom { start };
|
|
|
|
}
|