-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
fix for ICE issue #25180 #25209
fix for ICE issue #25180 #25209
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
I think what the PR lacks as of yet is a testcase to show that the fix actually quells the ICE. I just added it and will commit after I rebuild. |
assert!(self.mode == Mode::Var); | ||
let (old_mode, old_qualif) = (self.mode, self.qualif); | ||
self.mode = Mode::Var; | ||
self.qualif = ConstQualif::empty(); |
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.
You don't have to copy with_mode
, you can just call it (and replace self
in the two original statements with v
, or whatever you choose for the name of the closure argument).
Yep, you're right. I'll change it. Thank you for pointing that out. |
… removed the with_mode copy, thanks to eddyb
assert!(self.mode == Mode::Var); | ||
self.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b)); | ||
self.with_mode(Mode::Var, |v| v.with_euv(Some(fn_id), | ||
|euv| euv.walk_fn(fd, b))); | ||
visit::walk_fn(self, fk, fd, b, s); |
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.
walk_fn
has to be inside the with_mode
call, too.
OK, but I'd like to understand why? Surely rustc compiles the code anyway – I even have a test case saying so. What are the implications of walking the fn in const mode? |
If it's in const mode, you get the const rules. And maybe ICEs. Try calling a function and you'll see. |
Ah, Ok. Should have run the extended test before I fixed the function. Is this ready to merge now or do I need to do something else? |
|
||
// pretty-expanded FIXME #25180 | ||
|
||
const x: &'static Fn() = &|| println!("ICE here"); |
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.
Do multiple statements, arguments and local variables work in these closures?
Yeah, it's a good idea to add some more tests. I'm on it. Edit: Just started make check. |
So yes, it appears to work after I got the test code right. |
📌 Commit a18ce4d has been approved by |
According to @eddyb – and my tests – the following gets rid of the ICE in issue rust-lang#25180.
According to @eddyb – and my tests – the following gets rid of the ICE in issue rust-lang#25180.
💔 Test failed - auto-mac-64-opt |
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// pretty-expanded FIXME #25180 |
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 failure was in pretty tests, which I don't you can do if you're using macros like println!
which use unstable items in their expansions.
According to @eddyb – and my tests – the following gets rid of the ICE in issue rust-lang#25180.
@bors: rollup- |
@steveklabnik huh, shouldn't a test failure take it out of the queue automatically? |
don't think so |
@steveklabnik I'm sorry that I broke the rollup. Apparently my tests weren't sufficient. I've now removed the print! macro invocations and added a feature declaration (which was hinted in the error message). Can someone tell me how I can reproduce the failing test? |
It's all good :) everyone does it. I'm not 100% sure how to reproduce though |
Thanks for the kind words. My first PR and manage to hit all available roadblocks at once. But hey, I learn a lot there days. 😄 |
|
||
const EMPTY: &'static Fn() = &|| (); | ||
|
||
const ONE_ARGUMENT: &'static Fn(u32) = &|y| assert!(y == 42); |
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.
assert!
still uses the formatting machinery. I'm curious if we prefer to disable pretty testing or just add feature gates. What do other tests do?
I see 783 instances of "feature" just in |
@llogiq Running |
@eddyb Thanks, but that only prints that my Makefile does not have this target. Perhaps I'm missing some required package? |
In that case, my previous two commits make the test pass on my machine. On the other hand, it doesn't even require the feature gate. So it appears I cannot reproduce the issue on my 64-bit intel / Linux machine (Though I'm not sure if this is really about darwin or if I missed something while building). Can someone with a mac reproduce the problem? |
☔ The latest upstream changes (presumably #25609) made this pull request unmergeable. Please resolve the merge conflicts. |
I've just revisited the problem, and recent changes not only made my PR unmergeable, but also fixed the problem in a different way. Closing the PR is the sensible option here. |
According to @eddyb – and my tests – the following gets rid of the ICE in issue #25180.