Skip to content
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

Unused attributes prefixed with _ don't work #39

Open
dllu opened this issue Sep 15, 2021 · 2 comments
Open

Unused attributes prefixed with _ don't work #39

dllu opened this issue Sep 15, 2021 · 2 comments

Comments

@dllu
Copy link

dllu commented Sep 15, 2021

For example:

#[self_referencing]
pub struct RentalStream {
    lifetime: (),
    #[borrows(lifetime)]
    #[covariant]
    context: uvc::Context<'this>,
    #[borrows(context)]
    #[covariant]
    device: uvc::Device<'this>,
    #[borrows(device)]
    #[covariant]
    device_handle: uvc::DeviceHandle<'this>,
    #[borrows(device_handle)]
    #[covariant]
    stream_handle: uvc::StreamHandle<'this>,
    #[borrows(mut stream_handle)]
    #[covariant]
    active_stream: uvc::ActiveStream<'this, ()>,
}
warning: field is never read: `active_stream`
  --> examples/demo-viz/uvc_camera.rs:41:9
   |
41 |     pub active_stream: uvc::ActiveStream<'this, ()>,
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

but if I change it to _active_stream, I now get:

warning: method `with__active_stream` should have a snake case name
  --> examples/demo-viz/uvc_camera.rs:41:5
   |
41 |     _active_stream: uvc::ActiveStream<'this, ()>,
   |     ^^^^^^^^^^^^^^ help: convert the identifier to snake case: `with_active_stream`
   |
   = note: `#[warn(non_snake_case)]` on by default

warning: method `borrow__active_stream` should have a snake case name
  --> examples/demo-viz/uvc_camera.rs:41:5
   |
41 |     _active_stream: uvc::ActiveStream<'this, ()>,
   |     ^^^^^^^^^^^^^^ help: convert the identifier to snake case: `borrow_active_stream`

warning: method `with__active_stream_mut` should have a snake case name
  --> examples/demo-viz/uvc_camera.rs:41:5
   |
41 |     _active_stream: uvc::ActiveStream<'this, ()>,
   |     ^^^^^^^^^^^^^^ help: convert the identifier to snake case: `with_active_stream_mut`

So I had to end up putting a #[allow(dead_code)] on top of my struct RentalStream, a crude hack.

@alxdb
Copy link

alxdb commented Sep 10, 2022

I've just had this same issue, and it appears that #[allow(dead_code)] is no longer working.

@fluxehub
Copy link

fluxehub commented Jan 3, 2024

This is still an issue for me, neither _ nor using #[allow(dead_code)] will disable warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants