-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip pub structs with repr(c) and repr(transparent) in dead code anal…
…ysis
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tests/ui/lint/dead-code/not-lint-structs-constructed-externally.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//@ check-pass | ||
#![deny(dead_code)] | ||
|
||
#[repr(C)] | ||
pub struct Foo { | ||
pub i: i16, | ||
align: i16 | ||
} | ||
|
||
mod ffi { | ||
use super::*; | ||
|
||
extern "C" { | ||
pub fn DomPromise_AddRef(promise: *const Promise); | ||
pub fn DomPromise_Release(promise: *const Promise); | ||
} | ||
} | ||
|
||
#[repr(C)] | ||
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() {} |