-
Notifications
You must be signed in to change notification settings - Fork 253
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
aya-log: Unify IP format hints into one, repsesent it by :i
token
#599
Conversation
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
I'm going to change other incorrect tokens (e.g. |
Having separate format hints and tokens per IP address family is unnecessary, since they are represented by different types and we handle format hints for each type separately. So we can just have one format hint. Also, we should be consistent with the format strings grammar in Rust[0]. The `type` token, which is mapped to formatting traits, usually consists of one letter[1] (and optional `?` for `Debug` trait, but that doesn't matter for us). It shouldn't consist of multiple letters. Our `:ipv4` and `:ipv6` tokens were clearly breaking that convention, so we should rather switch to something with one letter - hence `:i`. [0] https://doc.rust-lang.org/std/fmt/#syntax [1] https://doc.rust-lang.org/std/fmt/#formatting-traits
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.
Looks good to me!
I additionally tested this out locally on my project, and the results look good 👍
aya-log-ebpf-macros was failing to compile because it was referencing a couple of `DisplayHint` variants that no longer exist. These were removed in aya-rs#599. ``` Compiling aya-log-ebpf-macros v0.1.0 (/home/robert/aya/aya-log-ebpf-macros) error[E0599]: no variant or associated item named `Ipv4` found for enum `DisplayHint` in the current scope --> aya-log-ebpf-macros/src/expand.rs:93:22 | 93 | DisplayHint::Ipv4 => parse_str("::aya_log_ebpf::macro_support::check_impl_ipv4"), | ^^^^ variant or associated item not found in `DisplayHint` error[E0599]: no variant or associated item named `Ipv6` found for enum `DisplayHint` in the current scope --> aya-log-ebpf-macros/src/expand.rs:94:22 | 94 | DisplayHint::Ipv6 => parse_str("::aya_log_ebpf::macro_support::check_impl_ipv6"), | ^^^^ variant or associated item not found in `DisplayHint` For more information about this error, try `rustc --explain E0599`. ```
aya-log-ebpf-macros was failing to compile because it was referencing a couple of `DisplayHint` variants that no longer exist. These were removed in aya-rs#599. ``` Compiling aya-log-ebpf-macros v0.1.0 (/home/robert/aya/aya-log-ebpf-macros) error[E0599]: no variant or associated item named `Ipv4` found for enum `DisplayHint` in the current scope --> aya-log-ebpf-macros/src/expand.rs:93:22 | 93 | DisplayHint::Ipv4 => parse_str("::aya_log_ebpf::macro_support::check_impl_ipv4"), | ^^^^ variant or associated item not found in `DisplayHint` error[E0599]: no variant or associated item named `Ipv6` found for enum `DisplayHint` in the current scope --> aya-log-ebpf-macros/src/expand.rs:94:22 | 94 | DisplayHint::Ipv6 => parse_str("::aya_log_ebpf::macro_support::check_impl_ipv6"), | ^^^^ variant or associated item not found in `DisplayHint` For more information about this error, try `rustc --explain E0599`. ```
aya-log-ebpf-macros was failing to compile because it was referencing a couple of `DisplayHint` variants that no longer exist. These were removed in #599. ``` Compiling aya-log-ebpf-macros v0.1.0 (/home/robert/aya/aya-log-ebpf-macros) error[E0599]: no variant or associated item named `Ipv4` found for enum `DisplayHint` in the current scope --> aya-log-ebpf-macros/src/expand.rs:93:22 | 93 | DisplayHint::Ipv4 => parse_str("::aya_log_ebpf::macro_support::check_impl_ipv4"), | ^^^^ variant or associated item not found in `DisplayHint` error[E0599]: no variant or associated item named `Ipv6` found for enum `DisplayHint` in the current scope --> aya-log-ebpf-macros/src/expand.rs:94:22 | 94 | DisplayHint::Ipv6 => parse_str("::aya_log_ebpf::macro_support::check_impl_ipv6"), | ^^^^ variant or associated item not found in `DisplayHint` For more information about this error, try `rustc --explain E0599`. ```
`{:ipv4}` has been replaced with `{:i}` in aya-rs/aya#599.
Having separate format hints and tokens per IP address family is unnecessary, since they are represented by different types and we handle format hints for each type separately. So we can just have one format hint.
Also, we should be consistent with the format strings grammar in Rust[0]. The
type
token, which is mapped to formatting traits, usually consists of one letter[1] (and optional?
forDebug
trait, but that doesn't matter for us). It shouldn't consist of multiple letters. Our:ipv4
and:ipv6
tokens were clearly breaking that convention, so we should rather switch to something with one letter - hence:i
.[0] https://doc.rust-lang.org/std/fmt/#syntax
[1] https://doc.rust-lang.org/std/fmt/#formatting-traits