-
Notifications
You must be signed in to change notification settings - Fork 220
Update to Rust 1.90 #6958
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
Update to Rust 1.90 #6958
Conversation
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 am happy that DCE is more aggressive, but I think it's swinging a bit far, and we really should avoid reaching for allow(dead_code).
I didn't comment everywhere there was a problem because there were too many.
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). | ||
|
||
mod fixtures; | ||
use serde::{Deserialize, Serialize}; |
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.
Suggestion: make the change smaller by keeping the fixture definitions in the separate file, and just not including them in the file where they are not used
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 problem is that multiple bench files include the same fixtures module, and some fixtures are unused in each benchmark. this puts the fixtures for each benchmark in the benchmark
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.
Oh I see, that's terrible...
I think well commented allow(dead_code) in a central file might be better
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.
there's no shared code so this is better
#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize))] | ||
#[yoke(prove_covariance_manually)] | ||
#[allow(dead_code)] |
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.
Issue: allowing dead code is bad; why do you need if?
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.
this is the one place where I don't know why, Rust says it's never constructed so it doesn't seem to detect when it's constructed from deserialization through Yoke
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.
If that's so, it sounds like a bug, potentially a bad bug if rustc ever tries to use the same heuristic to strip symbols from the binary or something
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.
definitely not the same "heuristics", DCE happens way later when types and source locations are long gone
//! <https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/currencyData.json> | ||
use serde::Deserialize; | ||
use std::collections::BTreeMap; |
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.
Issue: if we're not using these, it's a bug. Ideally the datagen code would have been added in the same PR as the safe serde code, but that doesn't mean we should just delete the impls. Please at least make them cfg test with a little test?
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 have no idea what these are, I'm certainly not going to start writing tests for them.
One of these files is not even included as module anywhere.
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.
They are for parsing supplemental currency data. I've been asking for @younies to finish up the currency component and he probably added these impls but doesn't use them yet, but we will be needing them.
//! TODO(#5613): Even though these markers are no longer exported, we need them in order to export | ||
//! semantic skeleton data markers. This should be refactored to skip the intermediate data struct. | ||
#![allow(dead_code)] // so many unused fields |
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.
Issue: I want to eventually get rid of this whole file. If fields are actually dead, delete them?
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 did do that whole work, but it's super messy because you end up with structs with single or even no fields, and I think it makes the tests a lot harder to parse because you lose a lot of semantics of what these are. So I reverted to this.
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 haven't seen all of what we'd be losing?
Cfg(test) isn't sufficient?
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.
let's keep this massive cleanup for a different PR please
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.
Cfg(test) isn't sufficient?
there are fields here that are used in code, there are fields here that are used only in tests, there are fields here that are unused. to properly clean this up, the tests need to be rewritten
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.
These blanket allows make future improvements harder because we won't notice when we actually can delete code
A file containing code we actually want to delete is like the worst file to put a blanket suppression
|
||
#[cfg(any(feature = "use_wasm", feature = "use_icu4c"))] | ||
pub(crate) mod code_point_prop { | ||
#[derive(serde::Deserialize)] |
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.
Issue: again, cldr_serde is the one place where I think we should keep the whole struct. Also, it's not completely dead code: it makes the Deserialize impls check that those fields are well formed.
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.
eh, I don't think we generally assert fields that we don't use, I don't think it's that valuable
} | ||
|
||
#[derive(serde::Serialize, serde::Deserialize)] | ||
#[expect(dead_code)] |
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.
Nit: comment why
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.
because we test the derive macro but never construct these
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 meant add a comment in the code
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.
so I put a comment on the DeriveTest
structs saying "only tests derive macro"?
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.
Yes
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.
#[expect(dead_code)] // tests derive macro
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.
seems stupid but if you insist
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.
Please make allow dead_code as narrow as possible, on individual fields even, and leave code comments each time explaining why it is needed
yeah I'm just not going to do that for the legacy datetime stuff if this is a blocker then I'll close this PR and we can update the toolchain once that code has been cleaned up |
1.90 improves dead code detection, so I had to do some cleanups to pass CI.