-#![feature(plugin, box_syntax, inclusive_range_syntax)]
-#![plugin(clippy)]
-
-#![deny(no_effect, unnecessary_operation)]
+#![feature(box_syntax)]
+#![warn(clippy::no_effect)]
#![allow(dead_code)]
#![allow(path_statements)]
-#![allow(deref_addrof)]
+#![allow(clippy::deref_addrof)]
+#![allow(clippy::redundant_field_names)]
#![feature(untagged_unions)]
struct Unit;
struct Tuple(i32);
struct Struct {
- field: i32
+ field: i32,
}
enum Enum {
Tuple(i32),
Struct { field: i32 },
}
-
+struct DropUnit;
+impl Drop for DropUnit {
+ fn drop(&mut self) {}
+}
+struct DropStruct {
+ field: i32,
+}
+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,
+}
union Union {
a: u8,
b: f64,
}
-fn get_number() -> i32 { 0 }
-fn get_struct() -> Struct { Struct { field: 0 } }
+fn get_number() -> i32 {
+ 0
+}
+fn get_struct() -> Struct {
+ Struct { field: 0 }
+}
+fn get_drop_struct() -> DropStruct {
+ DropStruct { field: 0 }
+}
-unsafe fn unsafe_fn() -> i32 { 0 }
+unsafe fn unsafe_fn() -> i32 {
+ 0
+}
fn main() {
let s = get_struct();
let s2 = get_struct();
- 0; //~ERROR statement with no effect
- s2; //~ERROR statement with no effect
- Unit; //~ERROR statement with no effect
- Tuple(0); //~ERROR statement with no effect
- Struct { field: 0 }; //~ERROR statement with no effect
- Struct { ..s }; //~ERROR statement with no effect
- Union { a: 0 }; //~ERROR statement with no effect
- Enum::Tuple(0); //~ERROR statement with no effect
- Enum::Struct { field: 0 }; //~ERROR statement with no effect
- 5 + 6; //~ERROR statement with no effect
- *&42; //~ERROR statement with no effect
- &6; //~ERROR statement with no effect
- (5, 6, 7); //~ERROR statement with no effect
- box 42; //~ERROR statement with no effect
- ..; //~ERROR statement with no effect
- 5..; //~ERROR statement with no effect
- ..5; //~ERROR statement with no effect
- 5..6; //~ERROR statement with no effect
- 5...6; //~ERROR statement with no effect
- [42, 55]; //~ERROR statement with no effect
- [42, 55][1]; //~ERROR statement with no effect
- (42, 55).1; //~ERROR statement with no effect
- [42; 55]; //~ERROR statement with no effect
- [42; 55][13]; //~ERROR statement with no effect
+ 0;
+ s2;
+ Unit;
+ Tuple(0);
+ Struct { field: 0 };
+ Struct { ..s };
+ Union { a: 0 };
+ Enum::Tuple(0);
+ Enum::Struct { field: 0 };
+ 5 + 6;
+ *&42;
+ &6;
+ (5, 6, 7);
+ box 42;
+ ..;
+ 5..;
+ ..5;
+ 5..6;
+ 5..=6;
+ [42, 55];
+ [42, 55][1];
+ (42, 55).1;
+ [42; 55];
+ [42; 55][13];
let mut x = 0;
- || x += 5; //~ERROR statement with no effect
+ || x += 5;
+ let s: String = "foo".into();
+ FooString { s: s };
// Do not warn
get_number();
unsafe { unsafe_fn() };
-
- Tuple(get_number()); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- Struct { field: get_number() }; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- Struct { ..get_struct() }; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_struct();
- Enum::Tuple(get_number()); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- Enum::Struct { field: get_number() }; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- 5 + get_number(); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION 5;get_number();
- *&get_number(); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- &get_number(); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- (5, 6, get_number()); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION 5;6;get_number();
- box get_number(); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- get_number()..; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- ..get_number(); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- 5..get_number(); //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION 5;get_number();
- [42, get_number()]; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION 42;get_number();
- [42, 55][get_number() as usize]; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION [42, 55];get_number() as usize;
- (42, get_number()).1; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION 42;get_number();
- [get_number(); 55]; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
- [42; 55][get_number() as usize]; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION [42; 55];get_number() as usize;
- {get_number()}; //~ERROR statement can be reduced
- //~^HELP replace it with
- //~|SUGGESTION get_number();
+ DropUnit;
+ DropStruct { field: 0 };
+ DropTuple(0);
+ DropEnum::Tuple(0);
+ DropEnum::Struct { field: 0 };
}