-
Notifications
You must be signed in to change notification settings - Fork 171
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
break rust 💥 #2086
break rust 💥 #2086
Conversation
32c568d
to
8657790
Compare
There are some tests now 🙂
There's apparently
clang-format should be happy now; but I may have to revert some of the changes in case we decide on a longer error message text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its looking ok just not sure we need the the funny_error flag
Also just for the record we definitely need this critical change :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests look good, as well as the implementation :) nice work! Once everything is approved we'll probably ask you to rebase your commits into one, but that can be done later. Thank you for working on this!
Submitted as a review suggestion :)
Yes, we do have to write Changelog entries for GCC. You can run
Complicated and not worth it imo :) this is already nice and fun haha.
|
And implemented 🙂
Does that mean that my existing changelongs are not fine? Any specific things for me to fix? |
8e64c72
to
d19c019
Compare
They're great! I hadn't checked them yet haha, I thought you hadn't written any and was looking for help on how to proceed. The ones you wrote are really good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM i think i can live with a flag for this :D
I think this still needs more comments in the source code (and not just on GH):
|
@bugaevc are you going to add another commit with more comments? |
I am; but before I do that, a question: should I stash all the commits into one, or are multiple commits fine? |
having multiple commits is all good (and preferred!) as long as they all build :) I've checked and all your 4 commits build (we'll soon have more CI for that) so you're fine. Feel free to add the documentation in a new commit on top of these 4 :) |
We're going to introduce AST::Kind::IDENTIFIER next, and with the default C-style enum member scoping, this would cause name clashes. Instead, convert AST::Kind into an enum class, so that its members are properly namespaced. gcc/rust/ChangeLog: * ast/rust-ast.h (Kind): Convert into a C++ enum class * expand/rust-macro-builtins.cc: Adapt to the change Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
...and return it from IdentifierExpr::get_ast_kind (). This enables other code to dynamically test whether an expression is in fact an IdentifierExpr. gcc/rust/ChangeLog: * ast/rust-ast.h: Add AST::Kind::IDENTIFIER Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
...and thread it through the constructors and the ResolveExpr::go () method. This will be used for implementing the "break rust" Easter egg. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.h, resolve/rust-ast-resolve-expr.cc: Add ResolveExpr::funny_error Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
acfccf3
to
4dc555b
Compare
When we encounter a "break rust" statement, emit a funny error message and intentionally cause an ICE. This matches the corresponding Easter egg in rustc. As a GNU extension, "break gcc" is also supported. The conditions for this to happen are: * The break expression must be literally "rust" or "gcc". For instance, "break (rust)" will not trigger the Easter egg. * The name ("rust" or "gcc") must not be in scope; if it is, no error is emitted, and the compilation proceeds as usual. In other words, this only affects how GCC diagnoses programs that would fail to compile anyway. Note that this is different from the conditions under which rustc emits its ICE. For rustc, it matters whether or not the "break" is inside a loop, and for us it matters whether or not the name resolves. The end result should be the same anyway: valid programs continue to compile, and typing in fn main() { break rust; } triggers a funny ICE. Closes Rust-GCC#1996 gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc: Add "break rust" Easter egg gcc/testsuite/ChangeLog: * lib/prune.exp (prune_ices): Also prune "You have broken GCC Rust. This is a feature." * rust/compile/break-rust1.rs: New test * rust/compile/break-rust2.rs: New test * rust/compile/break-rust3.rs: New test Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Wrote a comment (several of them actually). Please tell me if these are comprehensive enough (and please point out any grammar / spelling / other mistakes) 🙂. I opted to fold this into the last commit though, and slightly expanded the commit message. Assuming this passes CI, it should be good to go from my side 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me, thank you @bugaevc !
Thank you for guiding me! And please don't forget to mention this important feature in the next progress report 😃 |
Accordingly also adjust #2086 "break rust 💥" code, to avoid: [...]/source-gcc/gcc/rust/resolve/rust-ast-resolve-expr.cc: In member function ‘virtual void Rust::Resolver::ResolveExpr::visit(Rust::AST::IdentifierExpr&)’: [...]/source-gcc/gcc/rust/resolve/rust-ast-resolve-expr.cc:164:42: error: invalid conversion from ‘void (*)(diagnostic_context*, diagnostic_info*, diagnostic_t)’ to ‘diagnostic_finalizer_fn’ {aka ‘void (*)(diagnostic_context*, con iagnostic_info*, diagnostic_t)’} [-fpermissive] 164 | diagnostic_finalizer (global_dc) = funny_ice_finalizer; | ^~~~~~~~~~~~~~~~~~~ | | | void (*)(diagnostic_context*, diagnostic_info*, diagnostic_t)
Fascinatingly, it appears the german translators have gone on strike: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114629 |
Since #1996 has received positive feedback, here's a tentative implementation 😄
TODO:
make check-rust
seems to pass locally, that's a startbreak rust
andbreak gcc
still compile just fine ifrust
/gcc
is actually in scopebreak (rust)
still causes the old error