-
Notifications
You must be signed in to change notification settings - Fork 180
Workaround for loop {} until it is fixed #59
Conversation
I would prefer to use |
ca0674b
to
25278e4
Compare
@japaric No problem, changed to |
One thing I've been doing in my crates (to avoid clippy warnings about an empty loop) is to place a |
I tried it, but using only continue still generates the |
@korken89 On which arch is that? I can't reproduce the problem on armv6m: With my usual code I get:
With the
|
I'm curious what the original workaround looked like, if anything I'd prefer a |
I think a |
@therealprof I was using latest nightly and The idea is simply that after filling out the template "It should just work™", which it does not do in some cases now - resulting in a CPU crash. |
I agree it should work out-of-the-box but I can't reproduce the failure with my own applications. Maybe the problem is specific to the empty main function of the quickstart example and not the loop itself? |
It is a known issue for a few years, you can read about it here: rust-lang/rust#28728 I can fix a small example when I'm back home :) |
@korken89 I've read the issue. I'm still interested in actually reproducing the problem myself because I haven't seen it so far and if it really is a problem I'll have to deploy a fix in quite a few crates and create new releases. So I'm looking forward to your example. ;) |
@therealprof, here you can download and run |
I also had to use a similar trick in |
@korken89 I think that is a totally different issue: The compiler is assuming that since the loop is irrelevant it can just optimise it away, so it will. And since main is empty rustc will happily inline it into the As soon as
Can you try whether
works for you? |
@therealprof I updated the |
Ah sorry, no I read the wrong function. Having side effect in |
@korken89 You should always get the |
Yeah, exactly. Back to the issue at hand, should we move this PR forward or go with a different approach? |
@korken89 I'd prefer to put the If we put other side-effects into the loop people are likely to copy it for no good reason. (Not that it really mattered but it's not exactly beautiful either). |
25278e4
to
f9570c7
Compare
I agree on moving the |
I see what you did there, you're expecting the user code to end up in the loop. That kind of assumes you're not starting your I think it is more idiomatic to suggest something something like:
I'm still going to blanket approve your version because it is better than what we have at the moment. |
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
Fixes #50 but is only a workaround until it is fixed in the compiler