Re: [PATCH 1/2] rust: macros: improve panic messages

Tamir Duberstein
2025-02-07T19:02:13Z

On Fri, Feb 7, 2025 at 1:12 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Fri, Feb 7, 2025 at 6:22 PM Tamir Duberstein <tamird@gmail.com> wrote:
> >
> > Include unexpected input on parsing failures. This has the side effect
> > of avoiding a spurious rust-analyzer warning:
> >
> > Variable `None` should have snake_case name, e.g. `none`
>
> Hmm... That should be solved independently, but sure.
>
> In any case, how is this related to the second patch in the series?
> i.e. do you need both to solve the macOS issue?

No, it's not required - you're right to point that out. I'll send it
separately. Is it very inconvenient to consider the other patch on its
own?

> > + let Some(token) = it.next() else {
> > + break;
> > + };
> > + match token {
> > + TokenTree::Punct(punct) => assert_eq!(punct.as_char(), ','),
> > + token => panic!("Expected ',' or end of array, got {}", token),
>
> Do we want to shadow here?

I personally like this style because the shadow and shadowed are the
same variable and the presence of a binding in the match expression
hints to the reader that it's used somewhere in the body of the match
arm. Do you have another preference?

> Also, I think you could write `{token}`. Same above.

Good call. Will make it so.

> Could you please show how the new output would look like in the commit message?

Yes, I will include before and after output.

> Cheers,
> Miguel