Repository navigation
Closed
Closed
Copy link
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.L-dead_codeLint: dead_codeLint: dead_codeP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.Untriaged performance or correctness regression.
Description
Code
mod ffi {
use super::*;
extern "C" {
pub fn DomPromise_AddRef(promise: *const Promise);
pub fn DomPromise_Release(promise: *const Promise);
}
}
#[repr(C)]
#[allow(unused)]
pub struct Promise {
private: [u8; 0],
__nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
}
pub unsafe trait RefCounted {
unsafe fn addref(&self);
unsafe fn release(&self);
}
unsafe impl RefCounted for Promise {
unsafe fn addref(&self) {
ffi::DomPromise_AddRef(self)
}
unsafe fn release(&self) {
ffi::DomPromise_Release(self)
}
}
Output with 1.79.0:
nothing
Output with 1.80.0:
warning: function `DomPromise_AddRef` is never used
--> src/lib.rs:5:16
|
5 | pub fn DomPromise_AddRef(promise: *const Promise);
| ^^^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: function `DomPromise_Release` is never used
--> src/lib.rs:6:16
|
6 | pub fn DomPromise_Release(promise: *const Promise);
| ^^^^^^^^^^^^^^^^^^
warning: `playground` (lib) generated 2 warnings
The original code didn't have the #[allow(unused)], which was added because of the "never constructed" dead_code lint, which I guess would be #126169. Adding a constructor does make the function never used errors go away, so it seems #[allow(unused)] doesn't have enough power.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.L-dead_codeLint: dead_codeLint: dead_codeP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.Untriaged performance or correctness regression.
Activity
apiraino commentedon Jun 12, 2024
WG-prioritization assigning priority (Zulip discussion).
@rustbot label -I-prioritize +P-medium
apiraino commentedon Jun 12, 2024
bisected to rust-lang-ci@c137109
cc @mu001999
mu001999 commentedon Jun 12, 2024
like #126169
glandium commentedon Jun 12, 2024
#126169 is about the struct itself, and there's a allow(unused). This is about the side effects.
mu001999 commentedon Jun 12, 2024
Oh, I see.
@rustbot claim
Rollup merge of rust-lang#126315 - mu001999-contrib:fix/126289, r=pet…
Rollup merge of rust-lang#126315 - mu001999-contrib:fix/126289, r=pet…
Rollup merge of rust-lang#126315 - mu001999-contrib:fix/126289, r=pet…
Rollup merge of rust-lang#126315 - mu001999-contrib:fix/126289, r=pet…
Unrolled build for rust-lang#126315