2016-03-07 16:31:38 +01:00
|
|
|
#![feature(plugin, box_syntax, inclusive_range_syntax)]
|
2017-09-18 12:47:33 +02:00
|
|
|
|
2015-10-28 17:50:00 +01:00
|
|
|
|
2017-05-17 14:19:44 +02:00
|
|
|
#![warn(no_effect, unnecessary_operation)]
|
2015-10-28 17:50:00 +01:00
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(path_statements)]
|
2016-11-22 19:22:37 +01:00
|
|
|
#![allow(deref_addrof)]
|
2018-02-10 21:13:17 +01:00
|
|
|
#![allow(redundant_field_names)]
|
2016-09-04 17:39:48 +02:00
|
|
|
#![feature(untagged_unions)]
|
2015-10-28 17:50:00 +01:00
|
|
|
|
|
|
|
struct Unit;
|
|
|
|
struct Tuple(i32);
|
|
|
|
struct Struct {
|
|
|
|
field: i32
|
|
|
|
}
|
|
|
|
enum Enum {
|
2016-02-01 12:51:33 +01:00
|
|
|
Tuple(i32),
|
|
|
|
Struct { field: i32 },
|
2015-10-28 17:50:00 +01:00
|
|
|
}
|
2017-09-18 21:07:33 +02:00
|
|
|
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) {}
|
|
|
|
}
|
2017-10-08 00:32:09 +02:00
|
|
|
struct FooString {
|
|
|
|
s: String,
|
|
|
|
}
|
2016-08-28 19:43:55 +02:00
|
|
|
union Union {
|
|
|
|
a: u8,
|
|
|
|
b: f64,
|
|
|
|
}
|
|
|
|
|
2015-10-28 17:50:00 +01:00
|
|
|
fn get_number() -> i32 { 0 }
|
|
|
|
fn get_struct() -> Struct { Struct { field: 0 } }
|
2017-09-18 21:07:33 +02:00
|
|
|
fn get_drop_struct() -> DropStruct { DropStruct { field: 0 } }
|
2015-10-28 17:50:00 +01:00
|
|
|
|
2016-05-25 18:51:35 +02:00
|
|
|
unsafe fn unsafe_fn() -> i32 { 0 }
|
|
|
|
|
2015-10-28 17:50:00 +01:00
|
|
|
fn main() {
|
|
|
|
let s = get_struct();
|
2016-02-11 13:50:41 +01:00
|
|
|
let s2 = get_struct();
|
2015-10-28 17:50:00 +01:00
|
|
|
|
2017-02-08 14:58:07 +01:00
|
|
|
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;
|
2017-09-28 19:40:19 +02:00
|
|
|
5..=6;
|
2017-02-08 14:58:07 +01:00
|
|
|
[42, 55];
|
|
|
|
[42, 55][1];
|
|
|
|
(42, 55).1;
|
|
|
|
[42; 55];
|
|
|
|
[42; 55][13];
|
2016-02-11 13:50:41 +01:00
|
|
|
let mut x = 0;
|
2017-02-08 14:58:07 +01:00
|
|
|
|| x += 5;
|
2017-10-08 00:32:09 +02:00
|
|
|
let s: String = "foo".into();
|
|
|
|
FooString { s: s };
|
2015-10-28 17:50:00 +01:00
|
|
|
|
|
|
|
// Do not warn
|
|
|
|
get_number();
|
2016-05-25 18:51:35 +02:00
|
|
|
unsafe { unsafe_fn() };
|
2017-09-18 21:07:33 +02:00
|
|
|
DropUnit;
|
|
|
|
DropStruct { field: 0 };
|
|
|
|
DropTuple(0);
|
|
|
|
DropEnum::Tuple(0);
|
|
|
|
DropEnum::Struct { field: 0 };
|
2016-05-13 16:43:47 +02:00
|
|
|
|
2017-02-08 14:58:07 +01:00
|
|
|
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());
|
|
|
|
box get_number();
|
|
|
|
get_number()..;
|
|
|
|
..get_number();
|
|
|
|
5..get_number();
|
|
|
|
[42, get_number()];
|
|
|
|
[42, 55][get_number() as usize];
|
|
|
|
(42, get_number()).1;
|
|
|
|
[get_number(); 55];
|
|
|
|
[42; 55][get_number() as usize];
|
|
|
|
{get_number()};
|
2017-10-08 00:32:09 +02:00
|
|
|
FooString { s: String::from("blah"), };
|
2017-09-18 21:07:33 +02: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() };
|
2015-10-28 17:50:00 +01:00
|
|
|
}
|