Skip to content

Update to Rust 1.67 #17378

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

Merged
merged 4 commits into from
Jan 27, 2023
Merged

Update to Rust 1.67 #17378

merged 4 commits into from
Jan 27, 2023

Conversation

teskje
Copy link
Contributor

@teskje teskje commented Jan 27, 2023

This PR updates the Rust version to 1.67.

There are a couple new lints that trigger on our code now, which are fixed/silenced in separate commits.

  • result_large_err: Fixed by boxing the offending error variant types.
  • "#[track_caller] on async functions is a no-op" (compiler warning): Fixed by removing the offending #[track_caller] annotations. Silenced by adding a manual #[allow].
  • let_underscore_future: These are FPs on task::spawn. Avoided by removing the let _ bindings.
  • unchecked_duration_subtraction: Silenced by adding a manual #[allow].

Motivation

  • This PR refactors existing code.

Tips for reviewer

Look at the commits separately!

Most of these lint failures can be solved differently (e.g. by globally ignoring the lint). I don't have strong feelings to any of the fixes in this PR, so please LMK if you'd prefer something different!

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered.

  • This PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way) and therefore is tagged with a T-proto label.

  • If this PR will require changes to cloud orchestration, there is a
    companion cloud PR to account for those changes that is tagged with
    the release-blocker label (example).

  • This PR includes the following user-facing behavior changes: N/A

`ResolvedObjectName` types are larger than 128 bytes, which made clippy
complain about the size of the `PlanError` enum. Solved by boxing
occurences of this type within `PlanError`.
@teskje teskje marked this pull request as ready for review January 27, 2023 10:26
@teskje teskje requested a review from a team January 27, 2023 10:26
@teskje teskje requested review from a team as code owners January 27, 2023 10:26
@@ -580,7 +580,6 @@ impl PersistClient {

/// Test helper for a [Self::open] call that is expected to succeed.
#[cfg(test)]
#[track_caller]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it always be the case that it doesn't have an effect. If it's meant to have an effect in the future it might be better to keep them and add an allow. cc @danhhz

Copy link
Contributor Author

@teskje teskje Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully not! rust-lang/rust#87417 is the tracking issue for making it do something.

I was wondering the same thing, and the more I think about it, the more I believe you are right and we should add an allow here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed!

`#[track_caller]` has no effect on async functions currently, and the
compiler warns about that. However, fixing this is in progress ([0]).
Rather than removing the annotations from async functions, we instead
ignore the compiler warning, so we don't forget to add the annotations
again once [0] is implemented.

[0]: rust-lang/rust#87417
Assigning the `JoinHandle` returned by `spawn` to `_` triggers a the
clippy lint `let_underscore_future`. This is a known FP (see
rust-lang/rust-clippy#9932). The easiest way
to avoid it is to not do that assignment.
This requires us to silence a new clippy lint,
`clippy::unchecked_duration_subtraction`. While the lint triggering is
not an FP, it is not very helpful either in this case. Substracting a
small tick duration from the current time will never underflow, and if
it did we probably would like to panic anyway. Note that the lint seems
to be "allow by default" on the current clippy main, so we should be
able to remove the explicit #[allow] again in the future.
@@ -125,7 +125,7 @@ where
};

let service = Arc::clone(&self.service);
let _ = mz_ore::task::spawn(|| "maelstrom::handle".to_string(), async move {
mz_ore::task::spawn(|| "maelstrom::handle".to_string(), async move {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry to be a bother, but what's the new warning here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Futures must be polled for work to be done.

ah, what an odd interaction between the lint and the one case this isn't true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh you had this in the PR description 🤦, sorry!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good!

There is some discussion here, in case you haven't seen it: rust-lang/rust-clippy#9932. I would be fine with simply disabling this lint, if you'd rather keep the let _ =. Although it generally seems to be a good thing to have. I think the other lint that prevents us from forgetting to await futures is the one that checks for #[must_use], and that is disabled by assigning the return value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was just reading that. it was indeed here for exactly the reason someone in that thread points out, but it's marginal enough that I don't particularly care

The let _ is indeed not strictly necessary (JoinHandle isn't must_use), however I do find it serves a legitimate documentation goal, it signals to the reader that the return value of spawn is intentionally dropped, whereas with just spawn there's a doubt left of whether the original developer simply forgot, or not.

It can be handled differently: comments, calling mem::drop, ... let _ = is the idiomatic way of signalling "I don't care about the return value", though.

@@ -125,7 +125,7 @@ where
};

let service = Arc::clone(&self.service);
let _ = mz_ore::task::spawn(|| "maelstrom::handle".to_string(), async move {
mz_ore::task::spawn(|| "maelstrom::handle".to_string(), async move {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Futures must be polled for work to be done.

ah, what an odd interaction between the lint and the one case this isn't true

Copy link
Contributor

@maddyblue maddyblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sql stuff lgtm

@teskje teskje merged commit c1c3468 into MaterializeInc:main Jan 27, 2023
@teskje teskje deleted the update-rust branch January 27, 2023 21:38
@teskje
Copy link
Contributor Author

teskje commented Jan 27, 2023

TFTRs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants