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

axum-core/macros: Change Display impl to match body_text() result #3118

Merged
merged 4 commits into from
Dec 27, 2024

Conversation

Turbo87
Copy link
Collaborator

@Turbo87 Turbo87 commented Dec 27, 2024

It seems less useful to only display $body without any information about the inner error. Since body_text() already combines both, this commit changes the Display impl to display the same.

Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Could you add a changelog entry for this?

It seems less useful to only display `$body` without any information about the inner error. Since `body_text()` already combines both, this commit changes the `Display` impl to display the same.
Since they both result in the same thing we might as well take advantage of one in the other.
@Turbo87
Copy link
Collaborator Author

Turbo87 commented Dec 27, 2024

Could you add a changelog entry for this?

sure, done

side question: any thoughts on using e.g. https://git-cliff.org/ to generate the changelogs automatically from the merged pull requests? We've started using that over at /~https://github.com/LukeMathWalker/cargo-manifest with the changelog entries being based on the labels of the merged pull requests and its been working quite well.

@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

# 0.5.0

- **change:** Change rejection `Display` impl to match `body_text()` result ([#3118])
Copy link
Member

Choose a reason for hiding this comment

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

I think this doesn't have enough info. We need to

  • mention that this affects all the (composite / enum?) extractors defined by axum and axum-extra or move this to those changelogs
  • state what was different about these before / what's the user-visible change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've slightly tweaked it. Is that better?

  • state what was different about these before / what's the user-visible change

I don't think there is a user-visible change in most cases since the body_text() impl hasn't really changed. The only thing that changed is the Display impl, which probably isn't actually visible to the user in most cases.

Copy link
Member

Choose a reason for hiding this comment

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

I meant how the change would be observable by users of axum, not (necessarily) end users.

New entry looks good 👍

@@ -132,7 +132,7 @@ macro_rules! __define_rejection {

impl std::fmt::Display for $name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", $body)
write!(f, concat!($body, ": {}"), self.0)
Copy link
Member

Choose a reason for hiding this comment

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

I'd slightly prefer f.write_str to not rely on inlining as much, but that probably affects other places too and can be a separate PR once again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added another commit that switches it over to use write_str()

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I thought it was just going to be one write_str, but I guess that would have only been the case for the non-composite case. Anyways, doesn't hurt.

@jplatte
Copy link
Member

jplatte commented Dec 27, 2024

side question: any thoughts on using e.g. https://git-cliff.org/ to generate the changelogs automatically from the merged pull requests?

Yes, I hate it with a passion 😂

Frequently I write changelog entries that look a lot different than the associated commit message, and not because one or the other is bad. They're just for different audiences: commit messages are for the project's developers mostly, changelog entries are for its users.

It's also super easy to ask a contributor to add an entry to a markdown file and have the existing contents there guide them to writing a useful entry, or post a follow-up PR adding a previous PR to the changelog. I haven't seen a nice equivalent for those things in projects using git-cliff.

I heard that my ex colleagues from my previous job recently tried a git-cliff based workflow where there were separate git commit message trailers for changelog entries, alleviating my first concern from above. However they went back to a hand-written changelog after not too long. Idk why, but if you're interested I can ping one of them 🙂

@Turbo87
Copy link
Collaborator Author

Turbo87 commented Dec 27, 2024

Yes, I hate it with a passion 😂

Frequently I write changelog entries that look a lot different than the associated commit message, and not because one or the other is bad. They're just for different audiences: commit messages are for the project's developers mostly, changelog entries are for its users.

😂

FWIW I agree with you with regard to changelogs generated from commits. That's why I'm usually generating the changelog from pull requests, and specifically their title and labels, which are still adjustable even after they are merged.

It's also super easy to ask a contributor to add an entry to a markdown file

sure, though it requires at least one other review cycle, potentially causing delays in merging PRs. if all maintainers are as responsive as you are then this is probably not an issue, but my experience is different 😅

@Turbo87 Turbo87 merged commit 53370b2 into tokio-rs:main Dec 27, 2024
18 checks passed
@Turbo87 Turbo87 deleted the rejection-display branch December 27, 2024 11:23
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.

2 participants