-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
UTC_OFFSET_FORMAT: use const blocks around function calls #704
Conversation
Strange, when I format this file I get a diff in unrelated parts of the file... I'll have to manually only format the part that I changed then. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #704 +/- ##
=======================================
- Coverage 97.8% 97.6% -0.2%
=======================================
Files 81 83 +2
Lines 9378 9008 -370
=======================================
- Hits 9169 8790 -379
- Misses 209 218 +9 ☔ View full report in Codecov by Sentry. |
Also to be clear, this code will not be rejected on the current edition ever. If we do any kind of change here, it will be over an edition. But it would still be interesting to know just how wide-spread this pattern is -- last time we tried this, several years ago, it was only 2 or 3 crates that were affected. |
Would the same behavior result if using separate
Try
As the primary intent here is to get a crater run, is it possible to apply a patch (in |
Ah I see. Yes using const items is also possible, just a bit less nice.
Cargo is a submodule, so it can't be easily patched from the rustc repo. Also that crater run would then show tons of failures from time-rs failing. As I said I am in no rush here, waiting a few weeks is fine. |
Let's do that for the time being. It would avoid the MSRV update and having to wait another 12 weeks to be permitted to do it (per policy). Feel free to include a
I considered the latter but am not familiar with the inner workings of crater.
Sounds good. With the requested update, I might be able to get it out this weekend (or Monday) depending on if I have time to review the changes since the most recent release. |
Done :) |
Thanks! |
Implicit promotion (where
&expr
terms implicitly create a new constant with valueexpr
and a borrow with lifetime'static
to such a constant) has a long and troubled history. Right now we are in a state that's at least reasonably well-behaved, but it does make for some rather strange behaviors, as is tracked in rust-lang/rust#124328. I wanted to do a crater experiment to see just how much code out there relies on this, by making rustc do longer do promotion of function calls, and it turns out not even cargo builds any more then. 😂The crate that failed to build is time. So I wonder if it would be okay to patch time to make it work under this more strict, more sane promotion regime. The main point in the new regime is to use explicit
const { ... }
blocks to make things into constants, instead of doing that implicitly. So here we wrap all function calls inconst
blocks, so that the entire outer expression is just a bunch of array constructors, enum constructors,&
, and consts -- which is trivially promotable.Landing this will raise the MSRV to 1.79. I realize it's too early to do that under your MSRV policy. 1.81 will be released tomorrow so then it would be covered by the policy, but I'm also completely fine with delaying this until later. I'm in no rush here. :)