https://github.com/rust-lang/rust/blob/master/src/test/ui/weird-exprs.rs Skip to content Sign up * Why GitHub? Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Project management - + Integrations - + GitHub Sponsors - + Customer stories- * Team * Enterprise * Explore + Explore GitHub - Learn and contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing Plans - + Compare plans - + Contact Sales - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} rust-lang / rust * Notifications * Star 55k * Fork 7.8k * Code * Issues 5k+ * Pull requests 374 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights Permalink master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags rust/src/test/ui/weird-exprs.rs Go to file * Go to file T * Go to line L * * Copy path * Copy permalink @slanterns slanterns Rename empty_tuple_assignment to monkey_barrel Latest commit 38fa66a Nov 12, 2020 History 4 contributors Users who have contributed to this file @slanterns @petrochenkov @tmiasko @lcnr 187 lines (162 sloc) 4.22 KB Raw Blame * Open with Desktop * View raw * View blame // 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) { 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:: ()); } 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(); } * Copy lines * Copy permalink * View git blame * Reference in new issue [ ] Go * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.