Skip to content
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

feat(lints): lint on formatting Report in anyhow construction #15457

Merged
merged 3 commits into from
Mar 5, 2024

Conversation

BugenZhao
Copy link
Member

Signed-off-by: Bugen Zhao [email protected]I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Inspired by #15109:

format_error lint should not be simply workarounded by adding an .as_report() method call. For example, we've started to instruct developers to use anyhow::Context if they're formatting errors in an anyhow! macro call since #14957.

This PR further enforce this by also adding the lints on the Reports in anyhow! calls. The UI test clearly shows the changes:

error: should not format error directly
--> $DIR/format_error.rs:79:27
|
LL | let _ = anyhow!("{}", err.as_report());
| ^^^^^^^^^^^^^^^
|
= help: consider directly wrapping the error with `anyhow::anyhow!(..)` instead of formatting its report
error: should not format error directly
--> $DIR/format_error.rs:80:48
|
LL | let _ = anyhow!("some error occurred: {}", err.as_report());
| ^^^^^^^^^^^^^^^
|
= help: consider using `anyhow::Context::(with_)context` to attach additional message to the error and make it an error source instead
error: should not format error directly
--> $DIR/format_error.rs:81:29
|
LL | let _ = anyhow!("{:?}", anyhow_err.as_report());
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider directly wrapping the error with `anyhow::anyhow!(..)` instead of formatting its report
error: should not format error directly
--> $DIR/format_error.rs:82:50
|
LL | let _ = anyhow!("some error occurred: {:?}", anyhow_err.as_report());
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider using `anyhow::Context::(with_)context` to attach additional message to the error and make it an error source instead

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@BugenZhao BugenZhao requested review from yuhao-su, xxchan and wenym1 March 5, 2024 08:25
@BugenZhao BugenZhao requested a review from a team as a code owner March 5, 2024 08:25
Signed-off-by: Bugen Zhao <[email protected]>
.into()
})
.and_then(|result| result),
try { join_result.context("failed to join creating actors futures")?? },
Copy link
Member

Choose a reason for hiding this comment

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

try {??} looks strange

Copy link
Member

Choose a reason for hiding this comment

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

magical

Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@BugenZhao BugenZhao added this pull request to the merge queue Mar 5, 2024
Merged via the queue into main with commit 3c3e75f Mar 5, 2024
27 of 28 checks passed
@BugenZhao BugenZhao deleted the bz/lint-format-report-in-anyhow branch March 5, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants