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

Rust nightly warning about dead code #3096

Closed
kennykerr opened this issue Jun 13, 2024 · 2 comments · Fixed by #3103
Closed

Rust nightly warning about dead code #3096

kennykerr opened this issue Jun 13, 2024 · 2 comments · Fixed by #3103
Labels
bug Something isn't working

Comments

@kennykerr
Copy link
Collaborator

kennykerr commented Jun 13, 2024

The latest Rust nightly compiler raises a new warning about dead code.

D:\git\windows-rs> cargo check -p windows --features Foundation      
warning: struct `IReference` is never constructed
    --> crates\libs\windows\src\Windows\Foundation\mod.rs:1024:12
     |
1024 | pub struct IReference<T>(windows_core::IUnknown, core::marker::PhantomData<T>)
     |            ^^^^^^^^^^
     |
     = note: `#[warn(dead_code)]` on by default

warning: struct `IReferenceArray` is never constructed
    --> crates\libs\windows\src\Windows\Foundation\mod.rs:1281:12
     |
1281 | pub struct IReferenceArray<T>(windows_core::IUnknown, core::marker::PhantomData<T>)
     |            ^^^^^^^^^^^^^^^

warning: `windows` (lib) generated 2 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s

This seems like a Rust nightly bug. I don't see what's wrong with this code.

Originally noticed here: https://github.com/microsoft/windows-rs/actions/runs/9501067497/job/26185702630

@kennykerr
Copy link
Collaborator Author

kennykerr commented Jun 13, 2024

You can for example use IReference as follows (from another crate):

use windows::{core::*, Foundation::*};

fn main() -> Result<()> {
    let r: IReference<i32> = PropertyValue::CreateInt32(123)?.cast()?;
    assert_eq!(r.Value()?, 123);
    Ok(())
}

I may just allow dead_code to unblock other work until this is resolved in the Rust compiler.

@kennykerr
Copy link
Collaborator Author

This seems to be similar to rust-lang/rust#126169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant