Re: [PATCH] gpu: nova-core: fix three clippy::precedence warnings

From: John Hubbard

Date: Sat Apr 04 2026 - 17:34:51 EST


On 4/4/26 4:29 AM, Danilo Krummrich wrote:
> On Sat Apr 4, 2026 at 1:13 PM CEST, Miguel Ojeda wrote:
>> On Sat, Apr 4, 2026 at 4:58 AM John Hubbard <jhubbard@xxxxxxxxxx> wrote:
>>>
>>> Clippy warns when shifts and bitwise-OR are mixed without parentheses,
>>> because the relative precedence of << and | is easy to misread. This was
>>> causing 3 warnings in drm-rust-next.
>>>
>>> For read_sysmem_flush_page_ga100(), add explicit parentheses.
>>>
>>> For the PCI ROM header parsing, replace the manual byte-shifting with
>>> u32::from_le_bytes(), which both fixes the warning and is clearer about
>>> the intended byte order.
>>>
>>> Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
>>
>> Please see:
>>
>> https://lore.kernel.org/rust-for-linux/20260401114540.30108-34-ojeda@xxxxxxxxxx/
>>
>> i.e. the plan was to allow it, since it may be a bit too annoying for
>> some. It was also the reason it was split upstream into a new lint,
>> which is why you only see it in Rust 1.85.0:
>>
>> The Clippy `precedence` lint was extended in Rust 1.85.0 to include
>> bitmasking and shift operations [1]. However, because it generated
>> many hits, in Rust 1.86.0 it was split into a new `precedence_bits`
>> lint which is not enabled by default [2].
>>
>> In other words, only Rust 1.85 has a different behavior.
>>
>> Having said that, if people prefer to have the extra parenthesis in
>> that case, then I don't mind to keep it enabled.
>
> I don't mind having the extra parenthesis, but I think we should disable the
> lint regardless, as I think it is a bit too much.
>
> I also think we should drop this patch, as it is not worth the churn, if we
> disable the lint.

OK, I sent v2 out before I noticed this, but I agree. :)

thanks,
--
John Hubbard