2023-04-23 06:03:09 -05:00
|
|
|
//@run-rustfix
|
2019-09-25 12:49:56 -05:00
|
|
|
|
2023-03-24 08:04:35 -05:00
|
|
|
#![allow(
|
|
|
|
clippy::deref_addrof,
|
|
|
|
dead_code,
|
|
|
|
unused,
|
|
|
|
clippy::no_effect,
|
|
|
|
clippy::unnecessary_struct_initialization
|
|
|
|
)]
|
2018-10-27 12:31:47 -05:00
|
|
|
#![warn(clippy::unnecessary_operation)]
|
|
|
|
|
|
|
|
struct Tuple(i32);
|
|
|
|
struct Struct {
|
2018-12-09 16:26:16 -06:00
|
|
|
field: i32,
|
2018-10-27 12:31:47 -05:00
|
|
|
}
|
|
|
|
enum Enum {
|
|
|
|
Tuple(i32),
|
|
|
|
Struct { field: i32 },
|
|
|
|
}
|
|
|
|
struct DropStruct {
|
2018-12-09 16:26:16 -06:00
|
|
|
field: i32,
|
2018-10-27 12:31:47 -05:00
|
|
|
}
|
|
|
|
impl Drop for DropStruct {
|
|
|
|
fn drop(&mut self) {}
|
|
|
|
}
|
|
|
|
struct DropTuple(i32);
|
|
|
|
impl Drop for DropTuple {
|
|
|
|
fn drop(&mut self) {}
|
|
|
|
}
|
|
|
|
enum DropEnum {
|
|
|
|
Tuple(i32),
|
|
|
|
Struct { field: i32 },
|
|
|
|
}
|
|
|
|
impl Drop for DropEnum {
|
|
|
|
fn drop(&mut self) {}
|
|
|
|
}
|
|
|
|
struct FooString {
|
|
|
|
s: String,
|
|
|
|
}
|
|
|
|
|
2018-12-09 16:26:16 -06:00
|
|
|
fn get_number() -> i32 {
|
|
|
|
0
|
|
|
|
}
|
2019-09-25 12:49:56 -05:00
|
|
|
|
|
|
|
fn get_usize() -> usize {
|
|
|
|
0
|
|
|
|
}
|
2018-12-09 16:26:16 -06:00
|
|
|
fn get_struct() -> Struct {
|
|
|
|
Struct { field: 0 }
|
|
|
|
}
|
|
|
|
fn get_drop_struct() -> DropStruct {
|
|
|
|
DropStruct { field: 0 }
|
|
|
|
}
|
2018-10-27 12:31:47 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
Tuple(get_number());
|
|
|
|
Struct { field: get_number() };
|
|
|
|
Struct { ..get_struct() };
|
|
|
|
Enum::Tuple(get_number());
|
|
|
|
Enum::Struct { field: get_number() };
|
|
|
|
5 + get_number();
|
|
|
|
*&get_number();
|
|
|
|
&get_number();
|
|
|
|
(5, 6, get_number());
|
|
|
|
get_number()..;
|
|
|
|
..get_number();
|
|
|
|
5..get_number();
|
|
|
|
[42, get_number()];
|
2019-09-25 12:49:56 -05:00
|
|
|
[42, 55][get_usize()];
|
2018-10-27 12:31:47 -05:00
|
|
|
(42, get_number()).1;
|
|
|
|
[get_number(); 55];
|
2019-09-25 12:49:56 -05:00
|
|
|
[42; 55][get_usize()];
|
2018-12-09 16:26:16 -06:00
|
|
|
{
|
|
|
|
get_number()
|
|
|
|
};
|
|
|
|
FooString {
|
|
|
|
s: String::from("blah"),
|
|
|
|
};
|
2018-10-27 12:31:47 -05:00
|
|
|
|
|
|
|
// Do not warn
|
|
|
|
DropTuple(get_number());
|
|
|
|
DropStruct { field: get_number() };
|
|
|
|
DropStruct { field: get_number() };
|
|
|
|
DropStruct { ..get_drop_struct() };
|
|
|
|
DropEnum::Tuple(get_number());
|
|
|
|
DropEnum::Struct { field: get_number() };
|
2022-12-01 11:29:38 -06:00
|
|
|
|
|
|
|
// Issue #9954
|
|
|
|
fn one() -> i8 {
|
|
|
|
1
|
|
|
|
}
|
|
|
|
macro_rules! use_expr {
|
|
|
|
($($e:expr),*) => {{ $($e;)* }}
|
|
|
|
}
|
|
|
|
use_expr!(isize::MIN / -(one() as isize), i8::MIN / -one());
|
2018-10-27 12:31:47 -05:00
|
|
|
}
|