-
Notifications
You must be signed in to change notification settings - Fork 13.3k
/
Copy pathweird-exprs.rs
187 lines (162 loc) · 4.22 KB
/
weird-exprs.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// run-pass
#![feature(generators)]
#![feature(destructuring_assignment)]
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![allow(unreachable_code)]
#![allow(unused_braces, unused_must_use, unused_parens)]
#![recursion_limit = "256"]
use std::cell::Cell;
use std::mem::swap;
// Just a grab bag of stuff that you wouldn't want to actually write.
fn strange() -> bool { let _x: bool = return true; }
fn funny() {
fn f(_x: ()) { }
f(return);
}
fn what() {
fn the(x: &Cell<bool>) {
return while !x.get() { x.set(true); };
}
let i = &Cell::new(false);
let dont = {||the(i)};
dont();
assert!((i.get()));
}
fn zombiejesus() {
loop {
while (return) {
if (return) {
match (return) {
1 => {
if (return) {
return
} else {
return
}
}
_ => { return }
};
} else if (return) {
return;
}
}
if (return) { break; }
}
}
fn notsure() {
let mut _x: isize;
let mut _y = (_x = 0) == (_x = 0);
let mut _z = (_x = 0) < (_x = 0);
let _a = (_x += 0) == (_x = 0);
let _b = swap(&mut _y, &mut _z) == swap(&mut _y, &mut _z);
}
fn canttouchthis() -> usize {
fn p() -> bool { true }
let _a = (assert!((true)) == (assert!(p())));
let _c = (assert!((p())) == ());
let _b: bool = (println!("{}", 0) == (return 0));
}
fn angrydome() {
loop { if break { } }
let mut i = 0;
loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => panic!("wat") } }
break; }
}
fn evil_lincoln() { let _evil = println!("lincoln"); }
fn dots() {
assert_eq!(String::from(".................................................."),
format!("{:?}", .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. ..));
}
fn u8(u8: u8) {
if u8 != 0u8 {
assert_eq!(8u8, {
macro_rules! u8 {
(u8) => {
mod u8 {
pub fn u8<'u8: 'u8 + 'u8>(u8: &'u8 u8) -> &'u8 u8 {
"u8";
u8
}
}
};
}
u8!(u8);
let &u8: &u8 = u8::u8(&8u8);
::u8(0u8);
u8
});
}
}
fn fishy() {
assert_eq!(String::from("><>"),
String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>());
}
fn union() {
union union<'union> { union: &'union union<'union>, }
}
fn special_characters() {
let val = !((|(..):(_,_),__@_|__)((&*"\\",'🤔')/**/,{})=={&[..=..][..];})//
;
assert!(!val);
}
fn punch_card() -> impl std::fmt::Debug {
..=..=.. .. .. .. .. .. .. .. .. .. .. ..=.. ..
..=.. ..=.. .. .. .. .. .. .. .. .. ..=..=..=..
..=.. ..=.. ..=.. ..=.. .. ..=..=.. .. ..=.. ..
..=..=.. .. ..=.. ..=.. ..=.. .. .. .. ..=.. ..
..=.. ..=.. ..=.. ..=.. .. ..=.. .. .. ..=.. ..
..=.. ..=.. ..=.. ..=.. .. .. ..=.. .. ..=.. ..
..=.. ..=.. .. ..=..=.. ..=..=.. .. .. ..=.. ..
}
fn r#match() {
let val = match match match match match () {
() => ()
} {
() => ()
} {
() => ()
} {
() => ()
} {
() => ()
};
assert_eq!(val, ());
}
fn i_yield() {
static || {
yield yield yield yield yield yield yield yield yield;
};
}
fn match_nested_if() {
let val = match () {
() if if if if true {true} else {false} {true} else {false} {true} else {false} => true,
_ => false,
};
assert!(val);
}
fn monkey_barrel() {
let val = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=();
assert_eq!(val, ());
}
pub fn main() {
strange();
funny();
what();
zombiejesus();
notsure();
canttouchthis();
angrydome();
evil_lincoln();
dots();
u8(8u8);
fishy();
union();
special_characters();
punch_card();
r#match();
i_yield();
match_nested_if();
monkey_barrel();
}