On Thu Jan 22, 2026 at 8:42 AM GMT, Alice Ryhl wrote:
> On Wed, Jan 21, 2026 at 04:37:46PM -0800, Deborah Brouwer wrote:
>> Currently these warnings, as errors, are preventing Tyr driver
>> from building:
>> 
>> error: field `device` is never read
>>   --> drivers/gpu/drm/tyr/driver.rs:37:5
>>    |
>> 36 | pub(crate) struct TyrDriver {
>>    |                   --------- field in this struct
>> 37 |     device: ARef<TyrDevice>,
>>    |     ^^^^^^
>>    |
>>    = note: `-D dead-code` implied by `-D warnings`
>>    = help: to override `-D warnings` add `#[allow(dead_code)]`
>> 
>> error: fields `mali` and `sram` are never read
>>    --> drivers/gpu/drm/tyr/driver.rs:196:5
>>     |
>> 195 | struct Regulators {
>>     |        ---------- fields in this struct
>> 196 |     mali: Regulator<regulator::Enabled>,
>>     |     ^^^^
>> 197 |     sram: Regulator<regulator::Enabled>,
>>     |     ^^^^
>> 
>> error: aborting due to 2 previous errors
>> 
>> Suppress these errors so that the Tyr driver will build.
>> 
>> Signed-off-by: Deborah Brouwer <[email protected]>
>
> I still don't understand why I couldn't reproduce it myself, but
> assuming it's not just an 1.80.0 issue, below is my review:
>
>>  drivers/gpu/drm/tyr/driver.rs | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
>> index 2a45d0288825..04c865cb4397 100644
>> --- a/drivers/gpu/drm/tyr/driver.rs
>> +++ b/drivers/gpu/drm/tyr/driver.rs
>> @@ -34,6 +34,7 @@
>>  
>>  #[pin_data(PinnedDrop)]
>>  pub(crate) struct TyrDriver {
>> +    #[allow(dead_code)]
>>      device: ARef<TyrDevice>,
>
> Let's use #[expect(dead_code)] so we remember to remove this when a user
> is added.
>
>>  }
>>  
>> @@ -193,6 +194,8 @@ struct Clocks {
>>  
>>  #[pin_data]
>>  struct Regulators {
>> +    #[allow(dead_code)]
>>      mali: Regulator<regulator::Enabled>,
>> +    #[allow(dead_code)]
>>      sram: Regulator<regulator::Enabled>,
>
> I don't think we intend to ever use these fields - they exist only for
> their destructor. In that case, please prefix them with an underscore
> instead:
>
> #[pin_data]
> struct Regulators {
>     _mali: Regulator<regulator::Enabled>,
>     _sram: Regulator<regulator::Enabled>,
> }

I wonder if it makes sense to request a feature to mute `dead_code` lint on
certain types which we know are there to represent a registration or resource
enablement.

Currently rustc's dead_code lint has a builtin exception for `PhantomData`, but
I think a lot other types should have the same treatment, this can be useful
even for other core types, e.g `PhantomPinned`.

Best,
Gary

Reply via email to