Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more weirdness to weird-exprs.rs #119028

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/ui/weird-exprs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,31 @@ fn infcx() {
let _cx: cx::cx::Cx = cx::cx::cx::cx::cx::Cx;
}

fn return_already() -> impl std::fmt::Debug {
loop {
return !!!!!!!
break !!!!!!1111
}
}

fn cursed_macros() -> impl std::fmt::Debug {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is misleading. Those are not actually macro invocations, but keywords followed by ! negations and regular blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's somewhat the whole purpose of weird-exprs.rs: Abuse rust's syntax to make an expression look like something different (ensuring that it'll always be parsed correctly). Similarly, fn closure_matching() does not in fact match on closures.

loop {
if! {
match! (
break! {
return! {
1337
}
}
)

{}
}

{}
}
}

pub fn main() {
strange();
funny();
Expand All @@ -257,4 +282,6 @@ pub fn main() {
semisemisemisemisemi();
useful_syntax();
infcx();
return_already();
cursed_macros();
}
Loading