Skip to main content

wowlab_tidy/languages/rust/rules/interop/
mod.rs

1mod asref_bound_on_type;
2mod concrete_io_param;
3mod dll_boundary_types;
4mod ffi_crate_naming;
5mod ffi_in_core;
6mod ffi_thin_glue;
7mod foreign_reexports;
8mod future_send_assert;
9mod manual_async_fn;
10mod native_escape_hatches;
11mod nonsend_across_await;
12mod owned_ref_param;
13mod pub_api_foreign_types;
14mod range_over_rangebounds;
15mod support;
16
17fn crate_name(rel: &str) -> Option<&str> {
18    let mut parts = rel.split('/');
19
20    if parts.next() != Some("crates") {
21        return None;
22    }
23
24    let name = parts.next()?;
25
26    parts.next()?;
27
28    Some(name)
29}
30
31fn is_ffi_crate(name: &str) -> bool {
32    name.ends_with("-ffi") || name.ends_with("_ffi")
33}
34
35fn is_sys_crate(name: &str) -> bool {
36    name.ends_with("-sys") || name.ends_with("_sys")
37}
38
39/// wasm-bindgen exports follow their own ABI conventions, not the C FFI rules.
40fn wasm_exempt(contents: &str) -> bool {
41    contents.contains("wasm_bindgen")
42}
43
44/// `extern` without an explicit ABI defaults to `"C"`.
45fn is_extern_c(abi: Option<ra_ap_syntax::ast::Abi>) -> bool {
46    abi.is_some_and(|abi| {
47        abi.string_token()
48            .is_none_or(|name| name.text().trim_matches('"') == "C")
49    })
50}