2019-07-26 21:54:25 +00:00
|
|
|
|
// run-pass
|
|
|
|
|
|
2023-10-19 21:46:28 +00:00
|
|
|
|
#![feature(coroutines)]
|
2019-06-07 03:01:54 +00:00
|
|
|
|
|
2018-09-14 10:20:28 +00:00
|
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
#![allow(dead_code)]
|
2023-05-15 18:40:06 +00:00
|
|
|
|
#![allow(redundant_semicolons)]
|
2018-09-14 10:20:28 +00:00
|
|
|
|
#![allow(unreachable_code)]
|
2020-07-28 00:00:00 +00:00
|
|
|
|
#![allow(unused_braces, unused_must_use, unused_parens)]
|
2021-06-29 18:22:44 +00:00
|
|
|
|
#![allow(uncommon_codepoints, confusable_idents)]
|
2023-05-15 18:40:06 +00:00
|
|
|
|
#![allow(unused_imports)]
|
2022-11-06 00:22:31 +00:00
|
|
|
|
#![allow(unreachable_patterns)]
|
2013-10-23 08:49:18 +00:00
|
|
|
|
|
2019-01-03 02:19:03 +00:00
|
|
|
|
#![recursion_limit = "256"]
|
2018-07-05 10:07:33 +00:00
|
|
|
|
|
2023-05-15 18:40:06 +00:00
|
|
|
|
extern crate core;
|
2013-12-31 23:46:27 +00:00
|
|
|
|
use std::cell::Cell;
|
2014-01-31 20:35:36 +00:00
|
|
|
|
use std::mem::swap;
|
2023-06-20 03:22:34 +00:00
|
|
|
|
use std::ops::Deref;
|
2013-05-06 04:42:54 +00:00
|
|
|
|
|
2011-09-26 17:26:30 +00:00
|
|
|
|
// Just a grab bag of stuff that you wouldn't want to actually write.
|
2011-08-19 05:16:54 +00:00
|
|
|
|
|
2012-08-02 00:30:05 +00:00
|
|
|
|
fn strange() -> bool { let _x: bool = return true; }
|
2011-08-19 05:16:54 +00:00
|
|
|
|
|
|
|
|
|
fn funny() {
|
2011-08-19 22:16:48 +00:00
|
|
|
|
fn f(_x: ()) { }
|
2012-08-02 00:30:05 +00:00
|
|
|
|
f(return);
|
2011-08-19 05:16:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn what() {
|
2014-10-02 05:10:09 +00:00
|
|
|
|
fn the(x: &Cell<bool>) {
|
2013-12-31 23:46:27 +00:00
|
|
|
|
return while !x.get() { x.set(true); };
|
|
|
|
|
}
|
2014-10-02 05:10:09 +00:00
|
|
|
|
let i = &Cell::new(false);
|
2015-02-01 17:44:15 +00:00
|
|
|
|
let dont = {||the(i)};
|
2011-08-19 05:16:54 +00:00
|
|
|
|
dont();
|
2013-12-31 23:46:27 +00:00
|
|
|
|
assert!((i.get()));
|
2011-08-19 05:16:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn zombiejesus() {
|
2012-05-10 21:06:19 +00:00
|
|
|
|
loop {
|
2012-08-02 00:30:05 +00:00
|
|
|
|
while (return) {
|
|
|
|
|
if (return) {
|
2012-08-06 19:34:08 +00:00
|
|
|
|
match (return) {
|
2015-01-25 21:05:03 +00:00
|
|
|
|
1 => {
|
2012-08-02 00:30:05 +00:00
|
|
|
|
if (return) {
|
|
|
|
|
return
|
2012-01-30 03:58:16 +00:00
|
|
|
|
} else {
|
2012-08-02 00:30:05 +00:00
|
|
|
|
return
|
2012-01-30 03:58:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-04 02:59:04 +00:00
|
|
|
|
_ => { return }
|
2012-01-30 03:58:16 +00:00
|
|
|
|
};
|
2012-08-02 00:30:05 +00:00
|
|
|
|
} else if (return) {
|
|
|
|
|
return;
|
2011-09-16 04:24:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-02 00:30:05 +00:00
|
|
|
|
if (return) { break; }
|
2012-05-10 21:06:19 +00:00
|
|
|
|
}
|
2011-08-19 05:16:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn notsure() {
|
2015-03-26 00:06:52 +00:00
|
|
|
|
let mut _x: isize;
|
2012-03-22 15:39:41 +00:00
|
|
|
|
let mut _y = (_x = 0) == (_x = 0);
|
2013-02-15 10:44:18 +00:00
|
|
|
|
let mut _z = (_x = 0) < (_x = 0);
|
2011-08-19 05:16:54 +00:00
|
|
|
|
let _a = (_x += 0) == (_x = 0);
|
2014-01-31 20:35:36 +00:00
|
|
|
|
let _b = swap(&mut _y, &mut _z) == swap(&mut _y, &mut _z);
|
2011-08-19 05:16:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
|
fn canttouchthis() -> usize {
|
2013-03-22 18:23:21 +00:00
|
|
|
|
fn p() -> bool { true }
|
2013-03-29 01:39:09 +00:00
|
|
|
|
let _a = (assert!((true)) == (assert!(p())));
|
|
|
|
|
let _c = (assert!((p())) == ());
|
2015-03-03 08:42:26 +00:00
|
|
|
|
let _b: bool = (println!("{}", 0) == (return 0));
|
2011-08-19 05:16:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn angrydome() {
|
2012-03-10 00:11:56 +00:00
|
|
|
|
loop { if break { } }
|
2015-01-25 21:05:03 +00:00
|
|
|
|
let mut i = 0;
|
|
|
|
|
loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => panic!("wat") } }
|
2012-08-23 21:44:58 +00:00
|
|
|
|
break; }
|
2011-08-19 05:16:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-12 08:55:36 +00:00
|
|
|
|
fn evil_lincoln() { let _evil: () = println!("lincoln"); }
|
2011-08-19 05:16:54 +00:00
|
|
|
|
|
2017-05-26 15:44:18 +00:00
|
|
|
|
fn dots() {
|
|
|
|
|
assert_eq!(String::from(".................................................."),
|
2017-06-05 21:02:55 +00:00
|
|
|
|
format!("{:?}", .. .. .. .. .. .. .. .. .. .. .. .. ..
|
|
|
|
|
.. .. .. .. .. .. .. .. .. .. .. ..));
|
2017-05-26 15:44:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-06 16:42:34 +00:00
|
|
|
|
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
|
|
|
|
|
}
|
2017-05-26 15:44:18 +00:00
|
|
|
|
}
|
2018-06-06 16:42:34 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-06-05 21:02:55 +00:00
|
|
|
|
|
2018-06-06 16:42:34 +00:00
|
|
|
|
u8!(u8);
|
|
|
|
|
let &u8: &u8 = u8::u8(&8u8);
|
|
|
|
|
::u8(0u8);
|
|
|
|
|
u8
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-05-26 15:44:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn fishy() {
|
2017-06-05 21:02:55 +00:00
|
|
|
|
assert_eq!(String::from("><>"),
|
|
|
|
|
String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>());
|
2017-05-26 15:44:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-04 07:53:09 +00:00
|
|
|
|
fn union() {
|
|
|
|
|
union union<'union> { union: &'union union<'union>, }
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-25 14:48:55 +00:00
|
|
|
|
fn special_characters() {
|
2022-05-20 22:17:33 +00:00
|
|
|
|
let val = !((|(..):(_,_),(|__@_|__)|__)((&*"\\",'🤔')/**/,{})=={&[..=..][..];})//
|
2018-05-25 14:48:55 +00:00
|
|
|
|
;
|
|
|
|
|
assert!(!val);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 10:07:33 +00:00
|
|
|
|
fn punch_card() -> impl std::fmt::Debug {
|
|
|
|
|
..=..=.. .. .. .. .. .. .. .. .. .. .. ..=.. ..
|
|
|
|
|
..=.. ..=.. .. .. .. .. .. .. .. .. ..=..=..=..
|
|
|
|
|
..=.. ..=.. ..=.. ..=.. .. ..=..=.. .. ..=.. ..
|
|
|
|
|
..=..=.. .. ..=.. ..=.. ..=.. .. .. .. ..=.. ..
|
|
|
|
|
..=.. ..=.. ..=.. ..=.. .. ..=.. .. .. ..=.. ..
|
|
|
|
|
..=.. ..=.. ..=.. ..=.. .. .. ..=.. .. ..=.. ..
|
|
|
|
|
..=.. ..=.. .. ..=..=.. ..=..=.. .. .. ..=.. ..
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-31 13:20:10 +00:00
|
|
|
|
fn r#match() {
|
2023-06-12 08:55:36 +00:00
|
|
|
|
let val: () = match match match match match () {
|
2019-03-31 13:20:10 +00:00
|
|
|
|
() => ()
|
|
|
|
|
} {
|
|
|
|
|
() => ()
|
|
|
|
|
} {
|
|
|
|
|
() => ()
|
|
|
|
|
} {
|
|
|
|
|
() => ()
|
|
|
|
|
} {
|
|
|
|
|
() => ()
|
|
|
|
|
};
|
|
|
|
|
assert_eq!(val, ());
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-07 03:01:54 +00:00
|
|
|
|
fn i_yield() {
|
|
|
|
|
static || {
|
|
|
|
|
yield yield yield yield yield yield yield yield yield;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-16 12:01:05 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-12 02:38:03 +00:00
|
|
|
|
fn monkey_barrel() {
|
2023-06-12 08:55:36 +00:00
|
|
|
|
let val: () = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=();
|
2020-11-11 15:40:11 +00:00
|
|
|
|
assert_eq!(val, ());
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 22:17:33 +00:00
|
|
|
|
fn 𝚌𝚘𝚗𝚝𝚒𝚗𝚞𝚎() {
|
|
|
|
|
type 𝚕𝚘𝚘𝚙 = i32;
|
|
|
|
|
fn 𝚋𝚛𝚎𝚊𝚔() -> 𝚕𝚘𝚘𝚙 {
|
|
|
|
|
let 𝚛𝚎𝚝𝚞𝚛𝚗 = 42;
|
|
|
|
|
return 𝚛𝚎𝚝𝚞𝚛𝚗;
|
|
|
|
|
}
|
2021-06-29 18:22:44 +00:00
|
|
|
|
assert_eq!(loop {
|
|
|
|
|
break 𝚋𝚛𝚎𝚊𝚔 ();
|
2022-05-20 22:17:33 +00:00
|
|
|
|
}, 42);
|
2021-06-29 18:22:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 18:28:44 +00:00
|
|
|
|
fn function() {
|
|
|
|
|
struct foo;
|
2023-06-20 03:22:34 +00:00
|
|
|
|
impl Deref for foo {
|
|
|
|
|
type Target = fn() -> Self;
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
|
&((|| foo) as _)
|
2021-06-29 18:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let foo = foo () ()() ()()() ()()()() ()()()()();
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 03:25:02 +00:00
|
|
|
|
fn bathroom_stall() {
|
|
|
|
|
let mut i = 1;
|
|
|
|
|
matches!(2, _|_|_|_|_|_ if (i+=1) != (i+=1));
|
|
|
|
|
assert_eq!(i, 13);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 00:22:31 +00:00
|
|
|
|
fn closure_matching() {
|
|
|
|
|
let x = |_| Some(1);
|
|
|
|
|
let (|x| x) = match x(..) {
|
|
|
|
|
|_| Some(2) => |_| Some(3),
|
|
|
|
|
|_| _ => unreachable!(),
|
|
|
|
|
};
|
|
|
|
|
assert!(matches!(x(..), |_| Some(4)));
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-15 18:40:06 +00:00
|
|
|
|
fn semisemisemisemisemi() {
|
|
|
|
|
;;;;;;; ;;;;;;; ;;; ;;; ;;
|
|
|
|
|
;; ;; ;;;; ;;;; ;;
|
|
|
|
|
;;;;;;; ;;;;; ;; ;;;; ;; ;;
|
|
|
|
|
;; ;; ;; ;; ;; ;;
|
|
|
|
|
;;;;;;; ;;;;;;; ;; ;; ;;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn useful_syntax() {
|
|
|
|
|
use {{std::{{collections::{{HashMap}}}}}};
|
|
|
|
|
use ::{{{{core}, {std}}}};
|
|
|
|
|
use {{::{{core as core2}}}};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn infcx() {
|
|
|
|
|
pub mod cx {
|
|
|
|
|
pub mod cx {
|
|
|
|
|
pub use super::cx;
|
|
|
|
|
pub struct Cx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let _cx: cx::cx::Cx = cx::cx::cx::cx::cx::Cx;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-16 22:32:24 +00:00
|
|
|
|
fn return_already() -> impl std::fmt::Debug {
|
|
|
|
|
loop {
|
|
|
|
|
return !!!!!!!
|
|
|
|
|
break !!!!!!1111
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-21 12:47:45 +00:00
|
|
|
|
fn fake_macros() -> impl std::fmt::Debug {
|
2023-12-16 22:32:24 +00:00
|
|
|
|
loop {
|
|
|
|
|
if! {
|
|
|
|
|
match! (
|
|
|
|
|
break! {
|
|
|
|
|
return! {
|
|
|
|
|
1337
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
|
pub fn main() {
|
2011-08-19 05:16:54 +00:00
|
|
|
|
strange();
|
|
|
|
|
funny();
|
|
|
|
|
what();
|
|
|
|
|
zombiejesus();
|
|
|
|
|
notsure();
|
|
|
|
|
canttouchthis();
|
|
|
|
|
angrydome();
|
|
|
|
|
evil_lincoln();
|
2017-05-26 15:44:18 +00:00
|
|
|
|
dots();
|
2018-06-06 16:42:34 +00:00
|
|
|
|
u8(8u8);
|
2017-05-26 15:44:18 +00:00
|
|
|
|
fishy();
|
2017-08-04 07:53:09 +00:00
|
|
|
|
union();
|
2018-05-25 14:50:59 +00:00
|
|
|
|
special_characters();
|
2018-07-05 10:07:33 +00:00
|
|
|
|
punch_card();
|
2019-03-31 13:20:10 +00:00
|
|
|
|
r#match();
|
2019-06-07 03:01:54 +00:00
|
|
|
|
i_yield();
|
2019-06-16 12:01:05 +00:00
|
|
|
|
match_nested_if();
|
2020-11-12 02:38:03 +00:00
|
|
|
|
monkey_barrel();
|
2022-05-20 22:17:33 +00:00
|
|
|
|
𝚌𝚘𝚗𝚝𝚒𝚗𝚞𝚎();
|
2021-06-29 18:28:44 +00:00
|
|
|
|
function();
|
2022-04-30 03:25:02 +00:00
|
|
|
|
bathroom_stall();
|
2022-11-06 00:22:31 +00:00
|
|
|
|
closure_matching();
|
2023-05-15 18:40:06 +00:00
|
|
|
|
semisemisemisemisemi();
|
|
|
|
|
useful_syntax();
|
|
|
|
|
infcx();
|
2023-12-16 22:32:24 +00:00
|
|
|
|
return_already();
|
2024-01-21 12:47:45 +00:00
|
|
|
|
fake_macros();
|
2011-08-19 05:16:54 +00:00
|
|
|
|
}
|