Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov
Add pub struct with allow(dead_code) into worklist <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r? <reviewer name> --> Fixes #126289
This commit is contained in:
commit
977c5fd419
@ -898,7 +898,7 @@ fn create_and_seed_worklist(
|
|||||||
match tcx.def_kind(id) {
|
match tcx.def_kind(id) {
|
||||||
DefKind::Impl { .. } => false,
|
DefKind::Impl { .. } => false,
|
||||||
DefKind::AssocConst | DefKind::AssocFn => !matches!(tcx.associated_item(id).container, AssocItemContainer::ImplContainer),
|
DefKind::AssocConst | DefKind::AssocFn => !matches!(tcx.associated_item(id).container, AssocItemContainer::ImplContainer),
|
||||||
DefKind::Struct => struct_all_fields_are_public(tcx, id.to_def_id()),
|
DefKind::Struct => struct_all_fields_are_public(tcx, id.to_def_id()) || has_allow_dead_code_or_lang_attr(tcx, id).is_some(),
|
||||||
_ => true
|
_ => true
|
||||||
})
|
})
|
||||||
.map(|id| (id, ComesFromAllowExpect::No))
|
.map(|id| (id, ComesFromAllowExpect::No))
|
||||||
|
33
tests/ui/lint/dead-code/allow-unconstructed-pub-struct.rs
Normal file
33
tests/ui/lint/dead-code/allow-unconstructed-pub-struct.rs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user