about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/no_mangle_with_rust_abi.rs
blob: f4248ffc0f4d0ff0b87475ac98d555f6ac201d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//@no-rustfix: overlapping suggestions
#![allow(unused)]
#![warn(clippy::no_mangle_with_rust_abi)]

#[unsafe(no_mangle)]
fn rust_abi_fn_one(arg_one: u32, arg_two: usize) {}
//~^ no_mangle_with_rust_abi

#[unsafe(no_mangle)]
pub fn rust_abi_fn_two(arg_one: u32, arg_two: usize) {}
//~^ no_mangle_with_rust_abi

/// # Safety
/// This function shouldn't be called unless the horsemen are ready
#[unsafe(no_mangle)]
pub unsafe fn rust_abi_fn_three(arg_one: u32, arg_two: usize) {}
//~^ no_mangle_with_rust_abi

/// # Safety
/// This function shouldn't be called unless the horsemen are ready
#[unsafe(no_mangle)]
unsafe fn rust_abi_fn_four(arg_one: u32, arg_two: usize) {}
//~^ no_mangle_with_rust_abi

#[unsafe(no_mangle)]
fn rust_abi_multiline_function_really_long_name_to_overflow_args_to_multiple_lines(
    //~^ no_mangle_with_rust_abi
    arg_one: u32,
    arg_two: usize,
) -> u32 {
    0
}

// Must not run on functions that explicitly opt in to using the Rust ABI with `extern "Rust"`
#[unsafe(no_mangle)]
#[rustfmt::skip]
extern "Rust" fn rust_abi_fn_explicit_opt_in(arg_one: u32, arg_two: usize) {}

fn rust_abi_fn_again(arg_one: u32, arg_two: usize) {}

#[unsafe(no_mangle)]
extern "C" fn c_abi_fn(arg_one: u32, arg_two: usize) {}

extern "C" fn c_abi_fn_again(arg_one: u32, arg_two: usize) {}

unsafe extern "C" {
    fn c_abi_in_block(arg_one: u32, arg_two: usize);
}

mod r#fn {
    #[unsafe(no_mangle)]
    pub(in super::r#fn) fn with_some_fn_around() {}
    //~^ no_mangle_with_rust_abi
}

fn main() {
    // test code goes here
}