]>
Commit | Line | Data |
---|---|---|
0bf4aa26 XL |
1 | #![allow(non_camel_case_types)] |
2 | #![allow(dead_code)] | |
3 | #![allow(unreachable_code)] | |
4 | #![allow(unused_parens)] | |
ff7c6d11 | 5 | // compile-flags: -Z borrowck=compare |
1a4d82fc | 6 | |
8faf50e0 XL |
7 | #![recursion_limit = "128"] |
8 | ||
1a4d82fc JJ |
9 | use std::cell::Cell; |
10 | use std::mem::swap; | |
970d7e83 | 11 | |
223e47cc LB |
12 | // Just a grab bag of stuff that you wouldn't want to actually write. |
13 | ||
14 | fn strange() -> bool { let _x: bool = return true; } | |
15 | ||
16 | fn funny() { | |
17 | fn f(_x: ()) { } | |
18 | f(return); | |
19 | } | |
20 | ||
21 | fn what() { | |
1a4d82fc JJ |
22 | fn the(x: &Cell<bool>) { |
23 | return while !x.get() { x.set(true); }; | |
24 | } | |
25 | let i = &Cell::new(false); | |
85aaf69f | 26 | let dont = {||the(i)}; |
223e47cc | 27 | dont(); |
1a4d82fc | 28 | assert!((i.get())); |
223e47cc LB |
29 | } |
30 | ||
31 | fn zombiejesus() { | |
32 | loop { | |
33 | while (return) { | |
34 | if (return) { | |
35 | match (return) { | |
85aaf69f | 36 | 1 => { |
223e47cc LB |
37 | if (return) { |
38 | return | |
39 | } else { | |
40 | return | |
41 | } | |
42 | } | |
43 | _ => { return } | |
44 | }; | |
45 | } else if (return) { | |
46 | return; | |
47 | } | |
48 | } | |
49 | if (return) { break; } | |
50 | } | |
51 | } | |
52 | ||
53 | fn notsure() { | |
c34b1796 | 54 | let mut _x: isize; |
223e47cc LB |
55 | let mut _y = (_x = 0) == (_x = 0); |
56 | let mut _z = (_x = 0) < (_x = 0); | |
57 | let _a = (_x += 0) == (_x = 0); | |
1a4d82fc | 58 | let _b = swap(&mut _y, &mut _z) == swap(&mut _y, &mut _z); |
223e47cc LB |
59 | } |
60 | ||
c34b1796 | 61 | fn canttouchthis() -> usize { |
223e47cc LB |
62 | fn p() -> bool { true } |
63 | let _a = (assert!((true)) == (assert!(p()))); | |
64 | let _c = (assert!((p())) == ()); | |
c34b1796 | 65 | let _b: bool = (println!("{}", 0) == (return 0)); |
223e47cc LB |
66 | } |
67 | ||
68 | fn angrydome() { | |
69 | loop { if break { } } | |
85aaf69f SL |
70 | let mut i = 0; |
71 | loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => panic!("wat") } } | |
223e47cc LB |
72 | break; } |
73 | } | |
74 | ||
1a4d82fc | 75 | fn evil_lincoln() { let _evil = println!("lincoln"); } |
223e47cc | 76 | |
041b39d2 XL |
77 | fn dots() { |
78 | assert_eq!(String::from(".................................................."), | |
79 | format!("{:?}", .. .. .. .. .. .. .. .. .. .. .. .. .. | |
80 | .. .. .. .. .. .. .. .. .. .. .. ..)); | |
81 | } | |
82 | ||
94b46f34 XL |
83 | fn u8(u8: u8) { |
84 | if u8 != 0u8 { | |
85 | assert_eq!(8u8, { | |
86 | macro_rules! u8 { | |
87 | (u8) => { | |
88 | mod u8 { | |
89 | pub fn u8<'u8: 'u8 + 'u8>(u8: &'u8 u8) -> &'u8 u8 { | |
90 | "u8"; | |
91 | u8 | |
92 | } | |
041b39d2 | 93 | } |
94b46f34 XL |
94 | }; |
95 | } | |
041b39d2 | 96 | |
94b46f34 XL |
97 | u8!(u8); |
98 | let &u8: &u8 = u8::u8(&8u8); | |
99 | ::u8(0u8); | |
100 | u8 | |
101 | }); | |
102 | } | |
041b39d2 XL |
103 | } |
104 | ||
105 | fn fishy() { | |
106 | assert_eq!(String::from("><>"), | |
107 | String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>()); | |
108 | } | |
109 | ||
3b2f2976 XL |
110 | fn union() { |
111 | union union<'union> { union: &'union union<'union>, } | |
112 | } | |
113 | ||
94b46f34 XL |
114 | fn special_characters() { |
115 | let val = !((|(..):(_,_),__@_|__)((&*"\\",'🤔')/**/,{})=={&[..=..][..];})// | |
116 | ; | |
117 | assert!(!val); | |
118 | } | |
119 | ||
8faf50e0 XL |
120 | fn punch_card() -> impl std::fmt::Debug { |
121 | ..=..=.. .. .. .. .. .. .. .. .. .. .. ..=.. .. | |
122 | ..=.. ..=.. .. .. .. .. .. .. .. .. ..=..=..=.. | |
123 | ..=.. ..=.. ..=.. ..=.. .. ..=..=.. .. ..=.. .. | |
124 | ..=..=.. .. ..=.. ..=.. ..=.. .. .. .. ..=.. .. | |
125 | ..=.. ..=.. ..=.. ..=.. .. ..=.. .. .. ..=.. .. | |
126 | ..=.. ..=.. ..=.. ..=.. .. .. ..=.. .. ..=.. .. | |
127 | ..=.. ..=.. .. ..=..=.. ..=..=.. .. .. ..=.. .. | |
128 | } | |
129 | ||
223e47cc LB |
130 | pub fn main() { |
131 | strange(); | |
132 | funny(); | |
133 | what(); | |
134 | zombiejesus(); | |
135 | notsure(); | |
136 | canttouchthis(); | |
137 | angrydome(); | |
138 | evil_lincoln(); | |
041b39d2 | 139 | dots(); |
94b46f34 | 140 | u8(8u8); |
041b39d2 | 141 | fishy(); |
3b2f2976 | 142 | union(); |
94b46f34 | 143 | special_characters(); |
8faf50e0 | 144 | punch_card(); |
223e47cc | 145 | } |