-// 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.
-
-#![feature(box_syntax)]
-#![warn(clippy::no_effect)]
+#![feature(box_syntax, fn_traits, unboxed_closures)]
+#![warn(clippy::no_effect_underscore_binding)]
#![allow(dead_code)]
#![allow(path_statements)]
#![allow(clippy::deref_addrof)]
0
}
-struct A(i32);
-struct B {
- field: i32,
+struct GreetStruct1;
+
+impl FnOnce<(&str,)> for GreetStruct1 {
+ type Output = ();
+
+ extern "rust-call" fn call_once(self, (who,): (&str,)) -> Self::Output {
+ println!("hello {}", who);
+ }
}
-struct C {
- b: B,
+
+struct GreetStruct2();
+
+impl FnOnce<(&str,)> for GreetStruct2 {
+ type Output = ();
+
+ extern "rust-call" fn call_once(self, (who,): (&str,)) -> Self::Output {
+ println!("hello {}", who);
+ }
}
-struct D {
- arr: [i32; 1],
+
+struct GreetStruct3 {}
+
+impl FnOnce<(&str,)> for GreetStruct3 {
+ type Output = ();
+
+ extern "rust-call" fn call_once(self, (who,): (&str,)) -> Self::Output {
+ println!("hello {}", who);
+ }
}
-const A_CONST: A = A(1);
-const B: B = B { field: 1 };
-const C: C = C { b: B { field: 1 } };
-const D: D = D { arr: [1] };
fn main() {
let s = get_struct();
|| x += 5;
let s: String = "foo".into();
FooString { s: s };
- A_CONST.0 = 2;
- B.field = 2;
- C.b.field = 2;
- D.arr[0] = 2;
+ let _unused = 1;
+ let _penguin = || println!("Some helpful closure");
+ let _duck = Struct { field: 0 };
+ let _cat = [2, 4, 6, 8][2];
+
+ #[allow(clippy::no_effect)]
+ 0;
// Do not warn
get_number();
unsafe { unsafe_fn() };
+ let _used = get_struct();
+ let _x = vec![1];
DropUnit;
DropStruct { field: 0 };
DropTuple(0);
DropEnum::Tuple(0);
DropEnum::Struct { field: 0 };
- let mut a_mut = A(1);
- a_mut.0 = 2;
- let mut b_mut = B { field: 1 };
- b_mut.field = 2;
- let mut c_mut = C { b: B { field: 1 } };
- c_mut.b.field = 2;
- let mut d_mut = D { arr: [1] };
- d_mut.arr[0] = 2;
+ GreetStruct1("world");
+ GreetStruct2()("world");
+ GreetStruct3 {}("world");
}