Skip to content

Commit 977c5fd

Browse files
authoredJun 13, 2024
Rollup merge of rust-lang#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 rust-lang#126289

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed
 

‎compiler/rustc_passes/src/dead.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ fn create_and_seed_worklist(
898898
match tcx.def_kind(id) {
899899
DefKind::Impl { .. } => false,
900900
DefKind::AssocConst | DefKind::AssocFn => !matches!(tcx.associated_item(id).container, AssocItemContainer::ImplContainer),
901-
DefKind::Struct => struct_all_fields_are_public(tcx, id.to_def_id()),
901+
DefKind::Struct => struct_all_fields_are_public(tcx, id.to_def_id()) || has_allow_dead_code_or_lang_attr(tcx, id).is_some(),
902902
_ => true
903903
})
904904
.map(|id| (id, ComesFromAllowExpect::No))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@ check-pass
2+
3+
mod ffi {
4+
use super::*;
5+
6+
extern "C" {
7+
pub fn DomPromise_AddRef(promise: *const Promise);
8+
pub fn DomPromise_Release(promise: *const Promise);
9+
}
10+
}
11+
12+
#[repr(C)]
13+
#[allow(unused)]
14+
pub struct Promise {
15+
private: [u8; 0],
16+
__nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
17+
}
18+
19+
pub unsafe trait RefCounted {
20+
unsafe fn addref(&self);
21+
unsafe fn release(&self);
22+
}
23+
24+
unsafe impl RefCounted for Promise {
25+
unsafe fn addref(&self) {
26+
ffi::DomPromise_AddRef(self)
27+
}
28+
unsafe fn release(&self) {
29+
ffi::DomPromise_Release(self)
30+
}
31+
}
32+
33+
fn main() {}

0 commit comments

Comments
 (0)
Please sign in to comment.