-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Document the fact that debug_handler
doesn't work within impl blocks
#1800
Document the fact that debug_handler
doesn't work within impl blocks
#1800
Conversation
/// This macro does not work for associated functions — functions defined in an `impl` block that | ||
/// don't take `self`: |
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 macro does not work for associated functions — functions defined in an `impl` block that | |
/// don't take `self`: | |
/// This macro does not work for associated functions that aren't methods — functions defined in an `impl` block that | |
/// don't take `self`: |
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.
But an associated function is never a method 🤔
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 added this clarification @davidpdrsn — maybe I'm splitting hairs, but I think it pays to try and get it right
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.
https://doc.rust-lang.org/reference/items/associated-items.html#methods
Associated functions whose first parameter is named self are called methods and may be invoked using the method call operator, for example, x.foo(), as well as the usual function call notation.
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 macro does not work for associated functions — functions defined in an `impl` block that | |
/// don't take `self`: | |
/// This macro does not work functions in an `impl` block that | |
/// don't have a `self` parameter: |
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, already merged 😅
Motivation
When upgrading from from axum 0.5.x to 0.6.x I encountered a breaking change to how the
debug_handler
macro works.In 0.5.x, an associated function (not a method) could be used with
debug_handler
. In 0.6.x this yields confusing compilation errors.As per @davidpdrsn on Discord:
Solution
This PR attempts to document this behavior.