aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/tests/data/parser/ok/0035_weird_exprs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/tests/data/parser/ok/0035_weird_exprs.rs')
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0035_weird_exprs.rs149
1 files changed, 149 insertions, 0 deletions
diff --git a/crates/ra_syntax/tests/data/parser/ok/0035_weird_exprs.rs b/crates/ra_syntax/tests/data/parser/ok/0035_weird_exprs.rs
new file mode 100644
index 000000000..74edc6354
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0035_weird_exprs.rs
@@ -0,0 +1,149 @@
1#![allow(non_camel_case_types)]
2#![allow(dead_code)]
3#![allow(unreachable_code)]
4#![allow(unused_parens)]
5
6#![recursion_limit = "128"]
7
8use std::cell::Cell;
9use std::mem::swap;
10
11// Just a grab bag of stuff that you wouldn't want to actually write.
12
13fn strange() -> bool { let _x: bool = return true; }
14
15fn funny() {
16 fn f(_x: ()) { }
17 f(return);
18}
19
20fn what() {
21 fn the(x: &Cell<bool>) {
22 return while !x.get() { x.set(true); };
23 }
24 let i = &Cell::new(false);
25 let dont = {||the(i)};
26 dont();
27 assert!((i.get()));
28}
29
30fn zombiejesus() {
31 loop {
32 while (return) {
33 if (return) {
34 match (return) {
35 1 => {
36 if (return) {
37 return
38 } else {
39 return
40 }
41 }
42 _ => { return }
43 };
44 } else if (return) {
45 return;
46 }
47 }
48 if (return) { break; }
49 }
50}
51
52fn notsure() {
53 let mut _x: isize;
54 let mut _y = (_x = 0) == (_x = 0);
55 let mut _z = (_x = 0) < (_x = 0);
56 let _a = (_x += 0) == (_x = 0);
57 let _b = swap(&mut _y, &mut _z) == swap(&mut _y, &mut _z);
58}
59
60fn canttouchthis() -> usize {
61 fn p() -> bool { true }
62 let _a = (assert!((true)) == (assert!(p())));
63 let _c = (assert!((p())) == ());
64 let _b: bool = (println!("{}", 0) == (return 0));
65}
66
67fn angrydome() {
68 loop { if break { } }
69 let mut i = 0;
70 loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => panic!("wat") } }
71 break; }
72}
73
74fn evil_lincoln() { let _evil = println!("lincoln"); }
75
76fn dots() {
77 assert_eq!(String::from(".................................................."),
78 format!("{:?}", .. .. .. .. .. .. .. .. .. .. .. .. ..
79 .. .. .. .. .. .. .. .. .. .. .. ..));
80}
81
82fn u8(u8: u8) {
83 if u8 != 0u8 {
84 assert_eq!(8u8, {
85 macro_rules! u8 {
86 (u8) => {
87 mod u8 {
88 pub fn u8<'u8: 'u8 + 'u8>(u8: &'u8 u8) -> &'u8 u8 {
89 "u8";
90 u8
91 }
92 }
93 };
94 }
95
96 u8!(u8);
97 let &u8: &u8 = u8::u8(&8u8);
98 crate::u8(0u8);
99 u8
100 });
101 }
102}
103
104fn fishy() {
105 assert_eq!(String::from("><>"),
106 String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>());
107}
108
109fn union() {
110 union union<'union> { union: &'union union<'union>, }
111}
112
113fn special_characters() {
114 let val = !((|(..):(_,_),__@_|__)((&*"\\",'🤔')/**/,{})=={&[..=..][..];})//
115 ;
116 assert!(!val);
117}
118
119fn punch_card() -> impl std::fmt::Debug {
120 ..=..=.. .. .. .. .. .. .. .. .. .. .. ..=.. ..
121 ..=.. ..=.. .. .. .. .. .. .. .. .. ..=..=..=..
122 ..=.. ..=.. ..=.. ..=.. .. ..=..=.. .. ..=.. ..
123 ..=..=.. .. ..=.. ..=.. ..=.. .. .. .. ..=.. ..
124 ..=.. ..=.. ..=.. ..=.. .. ..=.. .. .. ..=.. ..
125 ..=.. ..=.. ..=.. ..=.. .. .. ..=.. .. ..=.. ..
126 ..=.. ..=.. .. ..=..=.. ..=..=.. .. .. ..=.. ..
127}
128
129fn ktulhu() {
130 ;;;();;;;;;;;;()
131}
132
133pub fn main() {
134 strange();
135 funny();
136 what();
137 zombiejesus();
138 notsure();
139 canttouchthis();
140 angrydome();
141 evil_lincoln();
142 dots();
143 u8(8u8);
144 fishy();
145 union();
146 special_characters();
147 punch_card();
148 ktulhu();
149}